text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import numpy as np

import pandas as pd

import seaborn as sns

data = pd.read_csv('../input/house-prices-advanced-regression-techniques/train.csv')
y = data['SalePrice']
data.drop(columns=['SalePrice'], inplace=True)

data.skew().sort_values(ascending=False)

data.kurt().sort_values(ascending=False)

missingVals = data.isnull().mean() * 100
missingVals.sort_values(ascending=False).head(20)

data.drop(columns=['Alley', 'Fence', 'PoolQC', 'MiscFeature', 'FireplaceQu', 'Id'], inplace=True)

corr = data.corr()
kot = corr[np.abs(corr) >= 0.7]

data.drop(columns=['GarageArea', 'GrLivArea', 'GarageYrBlt'], inplace=True)

y = data.SalePrice
data.drop(columns=['SalePrice'], inplace=True)

data.columns

def get_num_cat_features(type_features, data):
    return data.select_dtypes(include=type_features)
numerics = ['int64', 'float64']
newdf_num = get_num_cat_features(numerics, data)
newdf_cat = data.select_dtypes(['object'])

test = pd.read_csv('../input/house-prices-advanced-regression-techniques/test.csv')
test.drop(columns=['Id', 'Alley', 'Fence', 'PoolQC', 'MiscFeature', 'FireplaceQu'], inplace=True)
test.drop(columns=['GarageArea', 'GrLivArea', 'GarageYrBlt'], inplace=True)
test.fillna(test.mean())
numericstest = ['int64', 'float64']
newdf_numtest = get_num_cat_features(numerics, test)
test_num = get_num_cat_features(numerics, test)
newdf_cattest = test.select_dtypes(['object'])
trainTest = newdf_cat.append(newdf_cattest)

def encode_labels(data):
    encoded_categoric_train_set = data.copy()
    for c in data.columns:
        data[c] = data[c].astype('category')
        encoded_categoric_train_set[c] = data[c].cat.codes
    return encoded_categoric_train_set
encoded_categoric_train_set = encode_labels(trainTest)
newdf_cat = encoded_categoric_train_set[:1460]
test = encoded_categoric_train_set[1460:]

test.shape