Note: This environment variable is required for fully deterministic CuBLAS ops on CUDA >= 10.2 when
reproducible=Trueis set below. Without it, PyTorch raises aRuntimeErrorinstead of training deterministically. It must be set beforetorchis imported. See the README FAQ for details.
%env CUBLAS_WORKSPACE_CONFIG=:16:8
How to Save the Pipeline Memory Efficiently¶
Our pipeline offers extensive insights into the dynamics of training and other intermediate results.
When re-using the pipeline (with .save and .load functionality), this can create very large binary files, especially when working with large datasets.
Therefore, the default way of saving the pipeline is by discarding most of the training dynamics and intermediate results.
In this tutorial, we show:
- Which data is kept and which is discarded.
- The trade-offs in visualizing and evaluating a saved pipeline.
- How to save the complete pipeline including all training dynamics and intermediate results.
Theory: What Data is Kept?¶
Result Object¶
The main driver of memory is the result attribute and the _datasets (depending on the data size) in the pipeline and the trainer.
In the result attribute, we save the following:
- model
- adata_latent
All other attributes are set to empty default values.
Pipeline¶
Here we keep all attributes excpept:
.visualizer_datasetsWe remove the.visualizer, because this stores plots which can be misleading when rerunning the pipeline and seeing old plots that do not fit the new data.
We remove the_datasetsattribute, because it is often uses the most memory. All other attributes are kept. This is especially relevant for theconfigand the_preprocessor.
Whenever you perform any pipeline step, it will use the initial config you passed when first creating the pipeline.
The preprocessor is necessary because when runningpredictwith new data, this should be preprocessed the same way as initially (e.g., which genes to keep, how the scalers were fitted, etc.).
Trainer¶
We remove most attribute of the _trainer via the method purge.
IMPORTANT
When calling
.save, theresultattribute is modified in-place (to avoid copies).
This means after calling.save, your current pipeline object does not contain information from the other result objects.
This applies to the pipeline object in current memory, not only to the pipeline object after loading.
If you want to avoid this, please run.save(save_all=True).
from autoencodix.utils.example_data import EXAMPLE_MULTI_SC
from autoencodix.configs.varix_config import VarixConfig
from autoencodix.configs.default_config import DataCase, DataConfig, DataInfo
import autoencodix as acx
my_config = VarixConfig(
learning_rate=0.001,
epochs=30,
checkpoint_interval=5,
default_vae_loss="kl", # kl or mmd possible
data_case=DataCase.MULTI_SINGLE_CELL,
)
print("\n")
print("Starting Pipeline")
print("-" * 50)
print("-" * 50)
varix = acx.Varix(
data=EXAMPLE_MULTI_SC,
config=my_config,
)
result = varix.run()
Starting Pipeline
--------------------------------------------------
--------------------------------------------------
in handle_direct_user_data with data: <class 'autoencodix.data.datapackage.DataPackage'>
mudata: View of MuData object with n_obs × n_vars = 1000 × 700
2 modalities
rna: 1000 x 500
obs: 'cell_type', 'batch', 'donor', 'cell_cycle'
protein: 1000 x 200
obs: 'cell_type', 'batch', 'donor', 'cell_cycle'
Processing 1 MuData objects: ['multi_sc']
Processing train modality: multi_sc
Processing valid split
Processing valid modality: multi_sc
Processing test split
Processing test modality: multi_sc
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
Epoch 1 - Train Loss: 783.8270 Sub-losses: recon_loss: 783.8269, var_loss: 0.0000, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 1 - Valid Loss: 674.2708 Sub-losses: recon_loss: 674.2707, var_loss: 0.0001, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 2 - Train Loss: 699.6010 Sub-losses: recon_loss: 699.6008, var_loss: 0.0002, anneal_factor: 0.0001, effective_beta_factor: 0.0000 Epoch 2 - Valid Loss: 652.1881 Sub-losses: recon_loss: 652.1878, var_loss: 0.0003, anneal_factor: 0.0001, effective_beta_factor: 0.0000 Epoch 3 - Train Loss: 656.4180 Sub-losses: recon_loss: 656.4168, var_loss: 0.0012, anneal_factor: 0.0002, effective_beta_factor: 0.0000 Epoch 3 - Valid Loss: 625.0739 Sub-losses: recon_loss: 625.0734, var_loss: 0.0006, anneal_factor: 0.0002, effective_beta_factor: 0.0000 Epoch 4 - Train Loss: 637.0107 Sub-losses: recon_loss: 637.0058, var_loss: 0.0050, anneal_factor: 0.0003, effective_beta_factor: 0.0000 Epoch 4 - Valid Loss: 615.8611 Sub-losses: recon_loss: 615.8604, var_loss: 0.0007, anneal_factor: 0.0003, effective_beta_factor: 0.0000 Epoch 5 - Train Loss: 627.9194 Sub-losses: recon_loss: 627.9152, var_loss: 0.0042, anneal_factor: 0.0007, effective_beta_factor: 0.0001 Epoch 5 - Valid Loss: 605.3825 Sub-losses: recon_loss: 605.3809, var_loss: 0.0016, anneal_factor: 0.0007, effective_beta_factor: 0.0001 Epoch 6 - Train Loss: 612.5574 Sub-losses: recon_loss: 612.5484, var_loss: 0.0090, anneal_factor: 0.0013, effective_beta_factor: 0.0001 Epoch 6 - Valid Loss: 589.9656 Sub-losses: recon_loss: 589.9628, var_loss: 0.0028, anneal_factor: 0.0013, effective_beta_factor: 0.0001 Epoch 7 - Train Loss: 593.6844 Sub-losses: recon_loss: 593.6668, var_loss: 0.0177, anneal_factor: 0.0025, effective_beta_factor: 0.0002 Epoch 7 - Valid Loss: 560.1090 Sub-losses: recon_loss: 560.1044, var_loss: 0.0045, anneal_factor: 0.0025, effective_beta_factor: 0.0002 Epoch 8 - Train Loss: 561.6479 Sub-losses: recon_loss: 561.6288, var_loss: 0.0191, anneal_factor: 0.0048, effective_beta_factor: 0.0005 Epoch 8 - Valid Loss: 507.7625 Sub-losses: recon_loss: 507.7530, var_loss: 0.0096, anneal_factor: 0.0048, effective_beta_factor: 0.0005 Epoch 9 - Train Loss: 534.9153 Sub-losses: recon_loss: 534.8818, var_loss: 0.0335, anneal_factor: 0.0093, effective_beta_factor: 0.0009 Epoch 9 - Valid Loss: 445.4993 Sub-losses: recon_loss: 445.4802, var_loss: 0.0191, anneal_factor: 0.0093, effective_beta_factor: 0.0009 Epoch 10 - Train Loss: 497.7102 Sub-losses: recon_loss: 497.6525, var_loss: 0.0577, anneal_factor: 0.0180, effective_beta_factor: 0.0018 Epoch 10 - Valid Loss: 438.6540 Sub-losses: recon_loss: 438.6202, var_loss: 0.0338, anneal_factor: 0.0180, effective_beta_factor: 0.0018 Epoch 11 - Train Loss: 483.5498 Sub-losses: recon_loss: 483.4291, var_loss: 0.1206, anneal_factor: 0.0344, effective_beta_factor: 0.0034 Epoch 11 - Valid Loss: 416.3960 Sub-losses: recon_loss: 416.3270, var_loss: 0.0690, anneal_factor: 0.0344, effective_beta_factor: 0.0034 Epoch 12 - Train Loss: 470.8179 Sub-losses: recon_loss: 470.5980, var_loss: 0.2199, anneal_factor: 0.0650, effective_beta_factor: 0.0065 Epoch 12 - Valid Loss: 414.0788 Sub-losses: recon_loss: 413.9213, var_loss: 0.1575, anneal_factor: 0.0650, effective_beta_factor: 0.0065 Epoch 13 - Train Loss: 469.9154 Sub-losses: recon_loss: 469.5027, var_loss: 0.4127, anneal_factor: 0.1192, effective_beta_factor: 0.0119 Epoch 13 - Valid Loss: 403.3598 Sub-losses: recon_loss: 403.0631, var_loss: 0.2967, anneal_factor: 0.1192, effective_beta_factor: 0.0119 Epoch 14 - Train Loss: 462.5418 Sub-losses: recon_loss: 461.8312, var_loss: 0.7105, anneal_factor: 0.2086, effective_beta_factor: 0.0209 Epoch 14 - Valid Loss: 394.7311 Sub-losses: recon_loss: 394.1951, var_loss: 0.5361, anneal_factor: 0.2086, effective_beta_factor: 0.0209 Epoch 15 - Train Loss: 473.5944 Sub-losses: recon_loss: 472.4635, var_loss: 1.1309, anneal_factor: 0.3392, effective_beta_factor: 0.0339 Epoch 15 - Valid Loss: 399.1707 Sub-losses: recon_loss: 398.3019, var_loss: 0.8688, anneal_factor: 0.3392, effective_beta_factor: 0.0339 Epoch 16 - Train Loss: 460.3056 Sub-losses: recon_loss: 458.5930, var_loss: 1.7126, anneal_factor: 0.5000, effective_beta_factor: 0.0500 Epoch 16 - Valid Loss: 397.4022 Sub-losses: recon_loss: 395.9919, var_loss: 1.4102, anneal_factor: 0.5000, effective_beta_factor: 0.0500 Epoch 17 - Train Loss: 440.7799 Sub-losses: recon_loss: 438.4338, var_loss: 2.3461, anneal_factor: 0.6608, effective_beta_factor: 0.0661 Epoch 17 - Valid Loss: 394.7011 Sub-losses: recon_loss: 392.7804, var_loss: 1.9207, anneal_factor: 0.6608, effective_beta_factor: 0.0661 Epoch 18 - Train Loss: 454.1740 Sub-losses: recon_loss: 451.1796, var_loss: 2.9944, anneal_factor: 0.7914, effective_beta_factor: 0.0791 Epoch 18 - Valid Loss: 394.9608 Sub-losses: recon_loss: 392.6119, var_loss: 2.3489, anneal_factor: 0.7914, effective_beta_factor: 0.0791 Epoch 19 - Train Loss: 441.0030 Sub-losses: recon_loss: 437.6811, var_loss: 3.3219, anneal_factor: 0.8808, effective_beta_factor: 0.0881 Epoch 19 - Valid Loss: 393.5808 Sub-losses: recon_loss: 391.0548, var_loss: 2.5260, anneal_factor: 0.8808, effective_beta_factor: 0.0881 Epoch 20 - Train Loss: 443.8722 Sub-losses: recon_loss: 440.2967, var_loss: 3.5755, anneal_factor: 0.9350, effective_beta_factor: 0.0935 Epoch 20 - Valid Loss: 395.2028 Sub-losses: recon_loss: 392.4612, var_loss: 2.7416, anneal_factor: 0.9350, effective_beta_factor: 0.0935 Epoch 21 - Train Loss: 445.0039 Sub-losses: recon_loss: 441.2810, var_loss: 3.7229, anneal_factor: 0.9656, effective_beta_factor: 0.0966 Epoch 21 - Valid Loss: 397.5640 Sub-losses: recon_loss: 394.4998, var_loss: 3.0642, anneal_factor: 0.9656, effective_beta_factor: 0.0966 Epoch 22 - Train Loss: 436.5999 Sub-losses: recon_loss: 432.9243, var_loss: 3.6755, anneal_factor: 0.9820, effective_beta_factor: 0.0982 Epoch 22 - Valid Loss: 396.8338 Sub-losses: recon_loss: 393.9197, var_loss: 2.9141, anneal_factor: 0.9820, effective_beta_factor: 0.0982 Epoch 23 - Train Loss: 436.5542 Sub-losses: recon_loss: 432.7557, var_loss: 3.7985, anneal_factor: 0.9907, effective_beta_factor: 0.0991 Epoch 23 - Valid Loss: 393.0197 Sub-losses: recon_loss: 389.9772, var_loss: 3.0426, anneal_factor: 0.9907, effective_beta_factor: 0.0991 Epoch 24 - Train Loss: 440.4967 Sub-losses: recon_loss: 436.5647, var_loss: 3.9319, anneal_factor: 0.9952, effective_beta_factor: 0.0995 Epoch 24 - Valid Loss: 392.2895 Sub-losses: recon_loss: 389.0881, var_loss: 3.2015, anneal_factor: 0.9952, effective_beta_factor: 0.0995 Epoch 25 - Train Loss: 439.7828 Sub-losses: recon_loss: 435.8818, var_loss: 3.9011, anneal_factor: 0.9975, effective_beta_factor: 0.0998 Epoch 25 - Valid Loss: 392.1140 Sub-losses: recon_loss: 388.8866, var_loss: 3.2273, anneal_factor: 0.9975, effective_beta_factor: 0.0998 Epoch 26 - Train Loss: 436.1428 Sub-losses: recon_loss: 432.1413, var_loss: 4.0016, anneal_factor: 0.9987, effective_beta_factor: 0.0999 Epoch 26 - Valid Loss: 393.1209 Sub-losses: recon_loss: 389.9928, var_loss: 3.1280, anneal_factor: 0.9987, effective_beta_factor: 0.0999 Epoch 27 - Train Loss: 451.9407 Sub-losses: recon_loss: 448.0566, var_loss: 3.8841, anneal_factor: 0.9993, effective_beta_factor: 0.0999 Epoch 27 - Valid Loss: 392.9781 Sub-losses: recon_loss: 389.4436, var_loss: 3.5345, anneal_factor: 0.9993, effective_beta_factor: 0.0999 Epoch 28 - Train Loss: 433.2443 Sub-losses: recon_loss: 429.2605, var_loss: 3.9838, anneal_factor: 0.9997, effective_beta_factor: 0.1000 Epoch 28 - Valid Loss: 396.1637 Sub-losses: recon_loss: 392.5587, var_loss: 3.6050, anneal_factor: 0.9997, effective_beta_factor: 0.1000 Epoch 29 - Train Loss: 432.2076 Sub-losses: recon_loss: 428.2002, var_loss: 4.0074, anneal_factor: 0.9998, effective_beta_factor: 0.1000 Epoch 29 - Valid Loss: 392.4899 Sub-losses: recon_loss: 389.0604, var_loss: 3.4295, anneal_factor: 0.9998, effective_beta_factor: 0.1000 Epoch 30 - Train Loss: 428.7175 Sub-losses: recon_loss: 424.6904, var_loss: 4.0272, anneal_factor: 0.9999, effective_beta_factor: 0.1000 Epoch 30 - Valid Loss: 391.6893 Sub-losses: recon_loss: 388.3713, var_loss: 3.3179, anneal_factor: 0.9999, effective_beta_factor: 0.1000
Saving and Loading Explained¶
Here we first check the latent space (could be any other training dynamic) before saving.
After saving, we see that the result object got cleaned and only model, adata_latent, and embedding_evaluation are kept.
ls_before_save = result.latentspaces.get(epoch=-1, split="test")
print("Length of latentspace before saving")
print(len(ls_before_save))
varix.save("varix_backup.pkl")
ls_after_save = result.latentspaces.get()
print("Length of latentspace after saving")
print(len(ls_after_save))
Length of latentspace before saving 200 Preprocessor saved successfully. saving memory efficient Pipeline object saved successfully. Length of latentspace after saving 0
Implications for Visualization¶
We load the model and see the implications of this in visualize.
varix_loaded = acx.Varix().load("varix_backup.pkl")
Attempting to load a pipeline from ./varix_backup.pkl... Pipeline object loaded successfully. Actual type: Varix Preprocessor loaded successfully.
varix_loaded.visualize()
<Figure size 0x500 with 0 Axes>
Note that we code a
UserWarning. This is expected, since it tells us that we cannot visualize loss plots anymore because the data for this is no longer in the result object.
However, we could run a predict step on the trained model to get some visualizations.
res_loaded = varix_loaded.predict(data=EXAMPLE_MULTI_SC)
in handle_direct_user_data with data: <class 'autoencodix.data.datapackage.DataPackage'>
mudata: View of MuData object with n_obs × n_vars = 1000 × 700
2 modalities
rna: 1000 x 500
obs: 'cell_type', 'batch', 'donor', 'cell_cycle', 'n_genes'
protein: 1000 x 200
obs: 'cell_type', 'batch', 'donor', 'cell_cycle', 'n_genes'
Processing 1 MuData objects: ['multi_sc']
Processing test split
Processing test modality: multi_sc
n_samples in format recon: 1000
train
n_samples from datatpackge: {'paired_count': 1000}
varix_loaded.visualize()
# we use test split here, because predict with new data is equal to test split
varix_loaded.show_result(split="test")
Creating plots ...
<Figure size 0x500 with 0 Axes>
Implications for Evaluate¶
The evaluate step is not supported for this memory-efficient saving as of now, and you'll get the following warning and error:
res_eval = varix_loaded.evaluate(params=["cell_type"])
Perform ML task with feature df: Latent Latent Perform ML task for target parameter: cell_type
How to Keep All Data¶
When you really want to investigate all training dynamics and results, we recommend setting save_all=True. See below:
from autoencodix.utils.example_data import EXAMPLE_MULTI_BULK
my_config = VarixConfig(
learning_rate=0.001,
epochs=30,
checkpoint_interval=5,
default_vae_loss="kl", # kl or mmd possible
data_case=DataCase.MULTI_BULK,
)
n_varix = acx.Varix(data=EXAMPLE_MULTI_BULK, config=my_config)
result_new = n_varix.run()
n_varix.save(file_path="new_varix.pkl", save_all=True)
in handle_direct_user_data with data: <class 'autoencodix.data.datapackage.DataPackage'> anno key: transcriptomics anno key: proteomics Epoch 1 - Train Loss: 214.2306 Sub-losses: recon_loss: 214.2306, var_loss: 0.0000, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 1 - Valid Loss: 185.5984 Sub-losses: recon_loss: 185.5983, var_loss: 0.0000, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 2 - Train Loss: 203.4312 Sub-losses: recon_loss: 203.4311, var_loss: 0.0001, anneal_factor: 0.0001, effective_beta_factor: 0.0000 Epoch 2 - Valid Loss: 187.5715 Sub-losses: recon_loss: 187.5715, var_loss: 0.0000, anneal_factor: 0.0001, effective_beta_factor: 0.0000 Epoch 3 - Train Loss: 197.6002 Sub-losses: recon_loss: 197.6001, var_loss: 0.0001, anneal_factor: 0.0002, effective_beta_factor: 0.0000 Epoch 3 - Valid Loss: 185.5950 Sub-losses: recon_loss: 185.5950, var_loss: 0.0000, anneal_factor: 0.0002, effective_beta_factor: 0.0000 Epoch 4 - Train Loss: 195.3141 Sub-losses: recon_loss: 195.3139, var_loss: 0.0002, anneal_factor: 0.0003, effective_beta_factor: 0.0000 Epoch 4 - Valid Loss: 184.0191 Sub-losses: recon_loss: 184.0190, var_loss: 0.0001, anneal_factor: 0.0003, effective_beta_factor: 0.0000 Epoch 5 - Train Loss: 191.4216 Sub-losses: recon_loss: 191.4212, var_loss: 0.0004, anneal_factor: 0.0007, effective_beta_factor: 0.0001 Epoch 5 - Valid Loss: 184.4212 Sub-losses: recon_loss: 184.4210, var_loss: 0.0002, anneal_factor: 0.0007, effective_beta_factor: 0.0001 Epoch 6 - Train Loss: 190.2712 Sub-losses: recon_loss: 190.2704, var_loss: 0.0008, anneal_factor: 0.0013, effective_beta_factor: 0.0001 Epoch 6 - Valid Loss: 183.9692 Sub-losses: recon_loss: 183.9686, var_loss: 0.0006, anneal_factor: 0.0013, effective_beta_factor: 0.0001 Epoch 7 - Train Loss: 187.3219 Sub-losses: recon_loss: 187.3202, var_loss: 0.0018, anneal_factor: 0.0025, effective_beta_factor: 0.0002 Epoch 7 - Valid Loss: 182.1401 Sub-losses: recon_loss: 182.1388, var_loss: 0.0013, anneal_factor: 0.0025, effective_beta_factor: 0.0002 Epoch 8 - Train Loss: 185.5204 Sub-losses: recon_loss: 185.5167, var_loss: 0.0036, anneal_factor: 0.0048, effective_beta_factor: 0.0005 Epoch 8 - Valid Loss: 179.8548 Sub-losses: recon_loss: 179.8524, var_loss: 0.0024, anneal_factor: 0.0048, effective_beta_factor: 0.0005 Epoch 9 - Train Loss: 184.3709 Sub-losses: recon_loss: 184.3626, var_loss: 0.0083, anneal_factor: 0.0093, effective_beta_factor: 0.0009 Epoch 9 - Valid Loss: 181.4105 Sub-losses: recon_loss: 181.4053, var_loss: 0.0052, anneal_factor: 0.0093, effective_beta_factor: 0.0009 Epoch 10 - Train Loss: 182.7771 Sub-losses: recon_loss: 182.7612, var_loss: 0.0159, anneal_factor: 0.0180, effective_beta_factor: 0.0018 Epoch 10 - Valid Loss: 178.7134 Sub-losses: recon_loss: 178.7029, var_loss: 0.0104, anneal_factor: 0.0180, effective_beta_factor: 0.0018 Epoch 11 - Train Loss: 179.8746 Sub-losses: recon_loss: 179.8428, var_loss: 0.0318, anneal_factor: 0.0344, effective_beta_factor: 0.0034 Epoch 11 - Valid Loss: 175.9603 Sub-losses: recon_loss: 175.9353, var_loss: 0.0250, anneal_factor: 0.0344, effective_beta_factor: 0.0034 Epoch 12 - Train Loss: 177.6577 Sub-losses: recon_loss: 177.5888, var_loss: 0.0689, anneal_factor: 0.0650, effective_beta_factor: 0.0065 Epoch 12 - Valid Loss: 178.2489 Sub-losses: recon_loss: 178.2000, var_loss: 0.0489, anneal_factor: 0.0650, effective_beta_factor: 0.0065 Epoch 13 - Train Loss: 177.2356 Sub-losses: recon_loss: 177.1096, var_loss: 0.1260, anneal_factor: 0.1192, effective_beta_factor: 0.0119 Epoch 13 - Valid Loss: 174.5106 Sub-losses: recon_loss: 174.4299, var_loss: 0.0807, anneal_factor: 0.1192, effective_beta_factor: 0.0119 Epoch 14 - Train Loss: 176.5659 Sub-losses: recon_loss: 176.3190, var_loss: 0.2469, anneal_factor: 0.2086, effective_beta_factor: 0.0209 Epoch 14 - Valid Loss: 174.3225 Sub-losses: recon_loss: 174.1803, var_loss: 0.1422, anneal_factor: 0.2086, effective_beta_factor: 0.0209 Epoch 15 - Train Loss: 173.8222 Sub-losses: recon_loss: 173.4113, var_loss: 0.4109, anneal_factor: 0.3392, effective_beta_factor: 0.0339 Epoch 15 - Valid Loss: 176.3353 Sub-losses: recon_loss: 176.0875, var_loss: 0.2478, anneal_factor: 0.3392, effective_beta_factor: 0.0339 Epoch 16 - Train Loss: 172.2794 Sub-losses: recon_loss: 171.6635, var_loss: 0.6159, anneal_factor: 0.5000, effective_beta_factor: 0.0500 Epoch 16 - Valid Loss: 174.5671 Sub-losses: recon_loss: 174.2156, var_loss: 0.3515, anneal_factor: 0.5000, effective_beta_factor: 0.0500 Epoch 17 - Train Loss: 170.2685 Sub-losses: recon_loss: 169.4155, var_loss: 0.8530, anneal_factor: 0.6608, effective_beta_factor: 0.0661 Epoch 17 - Valid Loss: 173.7806 Sub-losses: recon_loss: 173.2976, var_loss: 0.4829, anneal_factor: 0.6608, effective_beta_factor: 0.0661 Epoch 18 - Train Loss: 170.7247 Sub-losses: recon_loss: 169.6572, var_loss: 1.0675, anneal_factor: 0.7914, effective_beta_factor: 0.0791 Epoch 18 - Valid Loss: 173.0292 Sub-losses: recon_loss: 172.3982, var_loss: 0.6310, anneal_factor: 0.7914, effective_beta_factor: 0.0791 Epoch 19 - Train Loss: 169.7708 Sub-losses: recon_loss: 168.5970, var_loss: 1.1737, anneal_factor: 0.8808, effective_beta_factor: 0.0881 Epoch 19 - Valid Loss: 174.4595 Sub-losses: recon_loss: 173.7771, var_loss: 0.6825, anneal_factor: 0.8808, effective_beta_factor: 0.0881 Epoch 20 - Train Loss: 168.6560 Sub-losses: recon_loss: 167.3547, var_loss: 1.3013, anneal_factor: 0.9350, effective_beta_factor: 0.0935 Epoch 20 - Valid Loss: 173.9368 Sub-losses: recon_loss: 173.2402, var_loss: 0.6966, anneal_factor: 0.9350, effective_beta_factor: 0.0935 Epoch 21 - Train Loss: 168.6468 Sub-losses: recon_loss: 167.3661, var_loss: 1.2808, anneal_factor: 0.9656, effective_beta_factor: 0.0966 Epoch 21 - Valid Loss: 173.9302 Sub-losses: recon_loss: 173.1697, var_loss: 0.7605, anneal_factor: 0.9656, effective_beta_factor: 0.0966 Epoch 22 - Train Loss: 167.6626 Sub-losses: recon_loss: 166.2957, var_loss: 1.3668, anneal_factor: 0.9820, effective_beta_factor: 0.0982 Epoch 22 - Valid Loss: 171.7076 Sub-losses: recon_loss: 170.9284, var_loss: 0.7792, anneal_factor: 0.9820, effective_beta_factor: 0.0982 Epoch 23 - Train Loss: 166.7637 Sub-losses: recon_loss: 165.4086, var_loss: 1.3551, anneal_factor: 0.9907, effective_beta_factor: 0.0991 Epoch 23 - Valid Loss: 171.9471 Sub-losses: recon_loss: 171.1123, var_loss: 0.8348, anneal_factor: 0.9907, effective_beta_factor: 0.0991 Epoch 24 - Train Loss: 164.6296 Sub-losses: recon_loss: 163.2627, var_loss: 1.3669, anneal_factor: 0.9952, effective_beta_factor: 0.0995 Epoch 24 - Valid Loss: 170.6566 Sub-losses: recon_loss: 169.8342, var_loss: 0.8224, anneal_factor: 0.9952, effective_beta_factor: 0.0995 Epoch 25 - Train Loss: 165.6159 Sub-losses: recon_loss: 164.1586, var_loss: 1.4573, anneal_factor: 0.9975, effective_beta_factor: 0.0998 Epoch 25 - Valid Loss: 170.8879 Sub-losses: recon_loss: 170.0140, var_loss: 0.8739, anneal_factor: 0.9975, effective_beta_factor: 0.0998 Epoch 26 - Train Loss: 163.7932 Sub-losses: recon_loss: 162.3245, var_loss: 1.4687, anneal_factor: 0.9987, effective_beta_factor: 0.0999 Epoch 26 - Valid Loss: 169.5822 Sub-losses: recon_loss: 168.7289, var_loss: 0.8533, anneal_factor: 0.9987, effective_beta_factor: 0.0999 Epoch 27 - Train Loss: 161.9896 Sub-losses: recon_loss: 160.4601, var_loss: 1.5295, anneal_factor: 0.9993, effective_beta_factor: 0.0999 Epoch 27 - Valid Loss: 169.6479 Sub-losses: recon_loss: 168.8129, var_loss: 0.8350, anneal_factor: 0.9993, effective_beta_factor: 0.0999 Epoch 28 - Train Loss: 162.4318 Sub-losses: recon_loss: 160.8788, var_loss: 1.5529, anneal_factor: 0.9997, effective_beta_factor: 0.1000 Epoch 28 - Valid Loss: 169.6541 Sub-losses: recon_loss: 168.7791, var_loss: 0.8749, anneal_factor: 0.9997, effective_beta_factor: 0.1000 Epoch 29 - Train Loss: 162.1046 Sub-losses: recon_loss: 160.5550, var_loss: 1.5496, anneal_factor: 0.9998, effective_beta_factor: 0.1000 Epoch 29 - Valid Loss: 168.5911 Sub-losses: recon_loss: 167.6339, var_loss: 0.9572, anneal_factor: 0.9998, effective_beta_factor: 0.1000 Epoch 30 - Train Loss: 160.8321 Sub-losses: recon_loss: 159.2459, var_loss: 1.5862, anneal_factor: 0.9999, effective_beta_factor: 0.1000 Epoch 30 - Valid Loss: 165.0649 Sub-losses: recon_loss: 164.0801, var_loss: 0.9848, anneal_factor: 0.9999, effective_beta_factor: 0.1000 Preprocessor saved successfully. Pipeline object saved successfully.
Now we can load the pipeline and all intermediate data is kept.
loaded_all_varix = acx.Varix().load(file_path="new_varix.pkl")
Attempting to load a pipeline from ./new_varix.pkl... Pipeline object loaded successfully. Actual type: Varix Preprocessor loaded successfully.
loaded_all_varix.visualize()
loaded_all_varix.show_result()
Creating plots ...
And we see that the loss plots from the initial training are still present.
Implications for Ontix and XModalix¶
These two pipelines offer more/other visualizations.
❗❗ Requirements: Getting Tutorial Data for XModalixj ❗❗¶
The data for this tutorial is hosted on Hugging Face Hub (autoencodix/tcga) and is downloaded automatically in the cell below on first run.
XModalix¶
import os
import autoencodix as acx
from autoencodix.configs.xmodalix_config import XModalixConfig
from autoencodix.configs.default_config import DataCase
p = os.getcwd()
d = "autoencodix_package"
if d not in p:
raise FileNotFoundError(f"'{d}' not found in path: {p}")
os.chdir(os.sep.join(p.split(os.sep)[: p.split(os.sep).index(d) + 1]))
print(f"Changed to: {os.getcwd()}")
# ---------------------------------------------------------------------
# Data is hosted on Hugging Face Hub and downloaded (and locally cached)
# automatically, then placed under the paths used below
# ---------------------------------------------------------------------
import shutil
import zipfile
import pandas as pd
from huggingface_hub import hf_hub_download
HF_REPO_ID = "autoencodix/tcga"
xmod_data_root = "data/XModalix-Tut-data"
os.makedirs(xmod_data_root, exist_ok=True)
rna_path = hf_hub_download(repo_id=HF_REPO_ID, repo_type="dataset", filename="rna.parquet")
shutil.copyfile(rna_path, os.path.join(xmod_data_root, "combined_rnaseq_formatted.parquet"))
clin_path = hf_hub_download(repo_id=HF_REPO_ID, repo_type="dataset", filename="clinical.parquet")
mapping_path = hf_hub_download(
repo_id=HF_REPO_ID, repo_type="dataset", filename="xmodalix/tcga_image_mappings.txt"
)
# The base clinical file has no image column; the XModalix image mapping is a separate,
# per-architecture extension that we join in here (left join: not every sample has an image).
clin_df = pd.read_parquet(clin_path)
mapping_df = pd.read_csv(mapping_path, sep="\t", index_col="sample_ids")
clin_df["img_paths"] = mapping_df["img_paths"]
clin_df.to_parquet(os.path.join(xmod_data_root, "combined_clin_formatted.parquet"))
images_zip = hf_hub_download(
repo_id=HF_REPO_ID, repo_type="dataset", filename="xmodalix/tcga_fake_images.zip"
)
images_extract_dir = os.path.join(xmod_data_root, "images")
if not os.path.isdir(os.path.join(images_extract_dir, "tcga_fake")):
with zipfile.ZipFile(images_zip) as zf:
zf.extractall(images_extract_dir)
clin_file = os.path.join("data/XModalix-Tut-data/combined_clin_formatted.parquet")
rna_file = os.path.join("data/XModalix-Tut-data/combined_rnaseq_formatted.parquet")
img_root = os.path.join("data/XModalix-Tut-data/images/tcga_fake")
xmodalix_config = XModalixConfig(
checkpoint_interval=5,
class_param="CANCER_TYPE_ACRONYM",
epochs=30,
latent_dim=8,
requires_paired=False,
pretrain_epochs=2,
data_case=DataCase.IMG_TO_BULK,
data_config=DataConfig(
annotation_columns=["CANCER_TYPE_ACRONYM"],
data_info={
"img": DataInfo(
file_path=img_root,
data_type="IMG",
scaling="MINMAX",
translate_direction="to",
pretrain_epochs=2,
# extra_anno_file=imganno_file,
),
"rna": DataInfo(
file_path=rna_file,
data_type="NUMERIC",
scaling="MINMAX",
translate_direction="from",
),
"anno": DataInfo(file_path=clin_file, data_type="ANNOTATION", sep="\t"),
},
),
)
xmodalix = acx.XModalix(config=xmodalix_config)
result = xmodalix.run()
outpath = os.path.join("tutorial_res", "xmodalix.pkl")
xmodalix.save(file_path=outpath)
Now we can load the pipeline again
xmodalix_loaded = acx.XModalix.load(outpath)
Attempting to load a pipeline from tutorial_res/xmodalix.pkl... Pipeline object loaded successfully. Actual type: XModalix Preprocessor loaded successfully.
Since we used memory efficient saving, we did not save the data, thus we need to run preprocessing again, this will read and preprocess the files defined in the config.
xmodalix_loaded.preprocess()
reading parquet: data/XModalix-Tut-data/combined_rnaseq_formatted.parquet reading parquet: data/XModalix-Tut-data/combined_clin_formatted.parquet Given image size is possible, rescaling images to: 64x64 Successfully loaded 3230 images for img anno key: rna anno key: img Converting 2261 images to torch.float32 tensors... Converting 646 images to torch.float32 tensors... Converting 323 images to torch.float32 tensors... key: train, type: <class 'dict'> key: valid, type: <class 'dict'> key: test, type: <class 'dict'>
No we can use the trained model to predict again:
# now you can use the model to predict with a different pair again:
r = xmodalix_loaded.predict(from_key="rna", to_key="img")
Prediction complete. Processing latent space results into a single AnnData object... Identified source modality for latent space: 'multi_bulk.rna' - Added 17450 source feature IDs to .uns Finished processing latent results.
xmodalix_loaded.visualize()
xmodalix_loaded.show_result()
Creating plots ... Absolute loss plot not found in the plots dictionary This happens, when you did not run visualize() or if you saved and loaded the model with `save_all=False`
Ontix¶
import autoencodix as acx
from autoencodix.configs.default_config import DefaultConfig
from autoencodix.configs.ontix_config import OntixConfig
from autoencodix.utils.example_data import (
EXAMPLE_PROCESSED_DATA,
)
# EXAMPLE_DATA hold PyTorch Datasets (child with extra info) with metdata for train, test and valid splits
processed_data = EXAMPLE_PROCESSED_DATA
ont_lvl1 = dict()
ont_lvl2 = dict()
ont_lvl1["pwy-1"] = ["sub-pwy-1", "sub-pwy-2"]
ont_lvl1["pwy-2"] = ["sub-pwy-2"]
ont_lvl1["pwy-3"] = ["sub-pwy-1", "sub-pwy-3"]
# first third of feature ids in processed_data.train.feature_ids
ont_lvl2["sub-pwy-1"] = processed_data.train.feature_ids[
: int(len(processed_data.train.feature_ids) / 3)
]
# second third of feature ids in processed_data.train.feature_ids
ont_lvl2["sub-pwy-2"] = processed_data.train.feature_ids[
int(len(processed_data.train.feature_ids) / 3) : int(
2 * len(processed_data.train.feature_ids) / 3
)
]
# last third of feature ids in processed_data.train.feature_ids
ont_lvl2["sub-pwy-3"] = processed_data.train.feature_ids[
int(2 * len(processed_data.train.feature_ids) / 3) : int(
len(processed_data.train.feature_ids)
)
]
# ont_lvl2["sub-pwy-1"] = ["gene-1", "gene-2"]
# ont_lvl2["sub-pwy-2"] = ["gene-3", "gene-4"]
# ont_lvl2["sub-pwy-3"] = ["gene-2", "gene-6"]
ontology_tuple = (ont_lvl1, ont_lvl2)
# Write each dictionary in ontology_tuple to a separate text file
for i, ont_dict in enumerate(ontology_tuple):
file_name = f"ontology_level_{i + 1}.txt"
with open(file_name, "w") as f:
for key, values in ont_dict.items():
for value in values:
f.write(f"{value}\t{key}\n")
print("Ontology dictionaries written to ontology_level_1.txt and ontology_level_2.txt")
ont_files = ["ontology_level_1.txt", "ontology_level_2.txt"]
Ontology dictionaries written to ontology_level_1.txt and ontology_level_2.txt
ontix = acx.Ontix(
ontologies=ont_files,
sep="\t",
config=OntixConfig(epochs=30, learning_rate=0.005, n_layers=1),
data=processed_data,
)
result_onitx = ontix.run()
Ontix checks: All possible feature names length: 30 Feature order length: 30 Feature names without filtering: 30 Mask layer 0 with shape torch.Size([3, 3]) and 5.0 connections Mask layer 1 with shape torch.Size([30, 3]) and 30.0 connections Latent Dim: 3 Epoch 1 - Train Loss: 1221.0144 Sub-losses: recon_loss: 1221.0143, var_loss: 0.0001, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 1 - Valid Loss: 1201.5706 Sub-losses: recon_loss: 1201.5705, var_loss: 0.0002, anneal_factor: 0.0000, effective_beta_factor: 0.0000 Epoch 2 - Train Loss: 1197.5059 Sub-losses: recon_loss: 1197.5055, var_loss: 0.0004, anneal_factor: 0.0001, effective_beta_factor: 0.0001 Epoch 2 - Valid Loss: 1176.2030 Sub-losses: recon_loss: 1176.2024, var_loss: 0.0006, anneal_factor: 0.0001, effective_beta_factor: 0.0001 Epoch 3 - Train Loss: 1162.7103 Sub-losses: recon_loss: 1162.7088, var_loss: 0.0015, anneal_factor: 0.0002, effective_beta_factor: 0.0002 Epoch 3 - Valid Loss: 1132.3454 Sub-losses: recon_loss: 1132.3434, var_loss: 0.0020, anneal_factor: 0.0002, effective_beta_factor: 0.0002 Epoch 4 - Train Loss: 1114.2964 Sub-losses: recon_loss: 1114.2919, var_loss: 0.0045, anneal_factor: 0.0003, effective_beta_factor: 0.0003 Epoch 4 - Valid Loss: 1078.6582 Sub-losses: recon_loss: 1078.6521, var_loss: 0.0062, anneal_factor: 0.0003, effective_beta_factor: 0.0003 Epoch 5 - Train Loss: 1065.5264 Sub-losses: recon_loss: 1065.5127, var_loss: 0.0137, anneal_factor: 0.0007, effective_beta_factor: 0.0007 Epoch 5 - Valid Loss: 1031.6363 Sub-losses: recon_loss: 1031.6191, var_loss: 0.0172, anneal_factor: 0.0007, effective_beta_factor: 0.0007 Epoch 6 - Train Loss: 1025.8335 Sub-losses: recon_loss: 1025.7974, var_loss: 0.0360, anneal_factor: 0.0013, effective_beta_factor: 0.0013 Epoch 6 - Valid Loss: 1003.2790 Sub-losses: recon_loss: 1003.2419, var_loss: 0.0371, anneal_factor: 0.0013, effective_beta_factor: 0.0013 Epoch 7 - Train Loss: 1007.7999 Sub-losses: recon_loss: 1007.7208, var_loss: 0.0791, anneal_factor: 0.0025, effective_beta_factor: 0.0025 Epoch 7 - Valid Loss: 981.5320 Sub-losses: recon_loss: 981.4466, var_loss: 0.0855, anneal_factor: 0.0025, effective_beta_factor: 0.0025 Epoch 8 - Train Loss: 990.8652 Sub-losses: recon_loss: 990.6891, var_loss: 0.1762, anneal_factor: 0.0048, effective_beta_factor: 0.0048 Epoch 8 - Valid Loss: 974.6721 Sub-losses: recon_loss: 974.5013, var_loss: 0.1707, anneal_factor: 0.0048, effective_beta_factor: 0.0048 Epoch 9 - Train Loss: 977.5746 Sub-losses: recon_loss: 977.2104, var_loss: 0.3642, anneal_factor: 0.0093, effective_beta_factor: 0.0093 Epoch 9 - Valid Loss: 955.1447 Sub-losses: recon_loss: 954.7737, var_loss: 0.3711, anneal_factor: 0.0093, effective_beta_factor: 0.0093 Epoch 10 - Train Loss: 974.9158 Sub-losses: recon_loss: 974.1722, var_loss: 0.7436, anneal_factor: 0.0180, effective_beta_factor: 0.0180 Epoch 10 - Valid Loss: 951.4543 Sub-losses: recon_loss: 950.7306, var_loss: 0.7237, anneal_factor: 0.0180, effective_beta_factor: 0.0180 Epoch 11 - Train Loss: 956.8427 Sub-losses: recon_loss: 955.2451, var_loss: 1.5976, anneal_factor: 0.0344, effective_beta_factor: 0.0344 Epoch 11 - Valid Loss: 941.5319 Sub-losses: recon_loss: 939.9884, var_loss: 1.5435, anneal_factor: 0.0344, effective_beta_factor: 0.0344 Epoch 12 - Train Loss: 955.6375 Sub-losses: recon_loss: 952.4723, var_loss: 3.1652, anneal_factor: 0.0650, effective_beta_factor: 0.0650 Epoch 12 - Valid Loss: 935.6899 Sub-losses: recon_loss: 932.8172, var_loss: 2.8727, anneal_factor: 0.0650, effective_beta_factor: 0.0650 Epoch 13 - Train Loss: 951.1653 Sub-losses: recon_loss: 945.4156, var_loss: 5.7497, anneal_factor: 0.1192, effective_beta_factor: 0.1192 Epoch 13 - Valid Loss: 930.1309 Sub-losses: recon_loss: 924.4477, var_loss: 5.6832, anneal_factor: 0.1192, effective_beta_factor: 0.1192 Epoch 14 - Train Loss: 947.8176 Sub-losses: recon_loss: 937.2625, var_loss: 10.5552, anneal_factor: 0.2086, effective_beta_factor: 0.2086 Epoch 14 - Valid Loss: 928.7065 Sub-losses: recon_loss: 918.8953, var_loss: 9.8112, anneal_factor: 0.2086, effective_beta_factor: 0.2086 Epoch 15 - Train Loss: 952.3984 Sub-losses: recon_loss: 936.3096, var_loss: 16.0888, anneal_factor: 0.3392, effective_beta_factor: 0.3392 Epoch 15 - Valid Loss: 929.8787 Sub-losses: recon_loss: 914.7768, var_loss: 15.1018, anneal_factor: 0.3392, effective_beta_factor: 0.3392 Epoch 16 - Train Loss: 949.2610 Sub-losses: recon_loss: 927.5621, var_loss: 21.6989, anneal_factor: 0.5000, effective_beta_factor: 0.5000 Epoch 16 - Valid Loss: 933.7573 Sub-losses: recon_loss: 913.9474, var_loss: 19.8100, anneal_factor: 0.5000, effective_beta_factor: 0.5000 Epoch 17 - Train Loss: 950.3796 Sub-losses: recon_loss: 924.5725, var_loss: 25.8071, anneal_factor: 0.6608, effective_beta_factor: 0.6608 Epoch 17 - Valid Loss: 928.1723 Sub-losses: recon_loss: 905.7023, var_loss: 22.4700, anneal_factor: 0.6608, effective_beta_factor: 0.6608 Epoch 18 - Train Loss: 951.6113 Sub-losses: recon_loss: 923.3481, var_loss: 28.2631, anneal_factor: 0.7914, effective_beta_factor: 0.7914 Epoch 18 - Valid Loss: 928.5229 Sub-losses: recon_loss: 903.8937, var_loss: 24.6293, anneal_factor: 0.7914, effective_beta_factor: 0.7914 Epoch 19 - Train Loss: 941.8345 Sub-losses: recon_loss: 913.8564, var_loss: 27.9781, anneal_factor: 0.8808, effective_beta_factor: 0.8808 Epoch 19 - Valid Loss: 926.0874 Sub-losses: recon_loss: 902.1671, var_loss: 23.9202, anneal_factor: 0.8808, effective_beta_factor: 0.8808 Epoch 20 - Train Loss: 940.5006 Sub-losses: recon_loss: 913.8868, var_loss: 26.6137, anneal_factor: 0.9350, effective_beta_factor: 0.9350 Epoch 20 - Valid Loss: 920.9032 Sub-losses: recon_loss: 897.3171, var_loss: 23.5861, anneal_factor: 0.9350, effective_beta_factor: 0.9350 Epoch 21 - Train Loss: 938.2790 Sub-losses: recon_loss: 913.3347, var_loss: 24.9443, anneal_factor: 0.9656, effective_beta_factor: 0.9656 Epoch 21 - Valid Loss: 918.9359 Sub-losses: recon_loss: 895.8992, var_loss: 23.0367, anneal_factor: 0.9656, effective_beta_factor: 0.9656 Epoch 22 - Train Loss: 929.9743 Sub-losses: recon_loss: 905.7796, var_loss: 24.1947, anneal_factor: 0.9820, effective_beta_factor: 0.9820 Epoch 22 - Valid Loss: 918.0283 Sub-losses: recon_loss: 895.6837, var_loss: 22.3446, anneal_factor: 0.9820, effective_beta_factor: 0.9820 Epoch 23 - Train Loss: 933.9519 Sub-losses: recon_loss: 910.1971, var_loss: 23.7548, anneal_factor: 0.9907, effective_beta_factor: 0.9907 Epoch 23 - Valid Loss: 911.7701 Sub-losses: recon_loss: 891.0258, var_loss: 20.7443, anneal_factor: 0.9907, effective_beta_factor: 0.9907 Epoch 24 - Train Loss: 926.4578 Sub-losses: recon_loss: 903.6484, var_loss: 22.8094, anneal_factor: 0.9952, effective_beta_factor: 0.9952 Epoch 24 - Valid Loss: 914.0869 Sub-losses: recon_loss: 893.2252, var_loss: 20.8617, anneal_factor: 0.9952, effective_beta_factor: 0.9952 Epoch 25 - Train Loss: 923.0073 Sub-losses: recon_loss: 900.3552, var_loss: 22.6521, anneal_factor: 0.9975, effective_beta_factor: 0.9975 Epoch 25 - Valid Loss: 905.8131 Sub-losses: recon_loss: 885.7856, var_loss: 20.0275, anneal_factor: 0.9975, effective_beta_factor: 0.9975 Epoch 26 - Train Loss: 920.1220 Sub-losses: recon_loss: 898.1062, var_loss: 22.0159, anneal_factor: 0.9987, effective_beta_factor: 0.9987 Epoch 26 - Valid Loss: 905.8649 Sub-losses: recon_loss: 884.6357, var_loss: 21.2292, anneal_factor: 0.9987, effective_beta_factor: 0.9987 Epoch 27 - Train Loss: 919.9186 Sub-losses: recon_loss: 898.6025, var_loss: 21.3161, anneal_factor: 0.9993, effective_beta_factor: 0.9993 Epoch 27 - Valid Loss: 905.4550 Sub-losses: recon_loss: 885.2871, var_loss: 20.1680, anneal_factor: 0.9993, effective_beta_factor: 0.9993 Epoch 28 - Train Loss: 913.9538 Sub-losses: recon_loss: 891.5910, var_loss: 22.3627, anneal_factor: 0.9997, effective_beta_factor: 0.9997 Epoch 28 - Valid Loss: 896.2276 Sub-losses: recon_loss: 876.1357, var_loss: 20.0919, anneal_factor: 0.9997, effective_beta_factor: 0.9997 Epoch 29 - Train Loss: 918.2080 Sub-losses: recon_loss: 897.0868, var_loss: 21.1212, anneal_factor: 0.9998, effective_beta_factor: 0.9998 Epoch 29 - Valid Loss: 895.7843 Sub-losses: recon_loss: 875.7118, var_loss: 20.0725, anneal_factor: 0.9998, effective_beta_factor: 0.9998 Epoch 30 - Train Loss: 910.1649 Sub-losses: recon_loss: 889.1332, var_loss: 21.0318, anneal_factor: 0.9999, effective_beta_factor: 0.9999 Epoch 30 - Valid Loss: 897.4055 Sub-losses: recon_loss: 877.5325, var_loss: 19.8730, anneal_factor: 0.9999, effective_beta_factor: 0.9999
ontix.save(file_path="ontix_backup.pkl")
Preprocessor saved successfully. saving memory efficient Ontix checks: All possible feature names length: 30 Feature order length: 30 Feature names without filtering: 30 Mask layer 0 with shape torch.Size([3, 3]) and 5.0 connections Mask layer 1 with shape torch.Size([30, 3]) and 30.0 connections Latent Dim: 3 Pipeline object saved successfully.
ontix_loaded = acx.Ontix(ontologies=ont_files).load(file_path="ontix_backup.pkl")
Attempting to load a pipeline from ./ontix_backup.pkl... Pipeline object loaded successfully. Actual type: Ontix Preprocessor loaded successfully.
pred_res = ontix_loaded.predict(EXAMPLE_PROCESSED_DATA)
ontix_loaded.visualize()
ontix_loaded.evaluate(params=["cluster"])
Perform ML task with feature df: Latent Latent Perform ML task for target parameter: cluster Perform ML task with feature df: Latent Latent Perform ML task for target parameter: cluster
Result Object Public Attributes:
------------------------------
latentspaces: TrainingDynamics object
sample_ids: TrainingDynamics object
reconstructions: TrainingDynamics object
mus: TrainingDynamics object
sigmas: TrainingDynamics object
losses: TrainingDynamics object
sub_losses: LossRegistry(_losses={})
preprocessed_data: Tensor of shape (0,)
model: OntixArchitecture
model_checkpoints: TrainingDynamics object
datasets: DatasetContainer(train=None, valid=None, test=None)
new_datasets: DatasetContainer(train=<autoencodix.data._numeric_dataset.NumericDataset object at 0x30eb85ab0>, valid=<autoencodix.data._numeric_dataset.NumericDataset object at 0x30e8bf8b0>, test=<autoencodix.data._numeric_dataset.NumericDataset object at 0x30e8bf670>)
adata_latent: AnnData object with n_obs × n_vars = 201 × 3
uns: 'var_names'
final_reconstruction: None
sub_results: None
sub_reconstructions: None
embedding_evaluation: cv_run score_split CLINIC_PARAM metric value \
0 CV_1 test cluster roc_auc_ovo 0.967187
1 CV_2 test cluster roc_auc_ovo 0.978906
2 CV_3 test cluster roc_auc_ovo 0.989062
3 CV_4 test cluster roc_auc_ovo 0.976562
4 CV_5 test cluster roc_auc_ovo 0.951562
5 CV_1 train cluster roc_auc_ovo 0.975391
6 CV_2 train cluster roc_auc_ovo 0.973736
7 CV_3 train cluster roc_auc_ovo 0.971341
8 CV_4 train cluster roc_auc_ovo 0.972955
9 CV_5 train cluster roc_auc_ovo 0.980029
0 CV_1 test cluster roc_auc_ovo 0.967187
1 CV_2 test cluster roc_auc_ovo 0.978906
2 CV_3 test cluster roc_auc_ovo 0.989062
3 CV_4 test cluster roc_auc_ovo 0.976562
4 CV_5 test cluster roc_auc_ovo 0.951562
5 CV_1 train cluster roc_auc_ovo 0.975391
6 CV_2 train cluster roc_auc_ovo 0.973736
7 CV_3 train cluster roc_auc_ovo 0.971341
8 CV_4 train cluster roc_auc_ovo 0.972955
9 CV_5 train cluster roc_auc_ovo 0.980029
ML_ALG ML_TYPE ML_TASK ML_SUBTASK
0 LogisticRegression() classification Latent Latent
1 LogisticRegression() classification Latent Latent
2 LogisticRegression() classification Latent Latent
3 LogisticRegression() classification Latent Latent
4 LogisticRegression() classification Latent Latent
5 LogisticRegression() classification Latent Latent
6 LogisticRegression() classification Latent Latent
7 LogisticRegression() classification Latent Latent
8 LogisticRegression() classification Latent Latent
9 LogisticRegression() classification Latent Latent
0 LogisticRegression() classification Latent Latent
1 LogisticRegression() classification Latent Latent
2 LogisticRegression() classification Latent Latent
3 LogisticRegression() classification Latent Latent
4 LogisticRegression() classification Latent Latent
5 LogisticRegression() classification Latent Latent
6 LogisticRegression() classification Latent Latent
7 LogisticRegression() classification Latent Latent
8 LogisticRegression() classification Latent Latent
9 LogisticRegression() classification Latent Latent
embedding_attributions: Empty DataFrame
Columns: []
Index: []
embedding_explanations: Dict with 0 items
ontix_loaded.show_result()
Creating plots ...
<Figure size 0x500 with 0 Axes>