皮爾遜pearsonCorrelation coefficient and Spearmanspearman等級相關系數.
They can be used to measure the magnitude of the correlation between two variables
1. 總體:All the individuals of the object to be examined are called the totality
(我國10The data obtained from the annual census is the overall data)
2. 樣本:從總體中所抽取的一部分個體叫做總體的一個樣本
(在QQThe data obtained by sending out the questionnaires and asking students to help them fill in are the sample data)
import pandas as pd
data = pd.read_excel('八年級女生體測數據.xlsx')
data.corr() # 計算相關性系數
運行結果:
## Correlation coefficient heatmap
import seaborn as sns
import matplotlib.pyplot as plt
corr = data.corr()
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] =False #減號unicode編碼
ax = plt.subplots(figsize=(20, 16))#調整畫布大小
ax = sns.heatmap(corr, vmax=.8, square=True, annot=True)#畫熱力圖 annot=True Indicates display coefficient
# 設置刻度字體大小
plt.xticks(fontsize=13)
plt.yticks(fontsize=13)
運行結果:
use Python Do algorithms , Not
Python Learn to share today :