scparadise.sceve.hyperparameter_tuning#
- scparadise.sceve.hyperparameter_tuning(mdata, path='', first_modality_name='rna', second_modality_name='prot', first_layer=None, second_layer=None, detailed_annotation=None, model_name='scEve_model_tuning', storage='sceve_model_tuning.db', study_name='study', load_if_exists=True, device='auto', tune_params='auto', random_state=0, num_trials=100, n_splits=5, epochs=None, patience=None, batch_size=None, eval_metric='rmse', use_augmentation=None, aug_probability=None, prob=None, noise_std=None, dropout_aug=None, alpha=None, nc=None, nb=None, nh=None, ed_nh_ratio=None, ff_hd=None, regressor_hd=None, dropout=None, lr=None, weight_decay=None, verbose=True)[source]#
Hyperparameter tuning for scEve model with k-fold cross validation using Optuna.
Notes
- Parameters:
mdata (MuData) – MuData object.
path (str, path object) – Path to create a model folder containing the training history, cell annotation dictionary, and genes used for training.
model_name (str (default: 'model_annotation')) – Name of a folder to save model.
first_modality_name (str (default: 'rna')) – Name of first modality in MuData object.
second_modality_name (str (default: 'prot')) – Name of second modality in MuData object.
first_layer (str (default: None)) – If specified, use mdata.mod[first_modality_name].layers[first_layer] for expression values instead of mdata.mod[first_modality_name].X.
second_layer (str (default: None)) – If specified, use mdata.mod[second_modality_name].layers[second_layer] for expression values instead of mdata.mod[second_modality_name].X.
detailed_annotation (str, (default: None)) – The most detailed level of cell annotation. Key in mdata.obs dataframe. If given may increase model evaluation score.
storage (str (default: 'sceve_model_tuning.db')) – Database URL. If this argument is set to None, in-memory (RAM) storage is used, and the study will not be persistent. We don’t recommend to use in-memory (RAM) storage to save optimization progress.
study_name (str (default: 'study')) – Study’s name. If this argument is set to None, a unique name is generated automatically.
load_if_exists (bool (default: True)) – Flag to control the behavior to handle a conflict of study names. In the case where a study named study_name already exists in the storage, a DuplicatedStudyError is raised if load_if_exists is set to False. Otherwise, the creation of the study is skipped, and the existing one is returned. If the value is True, allows hyperparameter tuning to continue if interrupted (keyboard interrupt, or OS update).
device (str (default: 'auto')) – Type of device to use in training model (‘cpu’, ‘cuda’). Set ‘auto’ for automatic selection.
eval_metric (list (default: ['rmse'])) – The metric is used as the target and for early stopping. The last metric is used as the target and for early stopping. Available metrics: ‘mse’, ‘mae’, ‘rmse’, ‘rmsle’.
num_trials (int (default: 100)) – The number of trials to get optimized hyperparameters for model training.
n_splits (int (default: 5)) – The number of data splits (folds) per trial. The data is divided into n_splits parts, where each part in turn is validation data, and the rest is training data. The number of folds determines the test_size. If n_splits = 5, then test_size = 0.2. If n_splits = 4, then test_size = 0.25.
tune_params (dict or 'auto' (default: 'auto')) – Dict specifying search spaces or “auto” to use built‑in defaults. Ranges and step for scEve model and training parameters. Default tuning parameters are available using ‘scparadise.sceve.get_default_tune_params’. The differences between setting parameters are available in ‘?scparadise.sceve.get_default_tune_params’. For a description of the parameters, see the ‘scparadise.sceve.train’ function.
batch_size (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
epochs (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
patience (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
nc (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
nb (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
nh (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
ed_nh_ratio (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
ff_hd (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
regressor_hd (int or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
dropout (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
lr (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
weight_decay (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
use_augmentation (bool or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
aug_probability (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
prob (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
noise_std (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
dropout_aug (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
alpha (float or None (default: None)) – If a value is specified, then the tuning of this parameter will not be performed.
random_state (int (default: 0)) – Controls the data shuffling, splitting to folds and model training. Pass an int for reproducible output across multiple function calls.
verbose (bool (default: True)) – Show progress bar for each trail during hyperparameter tuning.