image_output_1.png
from warnings import filterwarnings

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

import os
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(style='darkgrid')
from sklearn.linear_model import LinearRegression
from sklearn.svm import SVR
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import LabelEncoder
from xgboost import XGBRegressor
from warnings import filterwarnings
filterwarnings('ignore')

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

X_trainfull = df_train.drop(['SalePrice'], axis=1)
y = df_train.SalePrice

y = np.log1p(y)

d_temp = X_trainfull.isna().sum().sort_values(ascending=False)
d_temp = d_temp[d_temp > 0]
d_temp = d_temp / df_train.shape[0] * 100
plt.xlim(0, 100)

na_index = d_temp[d_temp > 20].index
X_trainfull.drop(na_index, axis=1, inplace=True)

num_cols = X_trainfull.corrwith(y).abs().sort_values(ascending=False).index
X_num = X_trainfull[num_cols]
X_cat = X_trainfull.drop(num_cols, axis=1)

X_num.sample(5)

high_corr_num = X_num.corrwith(y)[X_num.corrwith(y).abs() > 0.5].index
X_num = X_num[high_corr_num]

plt.figure(figsize=(10, 6))
sns.heatmap(X_num.corr(), annot=True, cmap='coolwarm')
plt.show()
print('Correlation of Each feature with target')
X_num.corrwith(y)