anndict.utils.stable_label#
- anndict.utils.stable_label(x, y, classifier, *, max_iterations=100, stability_threshold=0.05, moving_average_length=3, random_state=None)[source]#
Trains a classifier using a semi-supervised approach where labels are probabilistically reassigned based on classifier predictions.
- Parameters:
- x
ndarray feature matrix.
- y
ndarray initial labels for all data.
- classifier
ClassifierMixin a classifier instance that implements fit and predict_proba methods.
- max_iterations
int(default:100) maximum number of iterations for updating labels.
- stability_threshold
float(default:0.05) threshold for the fraction of labels changing to consider the labeling stable.
- moving_average_length
int(default:3) number of past iterations to consider for moving average.
- random_state
int|None(default:None) seed for random number generator for reproducibility.
- x
- Return type:
tuple[ClassifierMixin,list[float],int,ndarray]- Returns:
- classifier
ClassifierMixin trained classifier.
- history
list[float] percentage of labels that changed at each iteration.
- iterations
int number of iterations run.
- final_labels
ndarray the labels after the last iteration.
@todo - switch pca_density_subsets to use pca_density_filter_main or pca_density_filter_adata
- classifier