{"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":31192,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:15:32.577142Z","iopub.execute_input":"2025-12-20T10:15:32.577430Z","iopub.status.idle":"2025-12-20T10:15:32.583552Z","shell.execute_reply.started":"2025-12-20T10:15:32.577407Z","shell.execute_reply":"2025-12-20T10:15:32.582375Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"BASE_PATH = '/kaggle/input/csiro-biomass/'\nTRAIN_CSV_PATH = BASE_PATH + 'train.csv'\nTEST_CSV_PATH = BASE_PATH + 'test.csv'\n\ndf_train = pd.read_csv(TRAIN_CSV_PATH)\ndf_test = pd.read_csv(TEST_CSV_PATH)\n\ndisplay(df_train)\n\ndisplay(df_test)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:15:32.604274Z","iopub.execute_input":"2025-12-20T10:15:32.605228Z","iopub.status.idle":"2025-12-20T10:15:32.636784Z","shell.execute_reply.started":"2025-12-20T10:15:32.605185Z","shell.execute_reply":"2025-12-20T10:15:32.635845Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nfrom PIL import Image\n\nsample_rows = df_train.sample(5)\n\n\nplt.figure(figsize=(20, 5))\nfor i, (idx, row) in enumerate(sample_rows.iterrows()):\n    # Construct the full path to the images\n    full_path = BASE_PATH + row['image_path']\n    \n    img = Image.open(full_path)\n    plt.subplot(1, 5, i + 1)\n    plt.imshow(img)\n    plt.title(f\"\"\"\n        sample_id: {row['sample_id']}\n        image_path: {row['image_path']}\n        Sampling_Date: {row['Sampling_Date']} State: {row['State']}\n        Species: {row['Species']}\n        Pre_GSHH_NDVI: {row['Pre_GSHH_NDVI']}\n        Height_Ave_cm: {row['Height_Ave_cm']} cm\n        target_name: {row['target_name']}\n        target: {row['target']:.1f} g\n        \"\"\", loc='left', fontsize=(8))\n    plt.axis('off')\n\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:15:32.656030Z","iopub.execute_input":"2025-12-20T10:15:32.656634Z","iopub.status.idle":"2025-12-20T10:15:34.832056Z","shell.execute_reply.started":"2025-12-20T10:15:32.656605Z","shell.execute_reply":"2025-12-20T10:15:34.830938Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.scatterplot(data=df_train, x = 'Pre_GSHH_NDVI', y='target',hue='target_name', alpha=0.5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:15:34.833279Z","iopub.execute_input":"2025-12-20T10:15:34.833564Z","iopub.status.idle":"2025-12-20T10:15:35.285999Z","shell.execute_reply.started":"2025-12-20T10:15:34.833540Z","shell.execute_reply":"2025-12-20T10:15:35.285015Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"target_by_name = df_train.groupby('target_name')['target'].mean().reset_index()\ntarget_by_name","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:15:35.287038Z","iopub.execute_input":"2025-12-20T10:15:35.287287Z","iopub.status.idle":"2025-12-20T10:15:35.303353Z","shell.execute_reply.started":"2025-12-20T10:15:35.287263Z","shell.execute_reply":"2025-12-20T10:15:35.302402Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_submission = df_test.merge(\n    target_by_name,\n    on ='target_name',\n    how='left'\n)[[\"sample_id\",\"target\"]]\n\ndf_submission","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:17:09.550249Z","iopub.execute_input":"2025-12-20T10:17:09.550693Z","iopub.status.idle":"2025-12-20T10:17:09.562929Z","shell.execute_reply.started":"2025-12-20T10:17:09.550657Z","shell.execute_reply":"2025-12-20T10:17:09.562044Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_submission.to_csv('submission.csv',index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-12-20T10:20:50.774359Z","iopub.execute_input":"2025-12-20T10:20:50.775137Z","iopub.status.idle":"2025-12-20T10:20:50.780001Z","shell.execute_reply.started":"2025-12-20T10:20:50.775110Z","shell.execute_reply":"2025-12-20T10:20:50.779135Z"}},"outputs":[],"execution_count":null}]}