text_plain_output_1.png
import matplotlib.pyplot as plt

import missingno as msno

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', 20)

test = pd.read_csv('../input/house-prices-advanced-regression-techniques/test.csv')
train = pd.read_csv('../input/house-prices-advanced-regression-techniques/train.csv')

train.shape

train = train.drop(['Id'], axis=1)

missingdata_df = train.columns[train.isnull().any()].tolist()
msno.matrix(train[missingdata_df])

target = np.log(train['SalePrice'])
target.skew()

train = train.drop(['PoolQC', 'MiscFeature', 'Alley', 'Fence', 'FireplaceQu'], axis=1)

numeric_data = train.select_dtypes(include=[np.number])
categorical_data = train.select_dtypes(exclude=[np.number])

# Compute the correlation matrix
corr = numeric_data.corr()

# Generate a mask for the upper triangle
mask = np.triu(np.ones_like(corr, dtype=np.bool))

# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(11, 9))
plt.title('Correlation of Numeric Features',y=1,size=16)

# 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})

correlation = numeric_data.corr()

k= 10 # just taking 10 column with largest correlation coefficients with sales price
cols = correlation.nlargest(k,'SalePrice')['SalePrice'].index
print(cols)
cm = np.corrcoef(train[cols].values.T)
f , ax = plt.subplots(figsize = (14,11))
plt.title('Correlation of 10 numerical features with highest R with Sales Price',y=1,size=16)
sns.heatmap(cm, vmax=.8, linewidths=0.01,square=True,annot=True,cmap='viridis',
            linecolor="black",xticklabels = cols.values ,annot_kws = {'size':12},yticklabels = cols.values)

sns.set()
columns = ['SalePrice', 'OverallQual', 'GrLivArea', 'GarageCars', 'GarageArea', 'TotalBsmtSF', '1stFlrSF', 'FullBath', 'TotRmsAbvGrd', 'YearBuilt']
sns.pairplot(train[columns], height=2, kind='scatter', diag_kind='kde')
plt.show()