milia.plot.figures.anomaly#

Anomaly figures: the alpha dial, score strips, voltage bands and trust decay.

Functions

band(draw, trace[, low, high, x, y, group, ...])

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

decay(draw, table[, target, title])

Share still trusted as drift grows.

fprrecall(draw, table[, title])

Realised false-positive rate against recall across alpha.

scores(draw, groups, threshold[, title])

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

setsizes(draw, counts[, title])

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

milia.plot.figures.anomaly.fprrecall(draw, 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.figures.anomaly.scores(draw, 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.figures.anomaly.band(draw, 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:
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.figures.anomaly.decay(draw, 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.figures.anomaly.setsizes(draw, 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'