text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sb

import statsmodels.api as sm

df = pd.read_csv('../input/kc_house_data.csv')

#df correlation matrix
f,ax = plt.subplots(figsize=(12, 9))
sb.heatmap(df.corr(), annot=True, linewidths=.5, fmt='.1f', ax=ax)

var = 'sqft_living'
data = pd.concat([df['price'], df[var]], axis=1)

#scatter plot 'grade'/'price'
var1 = 'grade'
data = pd.concat([df['price'], df[var1]], axis=1)
f, ax = plt.subplots(figsize=(8, 6))
fig = sb.boxplot(x=var1, y="price", data=data)
fig.axis(ymin=0, ymax=8000000);

# Correlation matrix updated (X)
X = df[['bedrooms','floors','condition','grade','sqft_basement','yr_built','yr_renovated','lat','long','sqft_lot15']]
f,ax = plt.subplots(figsize=(18, 18))
sb.heatmap(X.corr(), annot=True, linewidths=0.5, fmt='.1f', ax=ax)

X = df[['bedrooms', 'floors', 'condition', 'grade', 'sqft_basement', 'yr_built', 'yr_renovated', 'lat', 'long', 'sqft_lot15']]
y = df['price']

est = sm.OLS(y, X).fit()
est.summary()