{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":112509,"databundleVersionId":14254895,"sourceType":"competition"}],"dockerImageVersionId":31153,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import numpy as np \nimport pandas as pd ","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-10-28T22:25:22.562628Z","iopub.execute_input":"2025-10-28T22:25:22.563125Z","iopub.status.idle":"2025-10-28T22:25:22.928014Z","shell.execute_reply.started":"2025-10-28T22:25:22.563083Z","shell.execute_reply":"2025-10-28T22:25:22.927037Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Load the train dataset\ndf_train = pd.read_csv('/kaggle/input/csiro-biomass/train.csv')\n\nprint(df_train.shape)\ndf_train.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-28T22:25:41.203720Z","iopub.execute_input":"2025-10-28T22:25:41.204110Z","iopub.status.idle":"2025-10-28T22:25:41.261354Z","shell.execute_reply.started":"2025-10-28T22:25:41.204080Z","shell.execute_reply":"2025-10-28T22:25:41.260336Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Calculate the median of 'target' grouped by 'target_name'\nmean_target_by_name = df_train.groupby('target_name')['target'].median().reset_index()\nmean_target_by_name","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-28T22:26:15.320134Z","iopub.execute_input":"2025-10-28T22:26:15.320536Z","iopub.status.idle":"2025-10-28T22:26:15.349565Z","shell.execute_reply.started":"2025-10-28T22:26:15.320510Z","shell.execute_reply":"2025-10-28T22:26:15.348394Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Load the test dataset\ndf_test = pd.read_csv('/kaggle/input/csiro-biomass/test.csv')\n\nprint(df_test.shape)\ndf_test.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-28T22:32:19.039099Z","iopub.execute_input":"2025-10-28T22:32:19.039491Z","iopub.status.idle":"2025-10-28T22:32:19.056716Z","shell.execute_reply.started":"2025-10-28T22:32:19.039466Z","shell.execute_reply":"2025-10-28T22:32:19.055240Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission_df = df_test.merge(\n    mean_target_by_name,\n    on='target_name',\n    how='left'\n)[[\"sample_id\",\"target\"]]\n\nsubmission_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-28T22:33:01.937608Z","iopub.execute_input":"2025-10-28T22:33:01.938437Z","iopub.status.idle":"2025-10-28T22:33:01.952748Z","shell.execute_reply.started":"2025-10-28T22:33:01.938409Z","shell.execute_reply":"2025-10-28T22:33:01.951804Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission_df.to_csv('submission.csv', index=False)","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}