IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Supervised Learning with scikit-learn

Visualizza il corso

Istruzioni dell'esercizio

  • 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.

Esercizio pratico interattivo

Prova questo esercizio completando il codice di esempio.

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(____(____, ____))
Modifica ed esegui il codice