text_plain_output_1.png
import numpy as np

import pandas as pd

train = pd.read_csv('../input/30-days-of-ml/train.csv')
test = pd.read_csv('../input/30-days-of-ml/test.csv')
sample_submission = pd.read_csv('../input/30-days-of-ml/sample_submission.csv')

train.dtypes

cat_cols = [col for col in train.columns if train[col].dtype == 'object']
cat_cols

cont_cols = [col for col in train.columns if train[col].dtype != 'object' and col not in ('id', 'target')]
cont_cols

mean = train['target'].mean()
std = train['target'].std()
cut_off = std * 3
lower, upper = (mean - cut_off, mean + cut_off)
outliers = train[(train['target'] > upper) | (train['target'] < lower)]
train.drop(outliers.index.to_list(), inplace=True)
train.shape

q25, q75 = (np.percentile(train['target'], 25), np.percentile(train['target'], 75))
iqr = q75 - q25
cut_off = iqr * 1.5
lower, upper = (q25 - cut_off, q75 + cut_off)
cut_off = iqr * 1.5
lower, upper = (q25 - cut_off, q75 + cut_off)
outliers = train[(train['target'] > upper) | (train['target'] < lower)]
train.drop(outliers.index.to_list(), inplace=True)
train.shape

train.isna().sum()[train.isna().sum() > 0]