milia.plot.mpl.agreement#

Agreement figures drawn with matplotlib (see milia.plot.figures.agreement).

milia.plot.mpl.agreement.confusion(pairs, title=None)#

How often two clusters share a conformal prediction set.

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 agreement
>>> type(agreement.confusion(pd.DataFrame({"a": [0], "b": [1], "count": [3]}))).__name__
'Figure'
milia.plot.mpl.agreement.drift(table, title=None)#

Distance to own and to nearest other centroid over periods.

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 agreement
>>> table = pd.DataFrame({"period": ["q1", "q2"], "own": [1.0, 2.0], "other": [3.0, 1.5]})
>>> type(agreement.drift(table)).__name__
'Figure'
milia.plot.mpl.agreement.heatmap(table, title=None, value='ari')#

Annotated heatmap of a square agreement 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 agreement
>>> table = pd.DataFrame([[1.0, 0.5], [0.5, 1.0]], index=["a", "b"], columns=["a", "b"])
>>> type(agreement.heatmap(table)).__name__
'Figure'
milia.plot.mpl.agreement.strip(groups, title=None, ylabel='ARI')#

Agreement values per comparison, e.g. seed noise against cross-window drift.

Drift is real only where its values sit below the seed-noise values.

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 agreement
>>> type(agreement.strip({"seeds": [0.9, 0.95], "quarters": [0.4, 0.5]})).__name__
'Figure'
milia.plot.mpl.agreement.transitions(table, title=None)#

Cluster transitions between two periods.

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 agreement
>>> type(agreement.transitions(pd.crosstab([0, 1, 1], [0, 0, 1]))).__name__
'Figure'
milia.plot.mpl.agreement.window(table, metrics=('ari', 'silhouette'), title=None)#

Metrics against the history window.

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 agreement
>>> table = pd.DataFrame({"window": ["day", "week"], "ari": [0.3, 0.6], "silhouette": [0.2, 0.3]})
>>> type(agreement.window(table)).__name__
'Figure'