NLL Poisson Scorer

Poisson distribution negative log-likelihood Scorer.

The anomaly score is the negative log likelihood of the actual series values under a Poisson distribution estimated from the stochastic prediction.

class darts.ad.scorers.nll_poisson_scorer.PoissonNLLScorer(window=1)[source]

Bases: NLLScorer

Attributes

is_probabilistic

Whether the scorer expects a probabilistic prediction for its first input.

Methods

eval_accuracy_from_prediction(...[, metric])

Computes the anomaly score between actual_series and pred_series, and returns the score of an agnostic threshold metric.

score_from_prediction(actual_series, pred_series)

Computes the anomaly score on the two (sequence of) series.

show_anomalies_from_prediction(...[, ...])

Plot the results of the scorer.

eval_accuracy_from_prediction(actual_anomalies, actual_series, pred_series, metric='AUC_ROC')

Computes the anomaly score between actual_series and pred_series, and returns the score of an agnostic threshold metric.

Parameters
  • actual_anomalies (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) ground truth of the anomalies (1 if it is an anomaly and 0 if not)

  • actual_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) actual series.

  • pred_series (Union[TimeSeries, Sequence[TimeSeries]]) – The (sequence of) predicted series.

  • metric (str) – Optionally, metric function to use. Must be one of “AUC_ROC” and “AUC_PR”. Default: “AUC_ROC”

Returns

Score of an agnostic threshold metric for the computed anomaly score
  • float if actual_series and actual_series are univariate series (dimension=1).

  • Sequence[float]

    • if actual_series and actual_series are multivariate series (dimension>1),

    returns one value per dimension, or * if actual_series and actual_series are sequences of univariate series, returns one value per series

  • Sequence[Sequence[float]]] if actual_series and actual_series are sequences

of multivariate series. Outer Sequence is over the sequence input and the inner Sequence is over the dimensions of each element in the sequence input.

Return type

Union[float, Sequence[float], Sequence[Sequence[float]]]

property is_probabilistic: bool

Whether the scorer expects a probabilistic prediction for its first input.

Return type

bool

score_from_prediction(actual_series, pred_series)

Computes the anomaly score on the two (sequence of) series.

If a pair of sequences is given, they must contain the same number of series. The scorer will score each pair of series independently and return an anomaly score for each pair.

Parameters
Returns

(Sequence of) anomaly score time series

Return type

Union[TimeSeries, Sequence[TimeSeries]]

show_anomalies_from_prediction(actual_series, pred_series, scorer_name=None, actual_anomalies=None, title=None, metric=None)

Plot the results of the scorer.

Computes the anomaly score on the two series. And plots the results.

The plot will be composed of the following:
  • the actual_series and the pred_series.

  • the anomaly score of the scorer.

  • the actual anomalies, if given.

It is possible to:
  • add a title to the figure with the parameter title

  • give personalized name to the scorer with scorer_name

  • show the results of a metric for the anomaly score (AUC_ROC or AUC_PR), if the actual anomalies is provided.

Parameters
  • actual_series (TimeSeries) – The actual series to visualize anomalies from.

  • pred_series (TimeSeries) – The predicted series of actual_series.

  • actual_anomalies (Optional[TimeSeries]) – The ground truth of the anomalies (1 if it is an anomaly and 0 if not)

  • scorer_name (Optional[str]) – Name of the scorer.

  • title (Optional[str]) – Title of the figure

  • metric (Optional[str]) – Optionally, Scoring function to use. Must be one of “AUC_ROC” and “AUC_PR”. Default: “AUC_ROC”