micm_nlp.evals.plot

Confusion-matrix rendering for classification evaluations.

calc_confusion_matrix runs when task.preproc_rules.calc_confusion_matrix is set and writes confusion_matrix.png into the run’s evaluation directory. Axis labels come from ds.label.names, or from integer ids when the true labels are integers.

Functions

calc_confusion_matrix(predictions, true_labels, ...)

Compute a confusion matrix and write it to <eval_path>/confusion_matrix.png.

Module Contents

micm_nlp.evals.plot.calc_confusion_matrix(predictions, true_labels, config, eval_path)

Compute a confusion matrix and write it to <eval_path>/confusion_matrix.png.

Both arrays are flattened first, so this works for per-token and per-example predictions alike. The label axis comes from config.ds.label.names: integer labels are plotted as indices into that list, string labels as the names themselves.

Parameters:
  • predictions – predicted labels.

  • true_labels – gold labels, same shape.

  • config – the run config; ds.label.names supplies the axis.

  • eval_path – directory to write the PNG into.