milia.plot.figures.agreement#
Agreement figures: heatmaps, transitions, the drift-versus-noise strip and window sensitivity.
Functions
|
How often two clusters share a conformal prediction set. |
|
Distance to own and to nearest other centroid over periods. |
|
Annotated heatmap of a square agreement table. |
|
A square table in long form. |
|
Agreement values per comparison, e.g. seed noise against cross-window drift. |
|
Cluster transitions between two periods. |
|
Metrics against the history window. |
- milia.plot.figures.agreement.square(table, row, column, value)#
A square table in long form.
- Parameters:
- Return type:
- Returns:
One row per cell, row and column labels as strings.
Examples
>>> import pandas as pd >>> square(pd.DataFrame([[1.0, 0.5], [0.5, 1.0]], index=["a", "b"], columns=["a", "b"]), "r", "c", "v").shape (4, 3)
- milia.plot.figures.agreement.heatmap(draw, table, title=None, value='ari')#
Annotated heatmap of a square agreement table.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Square table, e.g. frommilia.cluster.agreement.pairwise().value (
str) – Name of the value shown.
- 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 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.figures.agreement.transitions(draw, table, title=None)#
Cluster transitions between two periods.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.cluster.agreement.transitions().
- 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 agreement >>> type(agreement.transitions(pd.crosstab([0, 1, 1], [0, 0, 1]))).__name__ 'Figure'
- milia.plot.figures.agreement.confusion(draw, pairs, title=None)#
How often two clusters share a conformal prediction set.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.pairs (
DataFrame) – Output ofmilia.cluster.conformal.confusion().
- 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 agreement >>> type(agreement.confusion(pd.DataFrame({"a": [0], "b": [1], "count": [3]}))).__name__ 'Figure'
- milia.plot.figures.agreement.strip(draw, 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:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.groups (
Mapping[str,ArrayLike]) – Comparison name to its agreement values.ylabel (
str) – y-axis label.
- 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 agreement >>> type(agreement.strip({"seeds": [0.9, 0.95], "quarters": [0.4, 0.5]})).__name__ 'Figure'
- milia.plot.figures.agreement.window(draw, table, metrics=('ari', 'silhouette'), title=None)#
Metrics against the history window.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.cluster.agreement.history().
- 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 agreement >>> table = pd.DataFrame({"window": ["day", "week"], "ari": [0.3, 0.6], "silhouette": [0.2, 0.3]}) >>> type(agreement.window(table)).__name__ 'Figure'
- milia.plot.figures.agreement.drift(draw, table, title=None)#
Distance to own and to nearest other centroid over periods.
- Parameters:
draw (
ModuleType) – Drawing backend; bound for you inmilia.plot.letsandmilia.plot.mpl.table (
DataFrame) – Output ofmilia.cluster.agreement.drift().
- 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 agreement >>> table = pd.DataFrame({"period": ["q1", "q2"], "own": [1.0, 2.0], "other": [3.0, 1.5]}) >>> type(agreement.drift(table)).__name__ 'Figure'