isclusters#
- er_evaluation.data_structures.isclusters(obj)[source]#
Check if given object is a clusters dictionary.
- Clusters dictionary:
A clusters dictionary is a Python
dictwith keys corresponding to cluster identifiers and values being list of cluster elements. Example:{'c1': array([0, 1, 2]), 'c2': array([3, 4]), 'c3': array([5])}
- Returns:
True if clusters dictionary, False otherwise.
- Return type:
bool
Examples
>>> from numpy import array >>> obj = {'c1': array([0, 1, 2]), 'c2': array([3, 4]), 'c3': array([5])} >>> isclusters(obj) True
Dictionary values should be numpy arrays:
>>> obj = {'c1': [0, 1, 2], 'c2': [3, 4], 'c3': [5]} >>> isclusters(obj) False
⚠️ Warning: Clustering validity is not checked.
>>> import pandas as pd >>> obj = {'c1': array([pd.NA]), 'c2': array([pd.NA])} >>> isclusters(obj) True
Notes
This function does not verify that clusters are non-overlapping with unique non-NaN elements.