application_vnd.jupyter.stderr_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.preprocessing import LabelEncoder

from sklearn.preprocessing import LabelEncoder

import numpy as np

import pandas as pd

houseprice = pd.read_csv('C:/Users/hp/Desktop/KAGGLE/Ames Houses DATA/train.csv')

houseprice.isnull().sum()

housedfnum = houseprice.select_dtypes(include=[np.number])

housedfcat = houseprice.select_dtypes(include=[object])

le = LabelEncoder()

housedfnum['MSSubClass'] = le.fit_transform(housedfnum['MSSubClass'].values)
housedfnum['OverallQual'] = le.fit_transform(housedfnum['OverallQual'].values)
housedfnum['OverallCond'] = le.fit_transform(housedfnum['OverallCond'].values)
housedfnum['YearBuilt'] = le.fit_transform(housedfnum['YearBuilt'].values)
housedfnum['YearRemodAdd'] = le.fit_transform(housedfnum['YearRemodAdd'].values)
housedfnum['YrSold'] = le.fit_transform(housedfnum['YrSold'].values)
housedfnum['GarageYrBlt'] = le.fit_transform(housedfnum['GarageYrBlt'].values)

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

housedfcat2 = housedfcat1.apply(le.fit_transform)

housefinal = pd.concat([housedfnum, housedfcat2], axis=1)

housefinal.shape

LiR = LinearRegression()

y = housefinal['SalePrice']
X = housefinal.drop(['Id', 'SalePrice'], axis=1)

LiR.fit(X, y)

LiR.score(X, y)

predictedprice = LiR.predict(X)

priceresidual = housefinal.SalePrice - predictedprice

np.sqrt(np.mean(priceresidual ** 2))

housetest = pd.read_csv('C:/Users/hp/Desktop/KAGGLE/Ames Houses DATA/test.csv')

housetest.isnull().sum()

housetestnum = housetest.select_dtypes(include=[np.number])

housetestcat = housetest.select_dtypes(include=[object])

housetestnum.isnull().sum()

housetestnum.isnull().sum()

housetestcat.isnull().sum()

le = LabelEncoder()

housetestnum['MSSubClass'] = le.fit_transform(housetestnum['MSSubClass'].values)
housetestnum['OverallQual'] = le.fit_transform(housetestnum['OverallQual'].values)
housetestnum['OverallCond'] = le.fit_transform(housetestnum['OverallCond'].values)
housetestnum['YearBuilt'] = le.fit_transform(housetestnum['YearBuilt'].values)
housetestnum['YearRemodAdd'] = le.fit_transform(housetestnum['YearRemodAdd'].values)
housetestnum['YrSold'] = le.fit_transform(housetestnum['YrSold'].values)
housetestnum['GarageYrBlt'] = le.fit_transform(housetestnum['GarageYrBlt'].values)

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

housetestcat1.isnull().sum()

housetestcat1['MSZoning'] = le.fit_transform(housetestcat1['MSZoning'].astype(str))

housetestcat1['Utilities'] = le.fit_transform(housetestcat1['Utilities'].astype(str))