milia.plot.lets.anomaly#
Anomaly figures drawn with lets-plot (see milia.plot.figures.anomaly).
- milia.plot.lets.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.letsandmilia.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.
- Returns:
The figure – a lets-plot
PlotSpecor a matplotlibFigure, 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.lets.anomaly.decay(table, target=None, title=None)#
Share still trusted as drift grows.
- Parameters:
draw – Drawing backend; bound for you in
milia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.evaluate.anomaly.drift().target (
float|None) – Draw this share as a reference line.
- Returns:
The figure – a lets-plot
PlotSpecor a matplotlibFigure, 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.lets.anomaly.fprrecall(table, title=None)#
Realised false-positive rate against recall across alpha.
The dial a utility sets: fewer false alarms cost recall.
- Parameters:
draw – Drawing backend; bound for you in
milia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.evaluate.anomaly.alphas().
- Returns:
The figure – a lets-plot
PlotSpecor a matplotlibFigure, 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.lets.anomaly.scores(groups, threshold, title=None)#
Scores per set (calibration, normal, stress) against the conformal threshold.
- Parameters:
draw – Drawing backend; bound for you in
milia.plot.letsandmilia.plot.mpl.threshold (
float) – The calibrated threshold.
- Returns:
The figure – a lets-plot
PlotSpecor a matplotlibFigure, 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.lets.anomaly.setsizes(counts, title=None)#
Distribution of conformal prediction-set sizes, optionally for several models.
- Parameters:
draw – Drawing backend; bound for you in
milia.plot.letsandmilia.plot.mpl.counts (
Series|Mapping[str,Series]) – Output ofmilia.cluster.conformal.setsizes(), or name to such counts.
- Returns:
The figure – a lets-plot
PlotSpecor a matplotlibFigure, 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'