Challenge: Model Selection Workflow
Task
Swipe to start coding
You are working with scikit-learn model selection tools to evaluate and compare models in a consistent way.
- Split the dataset
Xandyinto training and test sets usingtrain_test_splitwith:test_size=0.25;random_state=42.
- Create a
LogisticRegressionestimator withmax_iter=1000. - Evaluate the estimator using
cross_val_scorewithcv=3. - Create a
GridSearchCVobject namedgrid_searchwith:- the estimator;
- the parameter grid
param_grid; cv=3.
- Fit
grid_searchon the training data. - Store:
- the mean cross-validation score in
cv_mean_score; - the best parameter dictionary in
best_params.
- the mean cross-validation score in
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 5.26
Challenge: Model Selection Workflow
Swipe to show menu
Task
Swipe to start coding
You are working with scikit-learn model selection tools to evaluate and compare models in a consistent way.
- Split the dataset
Xandyinto training and test sets usingtrain_test_splitwith:test_size=0.25;random_state=42.
- Create a
LogisticRegressionestimator withmax_iter=1000. - Evaluate the estimator using
cross_val_scorewithcv=3. - Create a
GridSearchCVobject namedgrid_searchwith:- the estimator;
- the parameter grid
param_grid; cv=3.
- Fit
grid_searchon the training data. - Store:
- the mean cross-validation score in
cv_mean_score; - the best parameter dictionary in
best_params.
- the mean cross-validation score in
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 4
single