{"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 tensorflow as tf\nimport numpy as np\nimport pandas as pd\n\n#visual\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:17.320987Z","iopub.execute_input":"2025-03-07T05:12:17.321407Z","iopub.status.idle":"2025-03-07T05:12:34.827586Z","shell.execute_reply.started":"2025-03-07T05:12:17.321377Z","shell.execute_reply":"2025-03-07T05:12:34.826566Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"path = '../input/stanford-rna-3d-folding/'\n\ndf_train_seq = pd.read_csv(path +'train_sequences.csv')\ndf_train_labels = pd.read_csv(path + 'train_labels.csv')\n\ndf_valid_seq = pd.read_csv(path + 'validation_sequences.csv')\ndf_validation_labels = pd.read_csv(path + 'validation_labels.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:34.828842Z","iopub.execute_input":"2025-03-07T05:12:34.829495Z","iopub.status.idle":"2025-03-07T05:12:35.277146Z","shell.execute_reply.started":"2025-03-07T05:12:34.829446Z","shell.execute_reply":"2025-03-07T05:12:35.276185Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# **EDA (Exploratory Data Analysis)**","metadata":{}},{"cell_type":"code","source":"shapes = {\n    'train_sequences': df_train_seq.shape,\n    'train_labels': df_train_labels.shape,\n    'validation_sequences': df_valid_seq.shape,\n    'validation_labels': df_validation_labels.shape\n}\n\n# Print the sizes for each DataFrame\nfor key, value in shapes.items():\n    print(f\"{key}: {value}\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.279291Z","iopub.execute_input":"2025-03-07T05:12:35.279591Z","iopub.status.idle":"2025-03-07T05:12:35.285990Z","shell.execute_reply.started":"2025-03-07T05:12:35.279565Z","shell.execute_reply":"2025-03-07T05:12:35.284913Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_seq.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.287768Z","iopub.execute_input":"2025-03-07T05:12:35.288193Z","iopub.status.idle":"2025-03-07T05:12:35.327918Z","shell.execute_reply.started":"2025-03-07T05:12:35.288164Z","shell.execute_reply":"2025-03-07T05:12:35.326868Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_seq.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.328925Z","iopub.execute_input":"2025-03-07T05:12:35.329306Z","iopub.status.idle":"2025-03-07T05:12:35.335380Z","shell.execute_reply.started":"2025-03-07T05:12:35.329275Z","shell.execute_reply":"2025-03-07T05:12:35.334390Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.336210Z","iopub.execute_input":"2025-03-07T05:12:35.336481Z","iopub.status.idle":"2025-03-07T05:12:35.361223Z","shell.execute_reply.started":"2025-03-07T05:12:35.336460Z","shell.execute_reply":"2025-03-07T05:12:35.360043Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.362227Z","iopub.execute_input":"2025-03-07T05:12:35.362498Z","iopub.status.idle":"2025-03-07T05:12:35.380010Z","shell.execute_reply.started":"2025-03-07T05:12:35.362476Z","shell.execute_reply":"2025-03-07T05:12:35.379145Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_valid_seq.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.382586Z","iopub.execute_input":"2025-03-07T05:12:35.382947Z","iopub.status.idle":"2025-03-07T05:12:35.404603Z","shell.execute_reply.started":"2025-03-07T05:12:35.382919Z","shell.execute_reply":"2025-03-07T05:12:35.403547Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_valid_seq.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.406036Z","iopub.execute_input":"2025-03-07T05:12:35.406367Z","iopub.status.idle":"2025-03-07T05:12:35.422917Z","shell.execute_reply.started":"2025-03-07T05:12:35.406339Z","shell.execute_reply":"2025-03-07T05:12:35.421821Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_validation_labels.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.423829Z","iopub.execute_input":"2025-03-07T05:12:35.424188Z","iopub.status.idle":"2025-03-07T05:12:35.470382Z","shell.execute_reply.started":"2025-03-07T05:12:35.424161Z","shell.execute_reply":"2025-03-07T05:12:35.469310Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_validation_labels.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.471433Z","iopub.execute_input":"2025-03-07T05:12:35.471764Z","iopub.status.idle":"2025-03-07T05:12:35.491805Z","shell.execute_reply.started":"2025-03-07T05:12:35.471727Z","shell.execute_reply":"2025-03-07T05:12:35.490537Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.492898Z","iopub.execute_input":"2025-03-07T05:12:35.493351Z","iopub.status.idle":"2025-03-07T05:12:35.551420Z","shell.execute_reply.started":"2025-03-07T05:12:35.493318Z","shell.execute_reply":"2025-03-07T05:12:35.550549Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.resname.unique()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.552042Z","iopub.execute_input":"2025-03-07T05:12:35.552348Z","iopub.status.idle":"2025-03-07T05:12:35.569211Z","shell.execute_reply.started":"2025-03-07T05:12:35.552325Z","shell.execute_reply":"2025-03-07T05:12:35.568275Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.resname.value_counts()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.570295Z","iopub.execute_input":"2025-03-07T05:12:35.570575Z","iopub.status.idle":"2025-03-07T05:12:35.596910Z","shell.execute_reply.started":"2025-03-07T05:12:35.570541Z","shell.execute_reply":"2025-03-07T05:12:35.595658Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.isnull().values.any()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.597997Z","iopub.execute_input":"2025-03-07T05:12:35.598349Z","iopub.status.idle":"2025-03-07T05:12:35.629562Z","shell.execute_reply.started":"2025-03-07T05:12:35.598323Z","shell.execute_reply":"2025-03-07T05:12:35.628256Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train_labels.isnull()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.630758Z","iopub.execute_input":"2025-03-07T05:12:35.631200Z","iopub.status.idle":"2025-03-07T05:12:35.671302Z","shell.execute_reply.started":"2025-03-07T05:12:35.631152Z","shell.execute_reply":"2025-03-07T05:12:35.670198Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"coord_cols = ['x_1', 'y_1', 'z_1']\nfor col in coord_cols:\n    df_train_labels[col] = df_train_labels[col].fillna(df_train_labels[col].mean())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.672328Z","iopub.execute_input":"2025-03-07T05:12:35.672735Z","iopub.status.idle":"2025-03-07T05:12:35.686516Z","shell.execute_reply.started":"2025-03-07T05:12:35.672704Z","shell.execute_reply":"2025-03-07T05:12:35.685200Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_validation_labels.isnull().values.any()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.687467Z","iopub.execute_input":"2025-03-07T05:12:35.687757Z","iopub.status.idle":"2025-03-07T05:12:35.694189Z","shell.execute_reply.started":"2025-03-07T05:12:35.687732Z","shell.execute_reply":"2025-03-07T05:12:35.693368Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Compute and plot the distribution of sequence lengths\ndf_train_seq['seq_length'] = df_train_seq['sequence'].apply(len)\nplt.figure(figsize=(5, 3))\nsns.histplot(df_train_seq['seq_length'], bins=20, kde=True)\nplt.title(\"Distribution of RNA Sequence Lengths (Train)\")\nplt.xlabel(\"Sequence Length\")\nplt.ylabel(\"Frequency\")\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:35.695054Z","iopub.execute_input":"2025-03-07T05:12:35.695437Z","iopub.status.idle":"2025-03-07T05:12:36.036042Z","shell.execute_reply.started":"2025-03-07T05:12:35.695412Z","shell.execute_reply":"2025-03-07T05:12:36.034968Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"x_coords = df_train_labels['x_1']\ny_coords = df_train_labels['y_1']\nz_coords = df_train_labels['z_1']\n\n# Create a 3D scatter plot\nfig = plt.figure(figsize=(8, 6))\nax = fig.add_subplot(111, projection='3d')\nresidue_ids = df_train_labels['resid']\n        \n# Create a normalized color mapping based on residue IDs\nnormalized_ids = (residue_ids - residue_ids.min()) / (residue_ids.max() - residue_ids.min())\ncolors = plt.cm.viridis(normalized_ids)\nax.scatter(x_coords, y_coords, z_coords, marker='o', c=colors, s=20)\n\n# Labeling the axes and giving a title\nax.set_xlabel(\"X coordinate\")\nax.set_ylabel(\"Y coordinate\")\nax.set_zlabel(\"Z coordinate\")\nax.set_title(\"3D Scatter Plot of Training Labels Coordinates\")\n\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-03-07T05:12:36.037041Z","iopub.execute_input":"2025-03-07T05:12:36.037366Z","iopub.status.idle":"2025-03-07T05:12:39.239235Z","shell.execute_reply.started":"2025-03-07T05:12:36.037330Z","shell.execute_reply":"2025-03-07T05:12:39.238139Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}