image_output_1.png
from scipy import stats

from scipy.stats import norm, skew

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

import pandas as pd
train = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')

train = pd.read_csv('09-house-train.csv')
test = pd.read_csv('09-house-test.csv')

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

train.iloc[0:5, :3]

null_cols = pd.DataFrame(train.isnull().sum().sort_values(ascending=False), columns=['Null Data Count'])
null_cols_pct = pd.DataFrame(round(train.isnull().sum().sort_values(ascending=False) / len(train), 2) * 100, columns=['Null Data Pct'])
null_cols_df = pd.DataFrame(pd.concat([null_cols, null_cols_pct], axis=1))
all_nulls = null_cols_df[null_cols_df['Null Data Pct'] > 0]
all_nulls

plt.xticks(rotation='90')

saleprice_df = pd.concat([train.SalePrice, np.log(train.SalePrice + 1).rename('LogSalePrice')], axis=1, names=['SalePrice', 'LogSalePrice'])

train = train.drop(train[train.SalePrice > 450000].index)

sns.set_style("white")
sns.set_color_codes(palette='deep')

# Create figure space
fig, ax = plt.subplots(figsize=(18,5), ncols=2, nrows=1)

# Create a distribution plot
ax1 = sns.distplot(saleprice_df.SalePrice, kde=False, fit=norm, ax=ax[0])
ax2 = sns.distplot(saleprice_df.LogSalePrice, kde=False, fit=norm, ax=ax[1])

# Set plot features
ax1.set_title('SalePrice Distribution')
ax2.set_title('LogSalePrice Distribution')

mu, sigma = norm.fit(train['SalePrice'])

train['LogSalePrice'] = np.log1p(train.SalePrice)

stats.probplot(train['SalePrice'], plot=plt)
plt.show()