text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd

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

import seaborn as sns

path = '../input/train.csv'

df = pd.read_csv(path)

df.columns

fig = plt.figure(2)
ax1 = fig.add_subplot(2, 2, 1)
ax2=fig.add_subplot(2,2,2)
ax3=fig.add_subplot(2,2,3)
ax4=fig.add_subplot(2,2,4)
df.plot.scatter(x='LotFrontage',y='SalePrice',ax=ax1)
df.plot.scatter(x='LotArea',y='SalePrice',ax=ax2)
df.plot.scatter(x='MSSubClass',y='SalePrice',ax=ax3)
df.plot.scatter(x='OverallQual',y='SalePrice',ax=ax4)
plt.show()

sns.set()
cols = list(df.columns)

X = df.drop('SalePrice', axis=1)

X_con = X.select_dtypes(exclude='object')

X_con_col = list(X_con.columns)

#outlier detection and replacing them with mean
def outlier_detect(df):
    for i in df.describe().columns:
        Q1=df.describe().at['25%',i]
        Q3=df.describe().at['75%',i]
        IQR=Q3 - Q1
        LTV=Q1 - 1.5 * IQR
        UTV=Q3 + 1.5 * IQR
        x=np.array(df[i])
        p=[]
        for j in x:
            if j < LTV or j>UTV:
                p.append(df[i].median())
            else:
                p.append(j)
        df[i]=p
    return df

X_con = outlier_detect(X_con)

X_con.isnull().sum()