{"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":87793,"databundleVersionId":11228175,"sourceType":"competition"}],"dockerImageVersionId":30918,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-03-04T15:59:07.576916Z","iopub.execute_input":"2025-03-04T15:59:07.577381Z","iopub.status.idle":"2025-03-04T15:59:07.586995Z","shell.execute_reply.started":"2025-03-04T15:59:07.577352Z","shell.execute_reply":"2025-03-04T15:59:07.585418Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nimport torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import Dataset, DataLoader","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-04T15:59:07.588594Z","iopub.execute_input":"2025-03-04T15:59:07.588897Z","iopub.status.idle":"2025-03-04T15:59:07.603768Z","shell.execute_reply.started":"2025-03-04T15:59:07.588873Z","shell.execute_reply":"2025-03-04T15:59:07.602532Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Loading the datasets\n\ndef load_data():\n    train_sequences = pd.read_csv('/kaggle/input/stanford-rna-3d-folding/train_sequences.csv')\n    train_labels = pd.read_csv('/kaggle/input/stanford-rna-3d-folding/train_labels.csv')\n    validation_sequences = pd.read_csv(\"/kaggle/input/stanford-rna-3d-folding/validation_sequences.csv\")\n    validation_labels = pd.read_csv(\"/kaggle/input/stanford-rna-3d-folding/validation_labels.csv\")\n    test_sequences = pd.read_csv(\"/kaggle/input/stanford-rna-3d-folding/test_sequences.csv\")\n    sample_submission = pd.read_csv(\"/kaggle/input/stanford-rna-3d-folding/sample_submission.csv\")\n    return train_sequences, train_labels, validation_sequences, validation_labels, test_sequences, sample_submission\n\ntrain_sequences, train_labels, validation_sequences, validation_labels, test_sequences, sample_submission = load_data()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-04T15:59:07.605612Z","iopub.execute_input":"2025-03-04T15:59:07.605978Z","iopub.status.idle":"2025-03-04T15:59:07.913871Z","shell.execute_reply.started":"2025-03-04T15:59:07.605938Z","shell.execute_reply":"2025-03-04T15:59:07.912785Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-04T15:59:45.125078Z","iopub.execute_input":"2025-03-04T15:59:45.125620Z","iopub.status.idle":"2025-03-04T15:59:45.973424Z","shell.execute_reply.started":"2025-03-04T15:59:45.125583Z","shell.execute_reply":"2025-03-04T15:59:45.970800Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Data Exploration\n\ndef explore_data():\n    print(\"Train Sequences Head:\")\n    print(train_sequences.head())\n    print(\"\\nTrain Labels Head:\")\n    print(train_labels.head())\n    print(\"\\nValidation Sequences Head:\")\n    print(validation_sequences.head())\n    print(\"\\nValidation Labels Head:\")\n    print(validation_labels.head())\n    print(\"\\nTest Sequences Head:\")\n    print(test_sequences.head())\n    print(\"\\nTrain Sequences Info:\")\n    print(train_sequences.info())\n    print(\"\\nTrain Labels Info:\")\n    print(train_labels.info())\n    print(\"\\nMissing Values in Train Sequences:\")\n    print(train_sequences.isnull().sum())\n    print(\"\\nMissing Values in Train Labels:\")\n    print(train_labels.isnull().sum())    \n    \n    # Sequence Length Distribution\n    train_sequences[\"sequence_length\"] = train_sequences[\"sequence\"].apply(len)\n    validation_sequences[\"sequence_length\"] = validation_sequences[\"sequence\"].apply(len)\n    \n    plt.figure(figsize=(10, 5))\n    sns.histplot(train_sequences[\"sequence_length\"], bins=50, kde=True, label=\"Train Sequences\", color='blue')\n    sns.histplot(validation_sequences[\"sequence_length\"], bins=50, kde=True, label=\"Validation Sequences\", color='orange')\n    plt.xlabel(\"Sequence Length\")\n    plt.ylabel(\"Count\")\n    plt.title(\"Distribution of RNA Sequence Lengths\")\n    plt.legend()\n    plt.show()\n\ntest_sequences[\"sequence_length\"] = test_sequences[\"sequence\"].apply(len)\n\nexplore_data()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-04T15:59:49.627410Z","iopub.execute_input":"2025-03-04T15:59:49.628059Z","iopub.status.idle":"2025-03-04T15:59:50.309328Z","shell.execute_reply.started":"2025-03-04T15:59:49.628025Z","shell.execute_reply":"2025-03-04T15:59:50.308287Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"**FEATURE ENGINEERING**","metadata":{}},{"cell_type":"code","source":"def encode_sequence(sequence):\n    mapping = {\"A\": 0, \"U\": 1, \"C\": 2, \"G\": 3}\n    return [mapping[char] if char in mapping else -1 for char in sequence] \n\ntrain_sequences[\"encoded_sequence\"] = train_sequences[\"sequence\"].apply(encode_sequence)\nvalidation_sequences[\"encoded_sequence\"] = validation_sequences[\"sequence\"].apply(encode_sequence)\ntest_sequences[\"encoded_sequence\"] = test_sequences[\"sequence\"].apply(encode_sequence)\n    ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-04T16:03:57.879575Z","iopub.execute_input":"2025-03-04T16:03:57.880010Z","iopub.status.idle":"2025-03-04T16:03:57.905169Z","shell.execute_reply.started":"2025-03-04T16:03:57.879977Z","shell.execute_reply":"2025-03-04T16:03:57.903881Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}