Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Putting It All Together | Section
Machine Learning Foundations with Scikit-Learn
Seksjon 1. Kapittel 32
single

single

bookChallenge: Putting It All Together

Sveip for å vise menyen

In this challenge, apply the full workflow learned in the course — from data preprocessing through training to model evaluation.

Oppgave

Sveip for å begynne å kode

You are working with a penguin dataset. Build an ML pipeline to classify species with KNN, handling encoding, missing values, scaling, and tuning.

  1. Encode y with LabelEncoder.
  2. Split with train_test_split(test_size=0.33).
  3. Make ct: OneHotEncoder on 'island', 'sex', remainder='passthrough'.
  4. Set param_grid for n_neighbors, weights, p. For n_neighbors better to use odd values of integers.
  5. Create GridSearchCV(KNeighborsClassifier(), param_grid).
  6. Pipeline: ctSimpleImputer('most_frequent')StandardScalerGridSearchCV.
  7. Fit on train.
  8. Print test .score.
  9. Predict, print first 5 decoded labels.
  10. Print .best_estimator_.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 32
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt