Get startedGet started for free

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.

This exercise is part of the course

Recurrent Neural Networks (RNNs) for Language Modeling with Keras

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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

# Choose the class with higher probability 
y_pred = np.____(predicted, axis=1)
Edit and Run Code