lace.engine.Engine.clustermap

Engine.clustermap(fn_name: str, *, indices=None, linkage_method='ward', no_plot=False, fn_kwargs=None, **kwargs) ClusterMap

Generate a clustermap of a pairwise function.

Parameters:
  • fn_name (str) – The name of the function: ‘rowsim’, ‘mi’, or ‘depprob’

  • indices (List[index], optional) – An optional list of indices from which to generate pairs. The output will be the function computed over the Cartesian product of indices. If None (default), all indices will be considered.

  • linkage_method (str, optional) – The linkage method for computing the hierarchical clustering over the pairwise function values. This values is passed to [scipy.cluster.hierarchy.linkage](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html#scipy.cluster.hierarchy.linkage)

  • no_plot (bool, optional) – If true, returns the linkage, and clustered pairwise function, but does not build a plot

  • fn_kwargs (dict, optional) – Keyword arguments passed to the target function

  • imshow (All other arguments passed to plotly) –

Returns:

The result of the computation. Contains the following fields: - df: the clusterd polars.DataFrame computed by pairwise_fn - linkage: the scipy-generated linkage - figure (optional): the plotly figure

Return type:

ClusterMap

Examples

Compute a dependence probability clustermap

>>> from lace.examples import Animals
>>> animals = Animals()
>>> animals.clustermap(
...     "depprob", zmin=0, zmax=1, color_continuous_scale="greys"
... ).figure.show()

Use the fn_kwargs keyword argument to pass keyword arguments to the target function.

>>> animals.clustermap(
...     "rowsim",
...     zmin=0,
...     zmax=1,
...     color_continuous_scale="greys",
...     fn_kwargs={"wrt": ["swims"]},
... ).figure.show()