milia.plot.figures.recommend#

Recommendation figures: trust histograms, rank intervals, top-N bars and benchmarks.

Functions

interval(draw, ranked, label[, top, title])

Rank with its bootstrap interval for the top entities.

methods(draw, table[, metric, title])

One metric per method from a benchmark table.

outcomes(draw, labels, frame, column[, title])

An outcome's values per cluster: does the archetype explain risk?

top(draw, frame, label, value[, n, facet, title])

Horizontal bars of the largest values, optionally per facet.

trust(draw, distances, tau[, title])

Nearest-neighbour distances, trusted and flagged, with the calibrated radius.

variance(draw, table[, title])

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:
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 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:
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 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:
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 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:
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 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:
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 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:
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 recommend
>>> type(recommend.outcomes([0, 1, 1], pd.DataFrame({"risk": [1.0, 2.0, 3.0]}), "risk")).__name__
'Figure'