scvi.external.contrastivevi.ContrastiveDataSplitter#
- class scvi.external.contrastivevi.ContrastiveDataSplitter(adata_manager, background_indices, target_indices, train_size=None, validation_size=None, shuffle_set_split=True, load_sparse_tensor=False, pin_memory=False, external_indexing=None, **kwargs)[source]#
Bases:
DataSplitterCreates ContrastiveDataLoader for training, validation, and test set.
If
train_size + validation_set < 1thentest_setis non-empty.- Parameters:
- adata_manager
AnnDataManager AnnDataManagerobject that has been created viasetup_anndata.- background_indices
list[int] Indices for background samples in adata.
- target_indices
list[int] Indices for target samples in adata.
- train_size
float|None(default:None) float, or None (default is 0.9)
- validation_size
float|None(default:None) float, or None (default is None)
- shuffle_set_split
bool(default:True) Whether to shuffle indices before splitting. If
False, the val, train, and test set are split in the sequential order of the data according tovalidation_sizeandtrain_sizepercentages.- load_sparse_tensor
bool(default:False) If
True, loads sparse CSR or CSC arrays in the input dataset as sparseTensorwith the same layout. Can lead to significant speedups in transferring data to GPUs, depending on the sparsity of the data. Passed intoAnnDataLoader.- pin_memory
bool(default:False) Whether to copy tensors into device-pinned memory before returning them. Passed into
AnnDataLoader.- external_indexing
list[ndarray] |None(default:None) A list of data split indices in the order of training, validation, and test sets. Validation and test set are not required and can be left empty. Note that per group (train,valid,test) it will cover both the background and target indices
- **kwargs
Keyword args for data loader. Data loader class is
AnnDataLoader.
- adata_manager
Attributes table#
Methods table#
|
Split background and target indices into train/val/test sets. |
Create a test data loader. |
|
Create a train data loader. |
|
Create validation data loader. |
Attributes#
Methods#
- ContrastiveDataSplitter.setup(stage=None)[source]#
Split background and target indices into train/val/test sets.