Compocyte.core.hierarchical_classifierΒΆ

Hierarchical classifier implementation.

This module provides HierarchicalClassifier, a composite classifier that manages a hierarchy of local classifiers for annotating single-cell data. The class orchestrates feature selection, training and prediction across the hierarchy and provides save/load utilities.

class Compocyte.core.hierarchical_classifier.HierarchicalClassifier(save_path, adata=None, root_node=None, dict_of_cell_relations=None, obs_names=None, default_input_data='normlog', num_threads=1, ignore_counts=False, temp_path=None)[source]ΒΆ

Bases: DataBase, HierarchyBase, ExportImportBase

create_local_classifier(node: str, overwrite: bool = False, classifier_type: DenseTorch | LogisticRegression | BoostedTrees = <class 'Compocyte.core.models.dense_torch.DenseTorch'>, **classifier_kwargs)[source]ΒΆ
introduce_limit(max_cells: int, stratify_by: str)[source]ΒΆ

Introduces a limit on the number of cells per local classifier training and specifies a stratification criterion.

Parameters: max_cells (int): The maximum number of cells allowed. stratify_by (str): The criterion by which to stratify the cells.

limit_cells(subset: scanpy.AnnData, max_cells: int, stratify_by: str) scanpy.AnnData[source]ΒΆ
load(load_path=None, load_adata=False)[source]ΒΆ
predict_all_child_nodes(node: str, threshold: float = -1, mlnp: bool = False, monte_carlo: int = None)[source]ΒΆ
predict_single_node(node: str, threshold: float = -1, monte_carlo: int = None) numpy.array[source]ΒΆ
run_feature_selection(node: str, overwrite: bool = False, n_features: int = -1, max_features: int = None, min_features: int = 30, test_factor: float = 1.0, max_cells=100000)[source]ΒΆ
save(save_adata=False)[source]ΒΆ
select_subset(node: str, features: list = None, max_cells: int = None) scanpy.AnnData[source]ΒΆ
select_subset_prediction(node: str, features: list = None, for_trial=False) scanpy.AnnData[source]ΒΆ
set_classifier_type(node, classifier_type)[source]ΒΆ
train_all_child_nodes(parallelize: bool = False, processes: int = None) None[source]ΒΆ
train_single_node(node, standardize_separately: str = None, **fit_kwargs)[source]ΒΆ