image_output_1.png
from scipy import stats

from scipy.stats import norm, skew

import matplotlib.pyplot as plt

import numpy as np

import os

import pandas as pd

import seaborn as sns

import warnings

import os
import pandas as pd
import numpy as np
import seaborn as sns
color = sns.color_palette()
sns.set_style('darkgrid')
import math
import matplotlib.pyplot as plt
from scipy.stats import skew
import warnings
def ignore_warn(*args, **kwargs):
    pass
warnings.warn = ignore_warn
from scipy import stats
from scipy.stats import norm, skew

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

fig, ax = plt.subplots()
ax.scatter(x = training_dataframe['GrLivArea'], y = training_dataframe['SalePrice'])
plt.ylabel('SalePrice', fontsize=13)
plt.xlabel('GrLivArea', fontsize=13)
plt.show()

#Deleting outliers
training_dataframe= training_dataframe.drop(training_dataframe[(training_dataframe['GrLivArea']>4000) & (training_dataframe['SalePrice']<300000)].index)

#Check the scatterplot again
fig, ax = plt.subplots()
ax.scatter(training_dataframe['GrLivArea'], training_dataframe['SalePrice'])
plt.ylabel('SalePrice', fontsize=13)
plt.xlabel('GrLivArea', fontsize=13)
plt.show()

#Plotting histogram
sns.distplot(training_dataframe['SalePrice'] , fit=norm);

# Fitted Parameters used by function
(mu, sigma) = norm.fit(training_dataframe['SalePrice'])
print( '\n mu = {:.2f} and sigma = {:.2f}\n'.format(mu, sigma))

#Plotting the distribution
plt.legend(['Normal dist. ($\mu=$ {:.2f} and $\sigma=$ {:.2f} )'.format(mu, sigma)],
            loc='best')
plt.ylabel('Frequency')
plt.title('SalePrice distribution')

#Plotting QQ-plot
fig = plt.figure()
res = stats.probplot(training_dataframe['SalePrice'], plot=plt)
plt.show()

training_dataframe['SalePrice'] = np.log1p(training_dataframe['SalePrice'])
sns.distplot(training_dataframe['SalePrice'], fit=norm)
mu, sigma = norm.fit(training_dataframe['SalePrice'])
print('\n mu = {:.2f} and sigma = {:.2f}\n'.format(mu, sigma))
plt.legend(['Normal dist. ($\\mu=$ {:.2f} and $\\sigma=$ {:.2f} )'.format(mu, sigma)], loc='best')
plt.ylabel('Frequency')
plt.title('SalePrice distribution')
fig = plt.figure()
res = stats.probplot(training_dataframe['SalePrice'], plot=plt)
plt.show()