BaşlayınÜcretsiz Başlayın

Pipeline for song genre prediction: II

Having set up the steps of the pipeline in the previous exercise, you will now use it on the music_df dataset to classify the genre of songs. What makes pipelines so incredibly useful is the simple interface that they provide.

X_train, X_test, y_train, and y_test have been preloaded for you, and confusion_matrix has been imported from sklearn.metrics.

Bu egzersiz

Supervised Learning with scikit-learn

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create a pipeline using the steps you previously defined.
  • Fit the pipeline to the training data.
  • Make predictions on the test set.
  • Calculate and print the confusion matrix.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

steps = [("imputer", imp_mean),
        ("knn", knn)]

# Create the pipeline
pipeline = ____(____)

# Fit the pipeline to the training data
____

# Make predictions on the test set
y_pred = ____

# Print the confusion matrix
print(____(____, ____))
Kodu Düzenle ve Çalıştır