milia.plot.mpl.anomaly#

Anomaly figures drawn with matplotlib (see milia.plot.figures.anomaly).

milia.plot.mpl.anomaly.band(trace, low=0.94, high=1.1, x='step', y='vmag_pu', group='load_name', title=None)#

Per-entity traces against a compliance band, entities leaving it highlighted.

Parameters:
  • draw – Drawing backend; bound for you in milia.plot.lets and milia.plot.mpl.

  • trace (DataFrame) – Long frame with one row per entity and step.

  • low (float) – Lower bound of the band.

  • high (float) – Upper bound of the band.

  • x (str) – Step column.

  • y (str) – Value column.

  • group (str) – Entity column.

  • title (str | None) – Figure title.

Returns:

The figure – a lets-plot PlotSpec or a matplotlib Figure, depending on the backend.

Examples

>>> import numpy as np, pandas as pd
>>> from milia.plot.mpl import anomaly
>>> trace = pd.DataFrame({"step": [0, 1, 0, 1], "vmag_pu": [1.0, 1.0, 1.0, 1.12], "load_name": list("aabb")})
>>> type(anomaly.band(trace)).__name__
'Figure'
milia.plot.mpl.anomaly.decay(table, target=None, title=None)#

Share still trusted as drift grows.

Parameters:
Returns:

The figure – a lets-plot PlotSpec or a matplotlib Figure, depending on the backend.

Examples

>>> import numpy as np, pandas as pd
>>> from milia.plot.mpl import anomaly
>>> type(anomaly.decay(pd.DataFrame({"level": [0, 50], "within": [0.9, 0.6]}), target=0.9)).__name__
'Figure'
milia.plot.mpl.anomaly.fprrecall(table, title=None)#

Realised false-positive rate against recall across alpha.

The dial a utility sets: fewer false alarms cost recall.

Parameters:
Returns:

The figure – a lets-plot PlotSpec or a matplotlib Figure, depending on the backend.

Examples

>>> import numpy as np, pandas as pd
>>> from milia.plot.mpl import anomaly
>>> table = pd.DataFrame({"alpha": [0.2, 0.1], "fpr": [0.2, 0.1], "recall": [0.9, 0.8]})
>>> type(anomaly.fprrecall(table)).__name__
'Figure'
milia.plot.mpl.anomaly.scores(groups, threshold, title=None)#

Scores per set (calibration, normal, stress) against the conformal threshold.

Parameters:
Returns:

The figure – a lets-plot PlotSpec or a matplotlib Figure, depending on the backend.

Examples

>>> import numpy as np, pandas as pd
>>> from milia.plot.mpl import anomaly
>>> type(anomaly.scores({"cal": [0.1, 0.2], "stress": [0.9]}, 0.5)).__name__
'Figure'
milia.plot.mpl.anomaly.setsizes(counts, title=None)#

Distribution of conformal prediction-set sizes, optionally for several models.

Parameters:
Returns:

The figure – a lets-plot PlotSpec or a matplotlib Figure, depending on the backend.

Examples

>>> import numpy as np, pandas as pd
>>> from milia.plot.mpl import anomaly
>>> type(anomaly.setsizes(pd.Series([5, 3], index=[1, 2]))).__name__
'Figure'