src.superphot_plus.plotting.confusion_matrices

This module provides various functions for analyzing and visualizing light curve data.

Module Contents

Functions

plot_high_confidence_confusion_matrix(probs_csv, filename)

Plot confusion matrices for high-confidence predictions.

plot_binary_confusion_matrix(probs_csv, filename[, cutoff])

Merge all non-Ia into one core collapse class and plot resulting

compare_four_class_confusion_matrices(probs_csv, ...)

Plots ALeRCE's classifications as confusion matrix, and compare

plot_true_agreement_matrix(probs_csv, ...[, spec])

Plot agreement matrix between ALeRCE and Superphot+

plot_expected_agreement_matrix(probs_csv, ...[, cmap])

Plot expected agreement matrix based on independent ALeRCE and

plot_agreement_matrix_from_arrs(our_labels, ...[, ...])

Helper function to plot agreement matrices.

plot_confusion_matrix(y_true, y_pred, filename[, ...])

Plot the confusion matrix between given true and predicted

plot_matrices(config, true_classes, pred_classes, ...)

Plots confusion matrices for test set metrics.

plot_high_confidence_confusion_matrix(probs_csv, filename, cutoff=0.7, num_include=None)[source]

Plot confusion matrices for high-confidence predictions.

Parameters:
  • probs_csv (str) – Path to the CSV file containing probability predictions.

  • filename (str) – Base filename for saving the confusion matrix plots.

  • cutoff (float, optional) – Probability cutoff value for high-confidence predictions. Default is 0.7.

plot_binary_confusion_matrix(probs_csv, filename, cutoff=0.5)[source]

Merge all non-Ia into one core collapse class and plot resulting binary confusion matrix.

Parameters:
  • probs_csv (str) – Path to the CSV file containing probability predictions.

  • filename (str) – Base filename for saving the confusion matrix plots.

compare_four_class_confusion_matrices(probs_csv, probs_alerce_csv, save_dir, p07=False)[source]

Plots ALeRCE’s classifications as confusion matrix, and compare to condensed four-class CM of Superphot+.

Only four classes as SNe IIn is not a label in their transient classifier.

Parameters:
  • probs_csv (str) – Path to the CSV file containing Superphot+ probability predictions.

  • probs_alerce_csv (str) – Path to the CSV file containing ALeRCE predicted classes.

  • save_dir (str) – Directory for saving the confusion matrix plots.

  • p07 (bool, optional) – If True, only include predictions with a probability >= 0.7. Default is False.

plot_true_agreement_matrix(probs_csv, probs_alerce_csv, save_dir, spec=True)[source]

Plot agreement matrix between ALeRCE and Superphot+ classifications.

Parameters:
  • probs_csv (str) – Path to the CSV file containing probability predictions.

  • probs_alerce_csv (str) – Path to the CSV containing ALeRCE predictions.

  • save_dir (str) – Directory path for saving the agreement matrix plot.

plot_expected_agreement_matrix(probs_csv, probs_alerce_csv, save_dir, cmap='custom_cmap2')[source]

Plot expected agreement matrix based on independent ALeRCE and Superphot+ confusion matrices.

Parameters:
  • probs_csv (str) – Path to the CSV file containing probability predictions.

  • save_dir (str) – Directory for saving the expected agreement matrix plot.

  • cmap (matplotlib.colors.Colormap, optional) – Color map for the plot. Default is plt.cm.Purples.

plot_agreement_matrix_from_arrs(our_labels, alerce_labels, folds, save_dir, spec=True, cmap='custom_cmap2')[source]

Helper function to plot agreement matrices.

Plot agreement matrix based on input arrays of ALeRCE and Superphot+ classifications.

Parameters:
  • our_labels (list) – List of our predicted labels.

  • alerce_labels (list) – List of ALeRCE predicted labels.

  • filename (str) – Base filename for saving the agreement matrix plot.

  • cmap (matplotlib.colors.Colormap, optional) – Color map for the plot. Default is plt.cm.Purples.

plot_confusion_matrix(y_true, y_pred, filename, folds=None, purity=False, cmap='custom_cmap1')[source]

Plot the confusion matrix between given true and predicted labels.

Parameters:
  • y_true (array-like) – True labels.

  • y_pred (array-like) – Predicted labels.

  • filename (str) – Base filename for saving the confusion matrix plot.

  • purity (bool, optional) – If True, plot the purity confusion matrix. Default is False.

  • cmap (matplotlib.colors.Colormap, optional) – Color map for the plot. Default is plt.cm.Purples.

plot_matrices(config, true_classes, pred_classes, prob_above_07)[source]

Plots confusion matrices for test set metrics.

Parameters:
  • config (ModelConfig) – The configuration of the model used for evaluation.

  • true_classes (np.ndarray) – The ground truth for the test ZTF objects.

  • pred_classes (np.ndarray) – The predicted classes for the test ZTF objects.

  • prob_above_07 (np.ndarray) – Indicates which predictions had a 70% confidence.

  • cm_folder (str) – The folder where the plot figures will be stored.