altoslabs / perturbench

Other
12 stars 0 forks source link

How to use the models you proposed? #4

Open liaowenyu opened 6 days ago

liaowenyu commented 6 days ago

Hi, could you give me a tutorial on how to use your proposed models to predict gene expression?

yanwu2014 commented 3 days ago

Hi there! So we have some usage instructions but in short, you can train a specific model on a specific dataset using the train command. For example to train a linear model on the norman19 dataset, use the command train experiment=neurips2024/linear_best_params_norman19. To use a different model or a different dataset, switch out the experiment config (you can see a list of available configs here). This will automatically evaluate your model on the val split at the end of training as well.

To generate predictions on a pretrained model, you can use the predict command, we'll try and add an example experiment config for predictions soon. But for now it'll look something like this:

# @package _global_

# specify here default configuration
# order of defaults determines the order in which configs override each other
defaults:
  - override /data: norman19 ## Specify data config
  - model /model: linear ## Specify model config

# Provide checkpoint path to a trained linear model
ckpt_path: ???

# You need to include the exact model hparams used during training
model:
  inject_covariates: false
  lr: 0.004716813309487752
  wd: 1.7588044643755207e-08

# task name, determines output directory path
task_name: "predict"

# Path to prediction dataframe (generate with notebooks/demos/generate_prediction_dataframe)
prediction_dataframe_path: ???

# seed for random number generators in pytorch, numpy and python.random
seed: null

# Path to save predictions
output_path: "${paths.output_dir}/predictions/"

# Number of perturbations to generate in memory at once
chunk_size: 50

If you save this config in the src/configs/experiments directory as something like linear_model_predict.yaml you can generate predictions with the command predict experiment=linear_model_predict.

Let me know if that helps answer your question?

liaowenyu commented 1 day ago

could you give me a tutorial on jupyter, so that I can easily visualize the results