classifier_results

This module provides various functions for analyzing and visualizing classification results.

Module Contents

Functions

save_class_fractions(spec_probs_csv, probs_alerce_csv, ...)

Save class fractions from spectroscopic, photometric, and

plot_class_fractions(saved_cf_file, fig_dir, filename)

Plot class fractions saved from 'save_class_fractions'.

generate_roc_curve(probs_csv, save_dir)

Generate a combined ROC curve of all SN classes.

plot_phase_vs_accuracy(phased_probs_csv, save_dir)

Plot classification accuracy as a function of phase.

plot_redshifts_abs_mags(probs_snr_csv, training_csv, ...)

Plot redshift and absolute magnitude distributions used in the

plot_snr_npoints_vs_accuracy(probs_snr_csv, save_dir)

Generate plots of number of SNR > 5 points versus

plot_snr_hist(probs_snr_csv, save_dir)

Replicates SNR plots needed for publication.

compare_mag_distributions(probs_classified, ...[, ...])

Generate overlaid magnitude distributions of the classified and unclassified datasets.

plot_chisquared_vs_accuracy(pred_spec_fn, ...[, sampler])

Plot chi-squared value histograms for both the spectroscopic and photometric

plot_model_metrics(metrics, num_epochs, plot_name, ...)

Plots training and validation results and exports them to files.

save_class_fractions(spec_probs_csv, probs_alerce_csv, phot_probs_csv, save_path)[source]

Save class fractions from spectroscopic, photometric, and corrected photometric.

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

  • phot_probs_csv (str) – Path to the CSV file containing photometric probability predictions.

  • save_fn (str) – Filename + dir for saving the class fractions.

plot_class_fractions(saved_cf_file, fig_dir, filename)[source]

Plot class fractions saved from ‘save_class_fractions’.

Parameters:
  • saved_cf_file (str) – Path to the saved class fractions file.

  • fig_dir (str) – Directory for saving the class fractions plot.

  • filename (str) – Filename for the class fractions plot figure.

generate_roc_curve(probs_csv, save_dir)[source]

Generate a combined ROC curve of all SN classes.

Parameters:
  • probs_csv (str) – CSV file where class probabilities are stored.

  • save_dir (str) – Where to save the figure.

plot_phase_vs_accuracy(phased_probs_csv, save_dir)[source]

Plot classification accuracy as a function of phase.

Parameters:
  • phased_probs_csv (str) – Where classification probabilities and LC truncated phases are saved.

  • save_dir (str) – Where to save the output figures.

plot_redshifts_abs_mags(probs_snr_csv, training_csv, fits_dir, save_dir, sampler='dynesty')[source]

Plot redshift and absolute magnitude distributions used in the redshift-inclusive classifier.

Parameters:
  • probs_snr_csv (str) – Where probabilities + SNRs are stored.

  • save_dir (str) – Where to save figures.

plot_snr_npoints_vs_accuracy(probs_snr_csv, save_dir)[source]

Generate plots of number of SNR > 5 points versus accuracy, and top 10% SNR versus accuracy.

TODO: add functionality for only one type.

Parameters:
  • probs_snr_csv (str) – Where probabilities + SNRs are stored.

  • save_dir (str) – Where to save figures.

plot_snr_hist(probs_snr_csv, save_dir)[source]

Replicates SNR plots needed for publication.

Parameters:
  • probs_snr_csv (str) – Where probability + SNR info is stored.

  • save_dir (str) – Where to save figure.

compare_mag_distributions(probs_classified, probs_unclassified, save_dir, zeropoint=26.3)[source]

Generate overlaid magnitude distributions of the classified and unclassified datasets. Assumes that unclassified LCs that did not pass the chi-squared cut are marked as “SKIP”.

Parameters:
  • probs_classified (str) – CSV filename where probs of spectroscopic set are stored.

  • probs_unclassified (str) – CSV filename where probs of photometric set are stored.

  • save_dir (str) – Where to save figure.

  • zeropoint (float, optional) – Zeropoint used when converting mags to fluxes. Defaults to 26.3.

plot_chisquared_vs_accuracy(pred_spec_fn, pred_phot_fn, fits_dir, save_dir, sampler=None)[source]

Plot chi-squared value histograms for both the spectroscopic and photometric datasets, and plot spec chi-squared as a function of classification accuracy.

TODO: IN PROGRESS

Parameters:
  • pred_spec_fn (str) – CSV filename where probs of spectroscopic set are stored.

  • pred_phot_fn (str) – CSV filename where probs of photometric set are stored.

  • save_dir (str) – Where to save figure.

plot_model_metrics(metrics, num_epochs, plot_name, metrics_dir)[source]

Plots training and validation results and exports them to files.

Parameters:
  • metrics (tuple) – Train and validation accuracies and losses.

  • num_epochs (int) – The total number of epochs.

  • plot_name (str) – The name for the plot figure files.

  • metrics_dir (str) – Where to store the plot figures.