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.
23 changes: 19 additions & 4 deletions q01_missing_value/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# Default imports
import pandas as pd
from sklearn.preprocessing import Imputer
import warnings

# Data loading
ny_housing = pd.read_csv('data/train.csv')
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']]

def imputation(housing_data):

housing_data['MasVnrArea'] = housing_data['MasVnrArea'].fillna(housing_data['MasVnrArea'].mean())
housing_data['GrLivArea'] = housing_data['GrLivArea'].fillna(housing_data['GrLivArea'].mean())
housing_data['SalePrice'] = housing_data['SalePrice'].fillna(housing_data['SalePrice'].mean())

housing_data['LotShape'] = housing_data['LotShape'].fillna(housing_data['LotShape'].mode()[0])
housing_data['GarageType'] = housing_data['GarageType'].fillna(housing_data['GarageType'].mode()[0])

return housing_data[['MasVnrArea', 'GrLivArea', 'SalePrice']], housing_data[['LotShape', 'GarageType']]

imputation(housing_data)





# Write your code here:
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.
15 changes: 13 additions & 2 deletions q02_outlier_removal/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Default imports
import pandas as pd

# Data
ny_housing = pd.read_csv('data/train.csv')
# Selecting 4 most relevant variables from the dataset fot the Cleaning and Preprocessing.
housing_data = ny_housing[['MasVnrArea', 'GrLivArea', 'LotShape', 'GarageType', 'SalePrice']]

def outlier_removal(housing_data):
df = housing_data
qlt = housing_data.quantile(q=0.95)

df = df.drop(df[(df['MasVnrArea']>qlt[0])].index)
df = df.drop(df[(df['GrLivArea']>qlt[1])].index)
df = df.drop(df[(df['SalePrice']>qlt[2])].index)

return df

outlier_removal(housing_data)



# Write your code here:
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.
16 changes: 15 additions & 1 deletion q03_skewness_log/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# %load q03_skewness_log/build.py
from scipy.stats import skew
import pandas as pd
import numpy as np

data = pd.read_csv('data/train.csv')

def skewness_log(data):

df = data.copy()
df['GrLivArea'] = np.log(df['GrLivArea'])
df['SalePrice'] = np.log(df['SalePrice'])

skewed_grLiv = skew(df['GrLivArea'])
skewed_SalePrice = skew(df['SalePrice'])

return skewed_grLiv, skewed_SalePrice

skewness_log(data)



# Write code here:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added q03_skewness_sqrt/__pycache__/build.cpython-36.pyc
Binary file not shown.
14 changes: 13 additions & 1 deletion q03_skewness_sqrt/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# %load q03_skewness_sqrt/build.py
# Default imports
from scipy.stats import skew
import pandas as pd
import numpy as np

ny_housing = pd.read_csv('data/train.csv')

def skewness_sqrt(ny_housing):
df = ny_housing.copy()
df['GrLivArea'] = np.sqrt(df['GrLivArea'])
df['SalePrice'] = np.sqrt(df['SalePrice'])

skewed_grLiv = skew(df['GrLivArea'])
skewed_SalePrice = skew(df['SalePrice'])

return skewed_grLiv, skewed_SalePrice

skewness_sqrt(ny_housing)


# Write your Solution Here:

Binary file not shown.
Binary file not shown.
Binary file added q04_encoding/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added q04_encoding/__pycache__/build.cpython-36.pyc
Binary file not shown.
12 changes: 11 additions & 1 deletion q04_encoding/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# %load q04_encoding/build.py
# Default imports
import pandas as pd
from sklearn.preprocessing import LabelEncoder

ny_housing = pd.read_csv('data/train.csv')
housing_data = ny_housing[['MasVnrArea', 'GrLivArea', 'LotShape', 'GarageType', 'SalePrice']]

def encoding(housing_data):
df = housing_data
label_encoder = LabelEncoder()
df['LotShape_Label'] = label_encoder.fit_transform(df['LotShape'])
df = df.join(pd.get_dummies(df['GarageType'], drop_first=True))

return df

encoding(housing_data)


# Write your code here:

Binary file not shown.
Binary file not shown.