text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

Data_train = pd.read_csv('/kaggle/input/playground-series-s3e1/train.csv')
Data_test = pd.read_csv('/kaggle/input/playground-series-s3e1/test.csv')

Data_train.shape

Data_test.shape

Data_train.columns

Data_test.columns

Data_train.isnull().sum().sum()

Data_test.isnull().sum().sum()

Data_train.corr()

feature_name = list(Data_train.columns[1:-1])

Data_train.drop('id', inplace=True, axis=1)
id = Data_test['id']
Data_test.drop('id', inplace=True, axis=1)

Data_train.skew()

feature_name = ['MedInc', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup', 'MedHouseVal']
for i in range(len(feature_name)):
    q1 = Data_train[feature_name[i]].quantile(0.25)
    q2 = Data_train[feature_name[i]].quantile(0.75)
    Data_train[feature_name[i]] = np.where(Data_train[feature_name[i]] < q1, q1, Data_train[feature_name[i]])
    Data_train[feature_name[i]] = np.where(Data_train[feature_name[i]] > q2, q2, Data_train[feature_name[i]])
Data_train.skew()

Data_test.skew()

feature_name = ['MedInc', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup']
for i in range(len(feature_name)):
    q1 = Data_test[feature_name[i]].quantile(0.25)
    q2 = Data_test[feature_name[i]].quantile(0.75)
    Data_test[feature_name[i]] = np.where(Data_test[feature_name[i]] < q1, q1, Data_test[feature_name[i]])
    Data_test[feature_name[i]] = np.where(Data_test[feature_name[i]] > q2, q2, Data_test[feature_name[i]])
Data_test.skew()