Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Creating a Complete ML Pipeline | Section
Machine Learning Foundations with Scikit-Learn
Osio 1. Luku 22
single

single

bookChallenge: Creating a Complete ML Pipeline

Pyyhkäise näyttääksesi valikon

Now create a pipeline that includes a final estimator. This produces a trained prediction pipeline that can generate predictions for new instances using the .predict() method.

Since a predictor requires the target variable y, encode it separately from the pipeline built for X. Use LabelEncoder to encode the target.

Additionally, there are materials to review the syntax of make_column_transformer and make_pipeline.

Note
Note

Since the predictions are encoded as 0, 1, or 2, the .inverse_transform() method of LabelEncoder can be used to convert them back to the original labels: 'Adelie', 'Chinstrap', or 'Gentoo'.

Tehtävä

Pyyhkäise aloittaaksesi koodauksen

You have a penguin DataFrame df. Build and train a full ML pipeline using KNeighborsClassifier.

  1. Encode the target y with LabelEncoder.
  2. Create a ColumnTransformer (ct) that applies OneHotEncoder to 'island' and 'sex', with remainder='passthrough'.
  3. Build a pipeline with: • ctSimpleImputer(strategy='most_frequent')StandardScalerKNeighborsClassifier
  4. Fit the pipeline on X and y.
  5. Predict on X and print the first decoded class names.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 22
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt