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 modified __pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/__pycache__/build.cpython-36.pyc
Binary file not shown.
13 changes: 11 additions & 2 deletions q01_load_data/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# %load q01_load_data/build.py
# Default imports
import pandas as pd
from sklearn.model_selection import train_test_split


path = 'data/house_prices_multivariate.csv'
# Write your solution here
def load_data(path, test_s=0.33, Random_state = 9):
df = pd.read_csv(path)
X = df.iloc[:,:-1]
y = df.iloc[:,-1]
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = test_s, random_state= Random_state)
return df, X_train, X_test, y_train, y_test





# Write your solution here

Binary file modified q01_load_data/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/tests/__pycache__/test_q01_load_data.cpython-36.pyc
Binary file not shown.
Binary file modified q02_Max_important_feature/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_Max_important_feature/__pycache__/build.cpython-36.pyc
Binary file not shown.
14 changes: 14 additions & 0 deletions q02_Max_important_feature/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# %load q02_Max_important_feature/build.py
# Default imports
import pandas as pd
from sklearn.model_selection import train_test_split
from greyatomlib.advanced_linear_regression.q01_load_data.build import load_data

# We have already loaded the data for you
data_set, X_train, X_test, y_train, y_test = load_data('data/house_prices_multivariate.csv')


# Write your code here
def Max_important_feature(path, test_s=0.33, Random_state = 4):
df = pd.read_csv(path)
X = df.iloc[:,:-1]
y = df.iloc[:,-1]
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size = test_s, random_state= Random_state)
return df, X_train, X_test, y_train, y_test





Binary file not shown.
Binary file not shown.
Binary file modified q03_polynomial/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_polynomial/__pycache__/build.cpython-36.pyc
Binary file not shown.
20 changes: 20 additions & 0 deletions q03_polynomial/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
# %load q03_polynomial/build.py
# Default imports
from greyatomlib.advanced_linear_regression.q01_load_data.build import load_data
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LinearRegression
import numpy as np
from sklearn.model_selection import train_test_split

# We have already loaded the data for you
data_set, X_train, X_test, y_train, y_test = load_data('data/house_prices_multivariate.csv')


# Write your solution here
def polynomial(power=5,Random_state=9):
linear_pipe = make_pipeline(PolynomialFeatures(degree=power,include_bias=False), LinearRegression())

cols = data_set.corr()['SalePrice'].drop('SalePrice').sort_values(ascending = False)[0:4].index
X = data_set[cols]
# print(X.shape)
y = data_set['SalePrice']
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=9, test_size = 0.33)

linear_pipe.fit(X_train,y_train)
print(linear_pipe.predict(np.array([4, 5, 6, 7]).reshape(1,-1)))
return linear_pipe


polynomial(power=5,Random_state=9)


Binary file modified q03_polynomial/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file not shown.