Challenge: Evaluating the Model with Cross-Validation
In this challenge, build and evaluate a model using both the train-test split and cross-validation on the preprocessed penguins dataset.
The following functions will be useful:
cross_val_score()
fromsklearn.model_selection
;train_test_split()
fromsklearn.model_selection
;.fit()
and.score()
methods of the model.
Task
Swipe to start coding
- Initialize a
KNeighborsClassifier
with 4 neighbors. - Use
cross_val_score()
with 3 folds to calculate cross-validation scores (the model can be passed untrained). - Split the data into training and test sets with
train_test_split()
. - Train the model on the training set.
- Evaluate the model on the test set with
.score()
.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 4. ChapterΒ 5
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
What is the difference between train-test split and cross-validation?
Can you explain how to use cross_val_score() with the penguins dataset?
How do I choose which evaluation method to use?
Awesome!
Completion rate improved to 3.13
Challenge: Evaluating the Model with Cross-Validation
Swipe to show menu
In this challenge, build and evaluate a model using both the train-test split and cross-validation on the preprocessed penguins dataset.
The following functions will be useful:
cross_val_score()
fromsklearn.model_selection
;train_test_split()
fromsklearn.model_selection
;.fit()
and.score()
methods of the model.
Task
Swipe to start coding
- Initialize a
KNeighborsClassifier
with 4 neighbors. - Use
cross_val_score()
with 3 folds to calculate cross-validation scores (the model can be passed untrained). - Split the data into training and test sets with
train_test_split()
. - Train the model on the training set.
- Evaluate the model on the test set with
.score()
.
Solution
Everything was clear?
Thanks for your feedback!
Awesome!
Completion rate improved to 3.13SectionΒ 4. ChapterΒ 5
single