Aan de slagGa gratis aan de slag

Performance on multi-class classification

In this exercise, you will compute the performance metrics for models using the module sklearn.metrics.

The model is already trained and stored in the variable model. Also, the variables X_test and y_true are also loaded, together with the functions confusion_matrix() and classification_report() from sklearn.metrics package.

You will first compute the confusion matrix of the model. Then, to summarize a model's performance, you will compute the precision, recall and F1-score using the classification_report() function. In this function, you can optionally pass a list containing the classes names (they are stored it in the news_cat variable) to the parameter target_names to make the report more readable.

Deze oefening maakt deel uit van de cursus

Recurrent Neural Networks (RNNs) for Language Modeling with Keras

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Use the model to predict on new data
____ = model.____(X_test)

# Choose the class with higher probability 
y_pred = np.____(predicted, axis=1)
Code bewerken en uitvoeren