-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEDA.py
36 lines (26 loc) · 899 Bytes
/
EDA.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Oct 20 22:20:02 2018
@author: bking
"""
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# Load data
train_df = pd.read_csv("data/train_pre.csv",index_col=0)
def corr_matrix(df_truth):
# Compute the correlation matrix
corr = df_truth.corr()
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))
# Generate a custom diverging colormap
cmap = sns.diverging_palette(220, 10, as_cmap=True)
# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
square=True, linewidths=.5, cbar_kws={"shrink": .5})
corr_matrix(train_df)