Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file added q01_missing_value/__pycache__/build.cpython-36.pyc
Binary file not shown.
15 changes: 14 additions & 1 deletion q01_missing_value/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# %load q01_missing_value/build.py
# Default imports
import pandas as pd

from sklearn.preprocessing import Imputer
# Data loading
ny_housing = pd.read_csv('data/train.csv')
# Selecting 4 most relevant variables along with target variable from the dataset fot the Cleaning and Preprocessing.
housing_data = ny_housing[['MasVnrArea', 'GrLivArea', 'LotShape', 'GarageType', 'SalePrice']]


# Write your code here:
def imputation(housing_data):
df = housing_data
imp = Imputer(missing_values=float('NaN'),strategy='mean', axis=0)
df['MasVnrArea'] = imp.fit_transform(df[['MasVnrArea']])
df['GrLivArea'] = imp.fit_transform(df[['GrLivArea']])
df['SalePrice'] = imp.fit_transform(df[['SalePrice']])
df['LotShape'] = df['LotShape'].fillna(df['LotShape'].mode()[0])
df['GarageType'] = df['GarageType'].fillna(df['GarageType'].mode()[0])
return df[['MasVnrArea', 'GrLivArea', 'SalePrice']],df[['LotShape', 'GarageType']]
#imputation(housing_data)


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added q02_outlier_removal/__pycache__/build.cpython-36.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions q02_outlier_removal/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q02_outlier_removal/build.py
# Default imports
import pandas as pd

Expand All @@ -8,3 +9,13 @@


# Write your code here:
def outlier_removal(df):

num_columns =df.select_dtypes(include=['float64','int64'])
quantile_95= num_columns.quantile(0.95)
for colname in num_columns:
quantile = quantile_95[colname]
df=df.drop(df[df[colname]>quantile].index)
return df


Binary file not shown.
Binary file not shown.
Binary file added q03_skewness_log/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added q03_skewness_log/__pycache__/build.cpython-36.pyc
Binary file not shown.
11 changes: 11 additions & 0 deletions q03_skewness_log/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q03_skewness_log/build.py
from scipy.stats import skew
import pandas as pd
import numpy as np
Expand All @@ -6,3 +7,13 @@


# Write code here:
def skewness_log(data):
data['GrLivAreaLT'] = np.log(data['GrLivArea'])
skewed_grLiv = skew(data['GrLivAreaLT'])

data['SalePriceLT'] = np.log(data['SalePrice'])
skewed_SaleP = skew(data['SalePriceLT'])

return skewed_grLiv, skewed_SaleP


Binary file not shown.
Binary file not shown.