Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Evaluating the Model with Cross-Validation | Section
Machine Learning Foundations with Scikit-Learn
Seção 1. Capítulo 27
single

single

bookChallenge: Evaluating the Model with Cross-Validation

Deslize para mostrar o 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() from sklearn.model_selection;
  • train_test_split() from sklearn.model_selection;
  • .fit() and .score() methods of the model.
Tarefa

Deslize para começar a programar

You are given a preprocessed version of the penguin dataset, where the feature matrix X and the target variable y are ready for modeling. Your goal is to train and evaluate a KNeighborsClassifier model using both cross-validation and a train-test split.

  1. Initialize a KNeighborsClassifier object with n_neighbors=4.
  2. Use the cross_val_score() function with cv=3 to calculate cross-validation scores for the model.
  3. Split the data into training and test sets using the train_test_split() function.
  4. Fit the model on the training set using the .fit() method.
  5. Evaluate the model on the test set using the .score() method and print the result.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 27
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

some-alt