anndict.utils.stable_label_adata

anndict.utils.stable_label_adata#

anndict.utils.stable_label_adata(adata, label_key, feature_key, classifier, **kwargs)[source]#

A wrapper for stable_label() that handles categorical labels.

Parameters:
adata AnnData

AnnData object containing the dataset.

label_key str

key to access the labels in adata.obs.

feature_key str

key of data to use in adata.obsm, or 'use_X' to use adata.X.

classifier ClassifierMixin

classifier instance that implements fit and predict_proba methods.

**kwargs

keyword args passed directly to stable_label().

Return type:

tuple[ClassifierMixin, list[float], int, ndarray, LabelEncoder]

Returns:

A tuple containing: - classifier: trained classifier. - history: percentage of labels that changed at each iteration. - iterations: number of iterations run. - final_labels: text-based final labels after the last iteration. - label_encoder: the label encoder used during training (can be used to convert predictions to semantic labels)