milia.plot.figures.recommend#
Recommendation figures: trust histograms, rank intervals, top-N bars and benchmarks.
Functions
|
Rank with its bootstrap interval for the top entities. |
|
One metric per method from a benchmark table. |
|
An outcome's values per cluster: does the archetype explain risk? |
|
Horizontal bars of the largest values, optionally per facet. |
|
Nearest-neighbour distances, trusted and flagged, with the calibrated radius. |
|
Within-entity to overall variance ratio per metric, with the line at one. |
- milia.plot.figures.recommend.trust(draw, distances, tau, title=None)#
Nearest-neighbour distances, trusted and flagged, with the calibrated radius.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.distances (
ArrayLike) – Output ofmilia.recommend.retrieval.KNNRetriever.distance().tau (
float) – The trust radius.
- 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 recommend >>> type(recommend.trust(np.linspace(0, 1, 20), 0.6)).__name__ 'Figure'
- milia.plot.figures.recommend.interval(draw, ranked, label, top=15, title=None)#
Rank with its bootstrap interval for the top entities.
Overlapping intervals mean the order is not settled.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.ranked (
DataFrame) – Output ofmilia.recommend.ranking.interval().label (
str) – Column naming each entity.top (
int) – Entities drawn.
- 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 recommend >>> ranked = pd.DataFrame({"name": ["a", "b"], "rank": [1, 2], "lower": [1, 1], "upper": [2, 2]}) >>> type(recommend.interval(ranked, "name")).__name__ 'Figure'
- milia.plot.figures.recommend.top(draw, frame, label, value, n=10, facet=None, title=None)#
Horizontal bars of the largest values, optionally per facet.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.frame (
DataFrame) – One row per entity.label (
str) – Column naming each entity.value (
str) – Column ranked on.n (
int) – Entities kept (per facet).
- 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 recommend >>> frame = pd.DataFrame({"name": list("abc"), "v": [1, 4, 2]}) >>> type(recommend.top(frame, "name", "v", n=2)).__name__ 'Figure'
- milia.plot.figures.recommend.methods(draw, table, metric='mae', title=None)#
One metric per method from a benchmark table.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.evaluate.retrieval.benchmark()(methods as the index).metric (
str) – Metric drawn.
- 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 recommend >>> type(recommend.methods(pd.DataFrame({"mae": [1.0, 2.0]}, index=["knn", "mean"]))).__name__ 'Figure'
- milia.plot.figures.recommend.variance(draw, table, title=None)#
Within-entity to overall variance ratio per metric, with the line at one.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.recommend.diagnostics.variance().
- 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 recommend >>> type(recommend.variance(pd.DataFrame({"metric": ["v"], "ratio": [0.4]}))).__name__ 'Figure'
- milia.plot.figures.recommend.outcomes(draw, labels, frame, column, title=None)#
An outcome’s values per cluster: does the archetype explain risk?
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.labels (
ArrayLike) – Cluster label of each entity.frame (
DataFrame) – One row per entity.column (
str) – Outcome drawn.
- 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 recommend >>> type(recommend.outcomes([0, 1, 1], pd.DataFrame({"risk": [1.0, 2.0, 3.0]}), "risk")).__name__ 'Figure'