single
Challenge: Creating a Complete ML Pipeline
メニューを表示するにはスワイプしてください
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.
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'.
スワイプしてコーディングを開始
You have a penguin DataFrame df. Build and train a full ML pipeline using KNeighborsClassifier.
- Encode the target
ywithLabelEncoder. - Create a
ColumnTransformer(ct) that appliesOneHotEncoderto'island'and'sex', withremainder='passthrough'. - Build a pipeline with:
ctSimpleImputer(strategy='most_frequent')StandardScalerKNeighborsClassifier
- Fit the pipeline on
Xandy. - Predict on
Xand print the first decoded class names.
解答
フィードバックありがとうございます!
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください