scparadise.sceve.train_tuned#
- scparadise.sceve.train_tuned(mdata, first_modality_name, second_modality_name, first_layer=None, second_layer=None, detailed_annotation=None, path='', path_tuned='', model_name='scEve_model_tuned', test_size=0.2, epochs=None, eval_metric=['rmse'], batch_size=None, patience=None, 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, device='auto', random_state=0, verbose=True, return_model=False)[source]#
Train custom scEve model with tuned hyperparameters. The function automatically uses the configured hyperparameters. However, you can change any hyperparameter by passing it via the corresponding parameter.
- 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.
path_tuned (str, path object) – Path to folder with tuned parameters by ‘scparadise.sceve.hyperparameter_tuning’ function.
model_name (str (default: 'scEve_model_tuned')) – 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[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[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.
test_size (float or int (default: 0.2)) – If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the test split. If int, represents the absolute number of test cells.
epochs (int (default: None)) – Maximum number of epochs for scEve model training. If specified, the specified value is used.
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’.
batch_size (int, (default: None)) – Number of examples per batch. If specified, the specified value is used.
patience (int (default: None)) – Number of consecutive epochs without improvement before performing early stopping. If patience is set to 0, then no early stopping will be performed. Note that if patience is enabled, then best weights from best epoch will automatically be loaded at the end of the training. If specified, the specified value is used.
use_augmentation (bool (default: None)) – Use data augmentation or not. If specified, the specified value is used.
aug_probability (float (default: None)) – The probability of applying augmentation to a batch. If specified, the specified value is used.
prob (float (default: None)) – Gene masking probability. If specified, the specified value is used.
noise_std (float (default: None)) – Gaussian noise standard deviation. If specified, the specified value is used.
dropout_aug (float (default: None)) – Dropout probability for simulating technical noise. If specified, the specified value is used.
alpha (float (default: None)) – Alpha parameter for mixup augmentation. If specified, the specified value is used.
nc (int (default: None)) – Number of chunks for genes from adata. If specified, the specified value is used.
nb (int (default None)) – Number of blocks in scEve model. If specified, the specified value is used.
nh (int (default: None)) – Number of heads in scEve model attention mechanism. If specified, the specified value is used.
ed_nh_ratio (int (default: None)) – Used for calculating embedding dimensionality (‘ed’) from ‘nh’. If specified, the specified value is used.
ff_hd (int (default: None)) – Number of nodes in each scEve model layer in feed forward network. If specified, the specified value is used.
regressor_hd (int (default: None)) – Number of nodes in scEve regressor. If specified, the specified value is used.
dropout (float (default: None)) – Portion of neurons that temporarily ignored during training (prevents overfitting). If specified, the specified value is used.
lr (float (default: None)) – Determines the step size at each iteration while moving toward a minimum of a loss function. If specified, the specified value is used.
weight_decay (float (default: None)) – Weight decay coefficient. If specified, the specified value is used.
device (str (default: 'auto')) – Type of device to use in training model (‘cpu’, ‘cuda’). Set ‘auto’ for automatic selection.
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 epoch during training.
return_model (bool (default: False)) – Return model after training or not.