sage.plotting.gradient_uncertainty

Filename : gradient_uncertainty.py Description : Short description of the file

Created on 2026-03-21 17:56:36

__author__ = Narenraju Nagarajan __copyright__ = Copyright 2026, ProjectName __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]

GitHub Repository: NULL

Documentation: NULL

Functions

plot_uncertainty_vs_gradient(model, source_params, ...)

Scatter plot of model uncertainty vs finite-difference output gradient.

Module Contents

plot_uncertainty_vs_gradient(model, source_params, labels, param_name, export_dir=None, save=True, delta_frac=0.01, epoch=None)[source]

Scatter plot of model uncertainty vs finite-difference output gradient.

Perturbs param_name by delta_frac × value and computes the numerical gradient of the ranking statistic. Plots this against the heteroscedastic uncertainty predicted by the model for signal events. Ideally, high gradient should co-occur with high uncertainty.

Parameters:
  • model (object with predict method) – Model that returns (ranking_stat, uncertainty) when called with return_uncertainty=True.

  • source_params (dict[str, array-like]) – Per-event parameter arrays.

  • labels (array-like, shape (N,)) – Binary ground-truth labels.

  • param_name (str) – Key of the parameter to perturb.

  • export_dir (str or None) – Output directory.

  • save (bool) – If True, save to disk; otherwise display.

  • delta_frac (float) – Fractional perturbation size for the gradient estimate (default 0.01).

  • epoch (int or str or None) – Epoch identifier for the filename.