-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython seaborn correlation
More file actions
52 lines (33 loc) · 1.04 KB
/
Copy pathPython seaborn correlation
File metadata and controls
52 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#1.Mount drive
from google.colab import drive
drive.mount('/content/drive')
#2.load dataset from drive
import pandas as pd
df5= pd.read_csv("/content/drive/My Drive/data5.csv",encoding ='latin1')
..............................................................................
#3.Correlation plot using seaborn package (sns), matplotlib for visualisation
import matplotlib.pyplot as plt
import seaborn as sns
#3.1 with regression
sns.pairplot(df, kind="reg")
plt.show()
# with color and correlation by one variable (ex: ethnicity)
sns.pairplot(df5, kind="scatter", hue="Ethnicity", markers=["o", "s", "D"], palette="Set2")
plt.show()
#3.2 without regression
sns.pairplot(df5, kind="scatter")
plot.show()
.............................................................................
#4.Correlation heatmap
corr = df5.corr()
ax = sns.heatmap(
corr,
vmin=-1, vmax=1, center=0,
cmap=sns.diverging_palette(20, 220, n=200),
square=True
)
ax.set_xticklabels(
ax.get_xticklabels(),
rotation=45,
horizontalalignment='right'
);