{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":51294,"databundleVersionId":6923401,"sourceType":"competition"},{"sourceId":153573875,"sourceType":"kernelVersion"},{"sourceId":153585275,"sourceType":"kernelVersion"}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"https://www.kaggle.com/code/mirenaborisova/srrnaf-5?scriptVersionId=153573875","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"markdown","source":"https://www.kaggle.com/code/jordanyoung993/cnn-submission/notebook","metadata":{}},{"cell_type":"code","source":"import warnings\nwarnings.simplefilter('ignore')\n\nimport pandas as pd\npd.set_option('display.max_columns', 30)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:08:55.882305Z","iopub.execute_input":"2023-12-04T17:08:55.882677Z","iopub.status.idle":"2023-12-04T17:08:56.331336Z","shell.execute_reply.started":"2023-12-04T17:08:55.882650Z","shell.execute_reply":"2023-12-04T17:08:56.330450Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences = pd.read_csv('/kaggle/input/stanford-ribonanza-rna-folding/test_sequences.csv')\n# test_sequences","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:08:56.332815Z","iopub.execute_input":"2023-12-04T17:08:56.333597Z","iopub.status.idle":"2023-12-04T17:09:04.781217Z","shell.execute_reply.started":"2023-12-04T17:08:56.333565Z","shell.execute_reply":"2023-12-04T17:09:04.780285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\n\nTEMP_DIR = '/kaggle/temp'\n\nif not os.path.isdir(TEMP_DIR):\n    \n    os.mkdir(TEMP_DIR)\n    \nos.listdir('/kaggle')","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:04.783146Z","iopub.execute_input":"2023-12-04T17:09:04.784023Z","iopub.status.idle":"2023-12-04T17:09:04.795294Z","shell.execute_reply.started":"2023-12-04T17:09:04.783981Z","shell.execute_reply":"2023-12-04T17:09:04.793945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"experiment_types = ['2a3_MaP', 'DMS_MaP', 'test']\n\nfor experiment_type in experiment_types:\n    \n    exptype_dir = os.path.join(TEMP_DIR, experiment_type)\n    \n    if not os.path.isdir(exptype_dir):\n        \n        os.mkdir(exptype_dir)\nos.listdir(TEMP_DIR)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:04.798889Z","iopub.execute_input":"2023-12-04T17:09:04.799401Z","iopub.status.idle":"2023-12-04T17:09:04.811168Z","shell.execute_reply.started":"2023-12-04T17:09:04.799333Z","shell.execute_reply":"2023-12-04T17:09:04.809876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def pad_sequence(sequence, max_length=457, padding_value=\"Z\"):\n    \n    padding_length = max_length - len(sequence)\n    \n    padded_sequence = list(sequence) + [padding_value] * padding_length\n    \n    return padded_sequence\n","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:04.812960Z","iopub.execute_input":"2023-12-04T17:09:04.813309Z","iopub.status.idle":"2023-12-04T17:09:04.821655Z","shell.execute_reply.started":"2023-12-04T17:09:04.813280Z","shell.execute_reply":"2023-12-04T17:09:04.820481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gc\n\ntest_sequences['sequence'] = test_sequences['sequence'].apply(pad_sequence)\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:04.823057Z","iopub.execute_input":"2023-12-04T17:09:04.824370Z","iopub.status.idle":"2023-12-04T17:09:40.072854Z","shell.execute_reply.started":"2023-12-04T17:09:04.824336Z","shell.execute_reply":"2023-12-04T17:09:40.071767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def dummy_labels(df):\n    \n    reactivity_feats = [f\"reactivity_{i}\" for i in range(457)]\n    labels = [[0 for i in range(457)] for i in range(df.shape[0])]\n    df[reactivity_feats] = pd.DataFrame(labels, index= df.index)\n    \n    return df, reactivity_feats","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:40.074723Z","iopub.execute_input":"2023-12-04T17:09:40.075138Z","iopub.status.idle":"2023-12-04T17:09:40.081689Z","shell.execute_reply.started":"2023-12-04T17:09:40.075100Z","shell.execute_reply":"2023-12-04T17:09:40.080709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences, reactivity_feats = dummy_labels(test_sequences)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:09:40.083231Z","iopub.execute_input":"2023-12-04T17:09:40.083570Z","iopub.status.idle":"2023-12-04T17:17:50.079159Z","shell.execute_reply.started":"2023-12-04T17:09:40.083544Z","shell.execute_reply":"2023-12-04T17:17:50.077266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# test_sequences","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:17:50.082092Z","iopub.execute_input":"2023-12-04T17:17:50.082482Z","iopub.status.idle":"2023-12-04T17:17:50.088228Z","shell.execute_reply.started":"2023-12-04T17:17:50.082439Z","shell.execute_reply":"2023-12-04T17:17:50.087268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def png_path(seq_id, experiment):\n    \n    return os.path.join(TEMP_DIR,experiment,f\"{seq_id}.png\")","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:17:50.092967Z","iopub.execute_input":"2023-12-04T17:17:50.094110Z","iopub.status.idle":"2023-12-04T17:17:50.107859Z","shell.execute_reply.started":"2023-12-04T17:17:50.094076Z","shell.execute_reply":"2023-12-04T17:17:50.106804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences['png_path'] = test_sequences['sequence_id'].apply(png_path, args = ('test',))","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:17:50.109907Z","iopub.execute_input":"2023-12-04T17:17:50.110775Z","iopub.status.idle":"2023-12-04T17:17:55.149724Z","shell.execute_reply.started":"2023-12-04T17:17:50.110734Z","shell.execute_reply":"2023-12-04T17:17:55.148631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# test_sequences","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:17:55.151313Z","iopub.execute_input":"2023-12-04T17:17:55.151687Z","iopub.status.idle":"2023-12-04T17:17:55.156303Z","shell.execute_reply.started":"2023-12-04T17:17:55.151660Z","shell.execute_reply":"2023-12-04T17:17:55.154933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sequences = test_sequences[['sequence', 'png_path']].values.tolist()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:17:55.157470Z","iopub.execute_input":"2023-12-04T17:17:55.157821Z","iopub.status.idle":"2023-12-04T17:18:07.353356Z","shell.execute_reply.started":"2023-12-04T17:17:55.157789Z","shell.execute_reply":"2023-12-04T17:18:07.352027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nitrogenous_bases = {'A': [1, 0, 0, 0, 0],\n                     'C': [0, 1, 0, 0, 0],\n                     'G': [0, 0, 1, 0, 0],\n                     'U': [0, 0, 0, 1, 0],\n                     'Z': [0, 0, 0, 0, 1]}","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:18:07.354876Z","iopub.execute_input":"2023-12-04T17:18:07.355250Z","iopub.status.idle":"2023-12-04T17:18:07.362050Z","shell.execute_reply.started":"2023-12-04T17:18:07.355206Z","shell.execute_reply":"2023-12-04T17:18:07.360924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nfrom PIL import Image\n\nfor sequence, path in sequences:\n    \n    sequence = pad_sequence(sequence)\n    letters_to_int8 = np.array([nitrogenous_bases[letter] for letter in sequence]).astype(np.uint8)\n    img = Image.fromarray(letters_to_int8)\n    img.save(path)\n    \n    del sequence","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:18:07.363375Z","iopub.execute_input":"2023-12-04T17:18:07.363681Z","iopub.status.idle":"2023-12-04T17:37:32.301732Z","shell.execute_reply.started":"2023-12-04T17:18:07.363655Z","shell.execute_reply":"2023-12-04T17:37:32.300641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import matplotlib.pyplot as plt\n\n# plt.imshow(letters_to_int8)\n# plt.xlim((0, 5))\n# plt.ylim((0, 10))","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:37:32.303357Z","iopub.execute_input":"2023-12-04T17:37:32.303796Z","iopub.status.idle":"2023-12-04T17:37:32.309665Z","shell.execute_reply.started":"2023-12-04T17:37:32.303767Z","shell.execute_reply":"2023-12-04T17:37:32.308309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del sequences\ndel letters_to_int8\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:37:32.311290Z","iopub.execute_input":"2023-12-04T17:37:32.312472Z","iopub.status.idle":"2023-12-04T17:37:36.446674Z","shell.execute_reply.started":"2023-12-04T17:37:32.312353Z","shell.execute_reply":"2023-12-04T17:37:36.445335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\n\ndatagen = tf.keras.preprocessing.image.ImageDataGenerator()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:37:36.448540Z","iopub.execute_input":"2023-12-04T17:37:36.448971Z","iopub.status.idle":"2023-12-04T17:37:49.597866Z","shell.execute_reply.started":"2023-12-04T17:37:36.448931Z","shell.execute_reply":"2023-12-04T17:37:49.596609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_generator = datagen.flow_from_dataframe(directory=None,\n                                             dataframe=test_sequences,\n                                             x_col='png_path',\n                                             y_col=reactivity_feats,\n                                             target_size=(457, 5),\n                                             batch_size=32,\n                                             seed=42,\n                                             shuffle=False,\n                                             class_mode=None)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:37:49.599533Z","iopub.execute_input":"2023-12-04T17:37:49.600521Z","iopub.status.idle":"2023-12-04T17:38:50.631413Z","shell.execute_reply.started":"2023-12-04T17:37:49.600477Z","shell.execute_reply":"2023-12-04T17:38:50.630305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"LEARNING_RATE = 1e-3\n\ndef get_model():\n    \n    model = tf.keras.Sequential([\n        tf.keras.layers.Conv2D(2,(2,2), activation='relu'),\n        tf.keras.layers.MaxPooling2D(pool_size=(2,2)),\n\n        tf.keras.layers.Flatten(),\n        tf.keras.layers.Dropout(0.3),\n        tf.keras.layers.Dense(457, activation='relu'),\n        tf.keras.layers.Dropout(0.3),\n        tf.keras.layers.Dense(457, activation='relu'),\n        tf.keras.layers.Dropout(0.3),\n        tf.keras.layers.Dense(457, activation='sigmoid')\n        \n    ])\n    \n    model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=LEARNING_RATE),\n            loss=tf.keras.losses.MeanSquaredError(),\n            )\n\n    return model","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:38:50.633272Z","iopub.execute_input":"2023-12-04T17:38:50.633879Z","iopub.status.idle":"2023-12-04T17:38:50.647588Z","shell.execute_reply.started":"2023-12-04T17:38:50.633832Z","shell.execute_reply":"2023-12-04T17:38:50.646474Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_2A3 = get_model()\nmodel_2A3.load_weights('/kaggle/input/srrnaf-5/checkpoints/2a3_model')","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:38:50.649681Z","iopub.execute_input":"2023-12-04T17:38:50.650146Z","iopub.status.idle":"2023-12-04T17:38:51.078640Z","shell.execute_reply.started":"2023-12-04T17:38:50.650103Z","shell.execute_reply":"2023-12-04T17:38:51.077276Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_DMS = get_model()\nmodel_DMS.load_weights('/kaggle/input/srrnaf-6/checkpoints/DMS_model')","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:38:51.081192Z","iopub.execute_input":"2023-12-04T17:38:51.082310Z","iopub.status.idle":"2023-12-04T17:38:51.151707Z","shell.execute_reply.started":"2023-12-04T17:38:51.082263Z","shell.execute_reply":"2023-12-04T17:38:51.150535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_generator.reset()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:38:51.153348Z","iopub.execute_input":"2023-12-04T17:38:51.154525Z","iopub.status.idle":"2023-12-04T17:38:51.159412Z","shell.execute_reply.started":"2023-12-04T17:38:51.154483Z","shell.execute_reply":"2023-12-04T17:38:51.158597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_2A3 = model_2A3.predict(test_generator)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:38:51.160718Z","iopub.execute_input":"2023-12-04T17:38:51.161408Z","iopub.status.idle":"2023-12-04T17:52:39.356672Z","shell.execute_reply.started":"2023-12-04T17:38:51.161376Z","shell.execute_reply":"2023-12-04T17:52:39.355399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_generator.reset()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:52:39.360315Z","iopub.execute_input":"2023-12-04T17:52:39.360770Z","iopub.status.idle":"2023-12-04T17:52:39.366768Z","shell.execute_reply.started":"2023-12-04T17:52:39.360729Z","shell.execute_reply":"2023-12-04T17:52:39.365712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_DMS = model_DMS.predict(test_generator)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T17:52:39.368399Z","iopub.execute_input":"2023-12-04T17:52:39.369078Z","iopub.status.idle":"2023-12-04T18:06:16.958500Z","shell.execute_reply.started":"2023-12-04T17:52:39.369041Z","shell.execute_reply":"2023-12-04T18:06:16.957146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences = test_sequences[['id_min', 'id_max']]","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:16.965183Z","iopub.execute_input":"2023-12-04T18:06:16.965603Z","iopub.status.idle":"2023-12-04T18:06:21.193634Z","shell.execute_reply.started":"2023-12-04T18:06:16.965568Z","shell.execute_reply":"2023-12-04T18:06:21.192606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences.head(2)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:21.201354Z","iopub.execute_input":"2023-12-04T18:06:21.201752Z","iopub.status.idle":"2023-12-04T18:06:21.219518Z","shell.execute_reply.started":"2023-12-04T18:06:21.201719Z","shell.execute_reply":"2023-12-04T18:06:21.218377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences['n'] = test_sequences['id_max'] - test_sequences['id_min']","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:21.220945Z","iopub.execute_input":"2023-12-04T18:06:21.221399Z","iopub.status.idle":"2023-12-04T18:06:21.234689Z","shell.execute_reply.started":"2023-12-04T18:06:21.221361Z","shell.execute_reply":"2023-12-04T18:06:21.233461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences = test_sequences['n']","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:21.236508Z","iopub.execute_input":"2023-12-04T18:06:21.236963Z","iopub.status.idle":"2023-12-04T18:06:21.243329Z","shell.execute_reply.started":"2023-12-04T18:06:21.236925Z","shell.execute_reply":"2023-12-04T18:06:21.242123Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_sequences = test_sequences.tolist()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:21.244747Z","iopub.execute_input":"2023-12-04T18:06:21.245155Z","iopub.status.idle":"2023-12-04T18:06:21.284498Z","shell.execute_reply.started":"2023-12-04T18:06:21.245118Z","shell.execute_reply":"2023-12-04T18:06:21.283304Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i, j in enumerate(test_sequences):\n    \n    np.put(preds_2A3[i], list(range(j + 1, 457)), [np.nan])\n    np.put(preds_DMS[i], list(range(j + 1, 457)), [np.nan])    ","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:06:21.286572Z","iopub.execute_input":"2023-12-04T18:06:21.287021Z","iopub.status.idle":"2023-12-04T18:08:01.184922Z","shell.execute_reply.started":"2023-12-04T18:06:21.286978Z","shell.execute_reply":"2023-12-04T18:08:01.183667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_2A3 = preds_2A3.flatten()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:01.186612Z","iopub.execute_input":"2023-12-04T18:08:01.187061Z","iopub.status.idle":"2023-12-04T18:08:03.530004Z","shell.execute_reply.started":"2023-12-04T18:08:01.187020Z","shell.execute_reply":"2023-12-04T18:08:03.528427Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_2A3 = preds_2A3[~np.isnan(preds_2A3)]","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:03.532431Z","iopub.execute_input":"2023-12-04T18:08:03.532967Z","iopub.status.idle":"2023-12-04T18:08:05.021976Z","shell.execute_reply.started":"2023-12-04T18:08:03.532919Z","shell.execute_reply":"2023-12-04T18:08:05.021117Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_DMS = preds_DMS.flatten()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:05.023525Z","iopub.execute_input":"2023-12-04T18:08:05.024453Z","iopub.status.idle":"2023-12-04T18:08:05.838353Z","shell.execute_reply.started":"2023-12-04T18:08:05.024419Z","shell.execute_reply":"2023-12-04T18:08:05.837392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_DMS = preds_DMS[~np.isnan(preds_DMS)]","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:05.840059Z","iopub.execute_input":"2023-12-04T18:08:05.840742Z","iopub.status.idle":"2023-12-04T18:08:07.402959Z","shell.execute_reply.started":"2023-12-04T18:08:05.840696Z","shell.execute_reply":"2023-12-04T18:08:07.401827Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del test_generator\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:07.404217Z","iopub.execute_input":"2023-12-04T18:08:07.404579Z","iopub.status.idle":"2023-12-04T18:08:07.770087Z","shell.execute_reply.started":"2023-12-04T18:08:07.404542Z","shell.execute_reply":"2023-12-04T18:08:07.768977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_2A3.shape","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:07.771624Z","iopub.execute_input":"2023-12-04T18:08:07.772190Z","iopub.status.idle":"2023-12-04T18:08:07.785152Z","shell.execute_reply.started":"2023-12-04T18:08:07.772159Z","shell.execute_reply":"2023-12-04T18:08:07.783802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_DMS.shape","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:07.786972Z","iopub.execute_input":"2023-12-04T18:08:07.787372Z","iopub.status.idle":"2023-12-04T18:08:07.795361Z","shell.execute_reply.started":"2023-12-04T18:08:07.787341Z","shell.execute_reply":"2023-12-04T18:08:07.794421Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ids = np.arange(preds_DMS.shape[0], dtype=np.int64)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:07.796922Z","iopub.execute_input":"2023-12-04T18:08:07.797493Z","iopub.status.idle":"2023-12-04T18:08:08.046301Z","shell.execute_reply.started":"2023-12-04T18:08:07.797462Z","shell.execute_reply":"2023-12-04T18:08:08.045090Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import polars as pl\n\nschema = {k:pl.Float32 for k in ['id', 'reactivity_DMS_MaP', 'reactivity_2A3_MaP']}","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:08.047720Z","iopub.execute_input":"2023-12-04T18:08:08.048118Z","iopub.status.idle":"2023-12-04T18:08:08.304640Z","shell.execute_reply.started":"2023-12-04T18:08:08.048086Z","shell.execute_reply":"2023-12-04T18:08:08.303467Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"schema['id'] = pl.Int64","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:08.306073Z","iopub.execute_input":"2023-12-04T18:08:08.306441Z","iopub.status.idle":"2023-12-04T18:08:08.311428Z","shell.execute_reply.started":"2023-12-04T18:08:08.306412Z","shell.execute_reply":"2023-12-04T18:08:08.310302Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_path = './submission.csv'","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:08.313180Z","iopub.execute_input":"2023-12-04T18:08:08.313572Z","iopub.status.idle":"2023-12-04T18:08:08.320389Z","shell.execute_reply.started":"2023-12-04T18:08:08.313519Z","shell.execute_reply":"2023-12-04T18:08:08.319283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pl.DataFrame(data=[ids, preds_DMS, preds_2A3],\n                  schema=schema)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:08.321498Z","iopub.execute_input":"2023-12-04T18:08:08.321782Z","iopub.status.idle":"2023-12-04T18:08:14.431794Z","shell.execute_reply.started":"2023-12-04T18:08:08.321757Z","shell.execute_reply":"2023-12-04T18:08:14.430759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.write_csv(sub_path, float_precision=4)","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:08:14.433351Z","iopub.execute_input":"2023-12-04T18:08:14.433803Z","iopub.status.idle":"2023-12-04T18:10:43.158839Z","shell.execute_reply.started":"2023-12-04T18:08:14.433761Z","shell.execute_reply":"2023-12-04T18:10:43.157589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2023-12-04T18:10:43.160484Z","iopub.execute_input":"2023-12-04T18:10:43.160847Z","iopub.status.idle":"2023-12-04T18:10:43.169529Z","shell.execute_reply.started":"2023-12-04T18:10:43.160817Z","shell.execute_reply":"2023-12-04T18:10:43.168046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}