Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Putting It All Together | Modeling
ML Introduction with scikit-learn
course content

Зміст курсу

ML Introduction with scikit-learn

ML Introduction with scikit-learn

1. Machine Learning Concepts
2. Preprocessing Data with Scikit-learn
3. Pipelines
4. Modeling

book
Challenge: Putting It All Together

In this challenge, you will apply everything you learned throughout the course from data preprocessing to training and evaluating the model.

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Завдання
test

Swipe to show code editor

  1. Encode the target.
  2. Split the data so that 33% is used for the test set and the remainder for the training set.
  3. Make a ColumnTransformer to encode only the 'island' and 'sex' columns. Make sure the others columns remain untouched. Use a proper encoder for nominal data.
  4. Fill the gaps in a param_grid to try the following values for the number of neighbors: [1, 3, 5, 7, 9, 12, 15, 20, 25].
  5. Create a GridSearchCV object with the KNeighborsClassifier as a model.
  6. Construct a pipeline that begins with ct as the first step, followed by imputation using the most frequent value, standardization, and concludes with GridSearchCV as the final estimator.
  7. Train the model using a pipeline on the training set.
  8. Evaluate the model on the test set. (Print its score)
  9. Get a predicted target for X_test.
  10. Print the best estimator found by grid_search.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 10
toggle bottom row

book
Challenge: Putting It All Together

In this challenge, you will apply everything you learned throughout the course from data preprocessing to training and evaluating the model.

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Завдання
test

Swipe to show code editor

  1. Encode the target.
  2. Split the data so that 33% is used for the test set and the remainder for the training set.
  3. Make a ColumnTransformer to encode only the 'island' and 'sex' columns. Make sure the others columns remain untouched. Use a proper encoder for nominal data.
  4. Fill the gaps in a param_grid to try the following values for the number of neighbors: [1, 3, 5, 7, 9, 12, 15, 20, 25].
  5. Create a GridSearchCV object with the KNeighborsClassifier as a model.
  6. Construct a pipeline that begins with ct as the first step, followed by imputation using the most frequent value, standardization, and concludes with GridSearchCV as the final estimator.
  7. Train the model using a pipeline on the training set.
  8. Evaluate the model on the test set. (Print its score)
  9. Get a predicted target for X_test.
  10. Print the best estimator found by grid_search.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 10
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt