scvi.autotune.AutotuneExperiment#
- class scvi.autotune.AutotuneExperiment(model_cls, data, metrics, mode, search_space, num_samples, scheduler='asha', searcher='hyperopt', seed=None, resources=None, experiment_name=None, logging_dir=None, save_checkpoints=False, scheduler_kwargs=None, searcher_kwargs=None, scib_stage='train_end', scib_subsample_rows=5000, scib_indices_list=None, n_jobs=1, solver='arpack', mudata_file_name='mydata.h5mu')[source]#
Track hyperparameter tuning experiments.
- Parameters:
- model_cls
BaseModelClass Model class on which to tune hyperparameters. Must implement a constructor and a
trainmethod.- data
AnnData|MuData|LightningDataModule AnnDataorMuDatathat has been set up withmodel_clsor aLightningDataModule.- metrics
str|list[str] Either a single metric or a list of metrics to track during the experiment. If a list is provided, the primary metric will be the first element in the list.
- mode
Literal['min','max'] Optimization mode for the primary metric. One of
"min"or"max".- search_space
dict[str,dict[Literal['model_params','train_params'],dict[str,Any]]] Dictionary of hyperparameter names and their respective search spaces. See the API for available search specifications. Must only contain the following top-level keys:
"model_params": parameters to pass to the model constructor."train_params": parameters to pass to the model’strainmethod.
Passed into
Tunerasparam_space.- num_samples
int Total number of hyperparameter configurations to sample from the search space. Passed into
TuneConfig.- scheduler
Literal['asha','hyperband','median','fifo'] (default:'asha') Ray Tune scheduler to use. One of the following:
"asha":AsyncHyperBandScheduler"hyperband":HyperBandScheduler"median":MedianStoppingRule"fifo":FIFOScheduler
Configured with reasonable defaults, which can be overridden with
scheduler_kwargs.- searcher
Literal['hyperopt','random'] (default:'hyperopt') Ray Tune search algorithm to use. One of the following:
"hyperopt":HyperOptSearch"random":BasicVariantGenerator
Configured with reasonable defaults, which can be overridden with
searcher_kwargs.- seed
int|None(default:None) Random seed to use for the experiment. Propagated to
scvi.settings.seedand search algorithms. If not provided, defaults toscvi.settings.seed.- resources
dict[Literal['cpu','gpu','memory'],float] |None(default:None) Dictionary of resources to allocate per trial in the experiment. Available keys include:
"cpu": number of CPU cores"gpu": number of GPUs"memory": amount of memory
Passed into
with_resources().- experiment_name
str|None(default:None) Name of the experiment, used for logging purposes. Defaults to a unique ID.
- logging_dir
str|None(default:None) Base directory to store experiment logs. Defaults to
logging_dir.- save_checkpoints
bool(default:False) If True, checkpoints will be saved and reported to Ray. Default False.
- scheduler_kwargs
dict|None(default:None) Additional keyword arguments to pass to the scheduler.
- searcher_kwargs
dict|None(default:None) Additional keyword arguments to pass to the search algorithm.
- scib_stage
str|None(default:'train_end') Used when performing scib-metrics tune, select whether to perform on validation (default) or training end.
- scib_subsample_rows
int|None(default:5000) Used when performing scib-metrics tune, select the number of rows to subsample (100 default). This is important to save computation time
- scib_indices_list
list|None(default:None) If not empty will be used to select the indices to calc the scib metric on, otherwise will use the random indices selection in size of scib_subsample_rows
- n_jobs
int(default:1) Number of jobs to use for parallelization of neighbor search.
- solver
str(default:'arpack') SVD solver to use during PCA. It can help stability issues. Choose from: “arpack”, “randomized” or “auto”
- mudata_file_name
str(default:'mydata.h5mu') name of the mudata file. can be a full path, but will not create folders
- model_cls
Notes
Lifecycle: beta
See also
Attributes table#
Data on which to tune hyperparameters. |
|
Name of the experiment. |
|
Unique identifier for the experiment. |
|
Base directory to store experiment logs. |
|
Metrics to track during the experiment. |
|
Optimization mode for the primary metric. |
|
Model class on which to tune hyperparameters. |
|
Total number of hyperparameter configurations to sample. |
|
Resources to allocate per trial in the experiment. |
|
Result grid for the experiment. |
|
Ray Tune scheduler to use. |
|
Additional keyword arguments to pass to the scheduler. |
|
Search space for hyperparameters. |
|
Ray Tune search algorithm to use. |
|
Additional keyword arguments to pass to the search algorithm. |
|
Random seed to use for the experiment. |
|
Keyword arguments for the setup method. |
|
Either |
Methods table#
|
Configure TensorBoard logger for a trial in this experiment. |
Configure a |
Attributes#
- AutotuneExperiment.data#
Data on which to tune hyperparameters.
- AutotuneExperiment.experiment_name#
Name of the experiment.
- AutotuneExperiment.id#
Unique identifier for the experiment.
- AutotuneExperiment.logging_dir#
Base directory to store experiment logs.
- AutotuneExperiment.metrics#
Metrics to track during the experiment.
- AutotuneExperiment.metrics_callback#
- AutotuneExperiment.mode#
Optimization mode for the primary metric.
- AutotuneExperiment.model_cls#
Model class on which to tune hyperparameters.
- AutotuneExperiment.num_samples#
Total number of hyperparameter configurations to sample.
- AutotuneExperiment.resources#
Resources to allocate per trial in the experiment.
- AutotuneExperiment.result_grid#
Result grid for the experiment.
- AutotuneExperiment.scheduler#
Ray Tune scheduler to use.
- AutotuneExperiment.scheduler_kwargs#
Additional keyword arguments to pass to the scheduler.
- AutotuneExperiment.scib_metrics_callback#
- AutotuneExperiment.search_space#
Search space for hyperparameters.
- AutotuneExperiment.searcher#
Ray Tune search algorithm to use.
- AutotuneExperiment.searcher_kwargs#
Additional keyword arguments to pass to the search algorithm.
- AutotuneExperiment.seed#
Random seed to use for the experiment.
- AutotuneExperiment.setup_method_args#
Keyword arguments for the setup method.
- AutotuneExperiment.setup_method_name#
Either
"setup_anndata"or"setup_mudata".