{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":59094,"databundleVersionId":7010844,"sourceType":"competition"},{"sourceId":7631230,"sourceType":"datasetVersion","datasetId":4441094}],"dockerImageVersionId":30646,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/working'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n        \n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-02-21T17:07:18.393593Z","iopub.execute_input":"2024-02-21T17:07:18.393967Z","iopub.status.idle":"2024-02-21T17:07:18.407465Z","shell.execute_reply.started":"2024-02-21T17:07:18.393937Z","shell.execute_reply":"2024-02-21T17:07:18.406495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!git clone https://github.com/Eliorkalfon/single_cell_pb","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:18.409475Z","iopub.execute_input":"2024-02-21T17:07:18.409871Z","iopub.status.idle":"2024-02-21T17:07:19.362743Z","shell.execute_reply.started":"2024-02-21T17:07:18.409842Z","shell.execute_reply":"2024-02-21T17:07:19.361639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls ./single_cell_pb/\nprint()\n!head ./single_cell_pb/requirements.txt","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:19.364209Z","iopub.execute_input":"2024-02-21T17:07:19.364528Z","iopub.status.idle":"2024-02-21T17:07:21.259844Z","shell.execute_reply.started":"2024-02-21T17:07:19.364499Z","shell.execute_reply":"2024-02-21T17:07:21.258776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install -r  ./single_cell_pb/requirements.txt","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:21.263144Z","iopub.execute_input":"2024-02-21T17:07:21.263930Z","iopub.status.idle":"2024-02-21T17:07:23.056020Z","shell.execute_reply.started":"2024-02-21T17:07:21.263898Z","shell.execute_reply":"2024-02-21T17:07:23.055066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install lion-pytorch","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:23.057834Z","iopub.execute_input":"2024-02-21T17:07:23.058170Z","iopub.status.idle":"2024-02-21T17:07:35.232448Z","shell.execute_reply.started":"2024-02-21T17:07:23.058140Z","shell.execute_reply":"2024-02-21T17:07:35.231275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!cp ./single_cell_pb/config_train.yaml ./single_cell_pb/config_train_old.yaml","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:35.234383Z","iopub.execute_input":"2024-02-21T17:07:35.234721Z","iopub.status.idle":"2024-02-21T17:07:36.284788Z","shell.execute_reply.started":"2024-02-21T17:07:35.234674Z","shell.execute_reply":"2024-02-21T17:07:36.283517Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"str_config_train = '''n_components_list: # targets dimension list\n  - 18211\nd_models_list:\n  - 128\nbatch_size: 32\nsampling_strategy: k-means  # Choose either 'k-means' or 'random'\ndata_file: '/kaggle/input/open-problems-single-cell-perturbations/de_train.parquet'\nid_map_file: '/kaggle/input/open-problems-single-cell-perturbations/id_map.csv'\nvalidation_percentage: 0.1\ndevice: cuda\nseed: null\nnum_epochs: 2\nearly_stopping: 5000'''\n# num_epochs: 20000\n\n# Open a file for writing (creates a new file or overwrites existing)\nwith open('./single_cell_pb/config_train.yaml', 'w') as file:\n    file.write(str_config_train)\n","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:36.286436Z","iopub.execute_input":"2024-02-21T17:07:36.286800Z","iopub.status.idle":"2024-02-21T17:07:36.292696Z","shell.execute_reply.started":"2024-02-21T17:07:36.286755Z","shell.execute_reply":"2024-02-21T17:07:36.291748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n# !cd single_cell_pb\n!python ./single_cell_pb/train.py --config ./single_cell_pb/config_train.yaml","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:07:36.293827Z","iopub.execute_input":"2024-02-21T17:07:36.294095Z","iopub.status.idle":"2024-02-21T17:08:52.385684Z","shell.execute_reply.started":"2024-02-21T17:07:36.294073Z","shell.execute_reply":"2024-02-21T17:08:52.384622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import torch\ntorch.__version__","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:25:56.521940Z","iopub.execute_input":"2024-02-21T17:25:56.522691Z","iopub.status.idle":"2024-02-21T17:25:58.268679Z","shell.execute_reply.started":"2024-02-21T17:25:56.522659Z","shell.execute_reply":"2024-02-21T17:25:58.267652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n!cp ./single_cell_pb/config_test.yaml ./single_cell_pb/config_test_old.yaml\n\nstr_config_test = \"\"\"\nn_components_list: # targets dimension list\n  - 18211\nd_models_list:\n  - 128\nbatch_size: 32\ndata_file: '/kaggle/input/open-problems-single-cell-perturbations/de_train.parquet'\nid_map_file: '/kaggle/input/open-problems-single-cell-perturbations/id_map.csv'\ndevice: cuda\nseed: null\nmodels_dir: '/kaggle/working/trained_models_random/'\"\"\"\n## ??? models_dir: '/kaggle/working/trained_models_random/' \n\n# Open a file for writing (creates a new file or overwrites existing)\nwith open('./single_cell_pb/config_test.yaml', 'w') as file:\n    file.write(str_config_test)\n","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:37:12.138128Z","iopub.execute_input":"2024-02-21T17:37:12.139306Z","iopub.status.idle":"2024-02-21T17:37:13.134136Z","shell.execute_reply.started":"2024-02-21T17:37:12.139272Z","shell.execute_reply":"2024-02-21T17:37:13.132943Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python ./single_cell_pb/predict.py --config ./single_cell_pb/config_test.yaml","metadata":{"execution":{"iopub.status.busy":"2024-02-21T17:38:31.064572Z","iopub.execute_input":"2024-02-21T17:38:31.065605Z","iopub.status.idle":"2024-02-21T17:39:29.808205Z","shell.execute_reply.started":"2024-02-21T17:38:31.065565Z","shell.execute_reply":"2024-02-21T17:39:29.806999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}