Confusion Matrix
confusion_matrixCompute a confusion matrix from a trained model or your true and predicted labels, with optional normalization and the most confused class pair for error analysis.
Instructions
Confusion matrix as numbers (rows = true class, columns = predicted class), plus the most confused class pair and, for two classes, TN / FP / FN / TP. For a picture use confusion_matrix_plot. Use EITHER a trained classification model (model_id) OR your own lists of true and predicted labels. Args: model_id (str, optional): ID of a trained classification model. dataset (str): "test" or "train". Only used with model_id. Default is "test". normalize (str, optional): None for counts, "true" (each row sums to 1: recall per class), "pred" (each column sums to 1: precision per class) or "all" (whole matrix sums to 1). y_true (list, optional): True labels (use together with y_pred). y_pred (list, optional): Predicted labels, same length as y_true. Returns: dict: labels, matrix, most_confused and (binary) the TN/FP/FN/TP breakdown.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "confusion_matrix"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y_pred | No | ||
| y_true | No | ||
| dataset | No | test | |
| model_id | No | ||
| normalize | No |