Train API¶
Model Construction¶
customics.CustOMICS.__init__(source_params, central_params, classif_params, surv_params, train_params, device=None)
¶
Model initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_params
|
dict[str, dict]
|
Per-source configuration. Keys are source names; each value is a dict with the following keys:
|
required |
central_params
|
dict
|
Central VAE configuration. Required keys: |
required |
classif_params
|
dict
|
Classifier configuration. Required keys: |
required |
surv_params
|
dict
|
Survival-predictor configuration. Required keys: |
required |
train_params
|
dict
|
Training hyperparameters. Required keys: |
required |
device
|
device | None
|
Torch compute device. |
None
|
Source code in customics/model.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
Training¶
customics.CustOMICS.fit(mdata, omics_val=None, batch_size=32, n_epochs=30, verbose=True)
¶
Train the customics model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mdata
|
MuData
|
Multi-omics object whose |
required |
omics_val
|
MuData | None
|
Validation omics data; same format as |
None
|
batch_size
|
int
|
Mini-batch size. |
32
|
n_epochs
|
int
|
Number of training epochs. |
30
|
verbose
|
bool
|
Log epoch-level loss when True. |
True
|
Raises:
| Type | Description |
|---|---|
DataValidationError
|
If required columns are missing or samples don't overlap. |
Source code in customics/model.py
Training History¶
customics.CustOMICS.plot_loss(show=True, figsize=(6, 3))
¶
Plot training (and validation) loss history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show
|
bool
|
Display the figure interactively. |
True
|
figsize
|
tuple[float, float]
|
Figure size. |
(6, 3)
|
Source code in customics/model.py
Model Size¶
customics.CustOMICS.get_number_parameters()
¶
Persistence¶
customics.CustOMICS.save(path)
¶
Save the model architecture config and trained weights to path.
The checkpoint contains the five parameter dicts needed to reconstruct
the model plus the state_dict and fitted encoders so that inference
works immediately after load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination file (conventionally |
required |
Source code in customics/model.py
customics.CustOMICS.load(path, device=None)
classmethod
¶
Load a model previously saved with save.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the checkpoint file written by save. |
required |
device
|
device | None
|
Target device. Defaults to CPU when not specified. |
None
|
Returns:
| Type | Description |
|---|---|
CustOMICS
|
A fully initialised, ready-to-use model instance. |