日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
創(chuàng)新互聯(lián)Python教程:python熱力圖的原理實(shí)現(xiàn)

在我們想要對(duì)不同變量進(jìn)行判斷的時(shí)候,會(huì)分析其中的之間的聯(lián)系。這種理念同樣也被用在實(shí)例生活中,最常見(jiàn)到的是做一個(gè)地理的熱力圖。很多人對(duì)畫(huà)熱力圖的方法不是很清楚,我們可以先裝好相關(guān)的工具,了解一些使用參數(shù),然后在實(shí)例中進(jìn)行畫(huà)熱力圖的實(shí)例體驗(yàn),下面就來(lái)看看具體的方法吧。

1.導(dǎo)入相關(guān)的packages

import seaborn as sns
%matplotlib inline
sns.set(font_scale=1.5)

2.參數(shù)

vmax:設(shè)置顏色帶的值

vmin:設(shè)置顏色帶的最小值

cmap:設(shè)置顏色帶的色系

center:設(shè)置顏色帶的分界線

annot:是否顯示數(shù)值注釋

fmt:format的縮寫(xiě),設(shè)置數(shù)值的格式化形式

linewidths:控制每個(gè)小方格之間的間距

linecolor:控制分割線的顏色

cbar_kws:關(guān)于顏色帶的設(shè)置

mask:傳入布爾型矩陣,若為矩陣內(nèi)為True,則熱力圖相應(yīng)的位置的數(shù)據(jù)將會(huì)被屏蔽掉(常用在繪制相關(guān)系數(shù)矩陣圖)

3.實(shí)例

用Python生成heatmap比較簡(jiǎn)單,導(dǎo)入googlmap然后把經(jīng)緯度plot在地圖上就可以了。最后把heatmap生成為一個(gè)html文件,可以放大和縮小。

import gmplot             # plot the locations on google map
import numpy as np        # linear algebra
import pandas as pd       # data processing, CSV file I/O (e.g. pd.read_csv())
import matplotlib.pyplot as plt  # data visualization
import seaborn as sns       # data visualization
 
 
df = pd.read_csv("data.csv")
df = pd.DataFrame(df)
df_td = pd.read_csv("datacopy.csv")
df_td = pd.DataFrame(df_td)
# print df.dtypes
print (df.shape)
print (df_td.shape)
 
def plot_heat_map(data, number):
    latitude_array = data['INTPTLAT'].values
    latitude_list = latitude_array.tolist()
    print(latitude_list[0])
 
    Longitude_array = data['INTPTLONG'].values
    longitude_list = Longitude_array.tolist()
    print(longitude_list[0])
 
    # Initialize the map to the first location in the list
    gmap = gmplot.GoogleMapPlotter(latitude_list[0], longitude_list[0], 10)
 
    # gmap.scatter(latitude_list, longitude_list, edge_width=10)
    gmap.heatmap(latitude_list, longitude_list)
 
    # Write the map in an HTML file
    # gmap.draw('Paths_map.html')
    gmap.draw('{}_Paths_map.html'.format(number))
 
 
plot_heat_map(df,'4')

以上就是python熱力圖的原理實(shí)現(xiàn),大家可以先跟著代碼試驗(yàn)一下,看看是否能運(yùn)行出相關(guān)的熱力圖,然后就其中的一些知識(shí)點(diǎn)進(jìn)行學(xué)習(xí)。


本文標(biāo)題:創(chuàng)新互聯(lián)Python教程:python熱力圖的原理實(shí)現(xiàn)
標(biāo)題網(wǎng)址:http://www.dlmjj.cn/article/cdohdoe.html