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 __init__.pyc
Binary file not shown.
Binary file modified q01_pipeline/__init__.pyc
Binary file not shown.
23 changes: 22 additions & 1 deletion q01_pipeline/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q01_pipeline/build.py
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split, GridSearchCV
Expand All @@ -6,8 +7,28 @@
from sklearn.utils.class_weight import compute_class_weight
from sklearn.metrics import roc_auc_score



bank = pd.read_csv('data/Bank_data_to_class.csv', sep=',')

# Write your solution here :
#Label encode
le = LabelEncoder()
for col in bank.select_dtypes(include=["object"]).columns.values:
bank[col] = le.fit_transform(bank[col])

param_grid = {"n_estimators": [10, 50, 120],
"max_depth": [40, 20, 10],
"max_leaf_nodes": [5, 10, 2]}
X = bank.iloc[:,:-1]
y = bank['y']
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.3, random_state=9)

model = RandomForestClassifier(random_state=9,class_weight='balanced')


def pipeline(X_train,X_test,y_train,y_test,model):

gscv = GridSearchCV(model, param_grid,cv=5)
gscv.fit(X_train,y_train)
y_pred = gscv.predict(X_test)
return gscv, roc_auc_score(y_test,y_pred).item()
Binary file modified q01_pipeline/build.pyc
Binary file not shown.
Binary file modified q01_pipeline/tests/__init__.pyc
Binary file not shown.
Binary file modified q01_pipeline/tests/test_q01_pipeline.pyc
Binary file not shown.