diff --git a/__pycache__/__init__.cpython-36.pyc b/__pycache__/__init__.cpython-36.pyc index 494c0e4..c47dbb0 100644 Binary files a/__pycache__/__init__.cpython-36.pyc and b/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_grid_search/__pycache__/__init__.cpython-36.pyc b/q01_grid_search/__pycache__/__init__.cpython-36.pyc index eed5319..0286cf5 100644 Binary files a/q01_grid_search/__pycache__/__init__.cpython-36.pyc and b/q01_grid_search/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_grid_search/__pycache__/build.cpython-36.pyc b/q01_grid_search/__pycache__/build.cpython-36.pyc index cac4a0b..c62156e 100644 Binary files a/q01_grid_search/__pycache__/build.cpython-36.pyc and b/q01_grid_search/__pycache__/build.cpython-36.pyc differ diff --git a/q01_grid_search/build.py b/q01_grid_search/build.py index 20c99a1..bb261cb 100644 --- a/q01_grid_search/build.py +++ b/q01_grid_search/build.py @@ -3,6 +3,7 @@ import warnings warnings.filterwarnings("ignore") import pandas as pd +import numpy as np from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import GridSearchCV @@ -19,4 +20,12 @@ # Write your solution here : +model = RandomForestClassifier(random_state=9, oob_score=True) +def grid_search(X_train, y_train, model, param_grid, cv=3): + search = GridSearchCV(estimator=model, param_grid=param_grid, cv=cv) + search.fit(X_train, y_train) + variable1 = list(search.cv_results_['params']) + variable2 = np.array(search.cv_results_['mean_test_score']) + return search, variable1, variable2 +grid_search(X_train, y_train, model, param_grid) diff --git a/q01_grid_search/tests/__pycache__/__init__.cpython-36.pyc b/q01_grid_search/tests/__pycache__/__init__.cpython-36.pyc index 31ac328..2d536eb 100644 Binary files a/q01_grid_search/tests/__pycache__/__init__.cpython-36.pyc and b/q01_grid_search/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q01_grid_search/tests/__pycache__/test_q01_grid_search.cpython-36.pyc b/q01_grid_search/tests/__pycache__/test_q01_grid_search.cpython-36.pyc index bf1afbe..5a3a7c4 100644 Binary files a/q01_grid_search/tests/__pycache__/test_q01_grid_search.cpython-36.pyc and b/q01_grid_search/tests/__pycache__/test_q01_grid_search.cpython-36.pyc differ diff --git a/q02_fit/__pycache__/__init__.cpython-36.pyc b/q02_fit/__pycache__/__init__.cpython-36.pyc index 97c33cb..f73484a 100644 Binary files a/q02_fit/__pycache__/__init__.cpython-36.pyc and b/q02_fit/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_fit/__pycache__/build.cpython-36.pyc b/q02_fit/__pycache__/build.cpython-36.pyc index 3d41a62..0d61004 100644 Binary files a/q02_fit/__pycache__/build.cpython-36.pyc and b/q02_fit/__pycache__/build.cpython-36.pyc differ diff --git a/q02_fit/build.py b/q02_fit/build.py index fbafb1a..c790292 100644 --- a/q02_fit/build.py +++ b/q02_fit/build.py @@ -22,6 +22,11 @@ # Write your solution here : - - - +def fit(X_test, y_test): + y_pred = grid.predict(X_test) + variable1 = confusion_matrix(y_test, y_pred) + variable2 = classification_report(y_test, y_pred) + variable3 = accuracy_score(y_test, y_pred) + return variable1, variable2, variable3 + +print(fit(X_test, y_test)) diff --git a/q02_fit/tests/__pycache__/__init__.cpython-36.pyc b/q02_fit/tests/__pycache__/__init__.cpython-36.pyc index 4a01850..29f504a 100644 Binary files a/q02_fit/tests/__pycache__/__init__.cpython-36.pyc and b/q02_fit/tests/__pycache__/__init__.cpython-36.pyc differ diff --git a/q02_fit/tests/__pycache__/test_q02_fit.cpython-36.pyc b/q02_fit/tests/__pycache__/test_q02_fit.cpython-36.pyc index 413b2fc..7e4e526 100644 Binary files a/q02_fit/tests/__pycache__/test_q02_fit.cpython-36.pyc and b/q02_fit/tests/__pycache__/test_q02_fit.cpython-36.pyc differ