-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c546b2
commit da9f0dd
Showing
6 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,43 @@ | ||
# TODO | ||
def hyper_parameter_tuning(model): | ||
return None | ||
from sklearn import preprocessing | ||
from sklearn.ensemble import RandomForestRegressor | ||
from sklearn.linear_model import Ridge | ||
from sklearn.model_selection import GridSearchCV | ||
from sklearn.pipeline import Pipeline | ||
from xgboost import XGBRegressor | ||
|
||
|
||
def hyper_parameter_tuning(my_pipeline,models,X_train,y_train): | ||
grid_param = [ | ||
[{"model": [Ridge()], | ||
"model__alpha": [0.5, 1, 2], | ||
# Add other parameters here | ||
}], | ||
[{"model": [XGBRegressor(objective ='reg:squarederror')], | ||
"model__n_estimators": [100, 200], | ||
# Add other parameters here | ||
}], | ||
[{"model": [RandomForestRegressor(random_state=0)], | ||
"model__n_estimators": [100, 200], | ||
# Add other parameters here | ||
}] | ||
] | ||
|
||
for i in range(len(models)): | ||
# Bundle preprocessing and modeling code in a pipeline | ||
my_pipeline = Pipeline(steps=[('preprocessor', preprocessing), | ||
('model', models[i][1]) | ||
]) | ||
|
||
gd_sr = GridSearchCV(estimator=my_pipeline, | ||
param_grid=grid_param[i], | ||
scoring='accuracy', | ||
cv=5, | ||
n_jobs=-1) | ||
|
||
gd_sr.fit(X_train, y_train) | ||
|
||
best_parameters = gd_sr.best_params_ | ||
best_result = gd_sr.best_score_ | ||
|
||
#console.print(f"Model: {models[i][0]}, Best Parameters: {best_parameters}, Best Score: {best_result}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#TODO |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.