{"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":"markdown","source":"<div style=\"\n    background: linear-gradient(135deg, #0a0a0a, #1b1b1b, #2c2c2c);\n    border: 2px solid #00FFB2;\n    border-radius: 14px;\n    padding: 18px 22px;\n    box-shadow: 0 0 18px rgba(0, 255, 178, 0.35);\n    font-family: 'Segoe UI', sans-serif;\n    color: #f2f2f2;\n    line-height: 1.6;\n\">\n\n<h2 style=\"text-align:center; color:#00FFB2; text-shadow:0 0 8px #00FFC6;\">\n🌿 CSIRO Image2Biomass — Baseline AI Approach\n</h2>\n\n<p style=\"font-size:15px; text-align:center; color:#e6e6e6; margin-top:-8px;\">\nCreated by <b>Shreyash Patil</b> | AI • Data Science • Computer Vision\n</p>\n\n<p style=\"font-size:15px; text-align:justify; color:#f2f2f2;\">\nThis project provides a clean and interpretable <b style=\"color:#00FFB2;\">baseline solution</b> for the \n<b>CSIRO Image2Biomass</b> competition. Using <b>median-based estimation</b> and simple visualization,\nthe model establishes a solid foundation for further improvements using advanced AI or vision-based approaches.\n</p>\n\n<h4 style=\"color:#00FFB2; margin-bottom:6px;\">🎯 Project Goal:</h4>\n<ul style=\"font-size:15px; margin-left:18px; color:#e6e6e6;\">\n  <li>Estimate plant biomass using structured tabular data.</li>\n  <li>Build a reliable median baseline for each target type.</li>\n  <li>Visualize key patterns in height and biomass metrics.</li>\n</ul>\n\n<p style=\"text-align:center; margin-top:10px; font-size:13px;\">\n📊 <b>Kaggle Competition:</b> <a href=\"https://www.kaggle.com/competitions/csiro-biomass\" style=\"color:#00FFB2;\">CSIRO Image2Biomass</a>  \n| 💻 <a href=\"https://github.com/ShreyashPatil530\" style=\"color:#00FFB2;\">GitHub</a>  \n| 📈 <a href=\"https://www.kaggle.com/shreyashpatil217\" style=\"color:#00FFB2;\">Kaggle</a>\n</p>\n\n</div>\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport random\nimport matplotlib.pyplot as plt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:35:28.407090Z","iopub.execute_input":"2025-10-29T04:35:28.407383Z","iopub.status.idle":"2025-10-29T04:35:29.555718Z","shell.execute_reply.started":"2025-10-29T04:35:28.407354Z","shell.execute_reply":"2025-10-29T04:35:29.554365Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/csiro-biomass/train.csv')\ndf_test  = pd.read_csv('/kaggle/input/csiro-biomass/test.csv')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:35:30.711241Z","iopub.execute_input":"2025-10-29T04:35:30.711613Z","iopub.status.idle":"2025-10-29T04:35:30.755126Z","shell.execute_reply.started":"2025-10-29T04:35:30.711587Z","shell.execute_reply":"2025-10-29T04:35:30.754277Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(df_train.shape)\nprint(df_test.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:36:05.292694Z","iopub.execute_input":"2025-10-29T04:36:05.293003Z","iopub.status.idle":"2025-10-29T04:36:05.298268Z","shell.execute_reply.started":"2025-10-29T04:36:05.292981Z","shell.execute_reply":"2025-10-29T04:36:05.297308Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"display(df_train.head(), df_test.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:36:50.119404Z","iopub.execute_input":"2025-10-29T04:36:50.119929Z","iopub.status.idle":"2025-10-29T04:36:50.158291Z","shell.execute_reply.started":"2025-10-29T04:36:50.119902Z","shell.execute_reply":"2025-10-29T04:36:50.157066Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"median_target_by_name = (\n    df_train\n    .groupby('target_name')['target']\n    .median()\n    .reset_index()\n)\n\nprint(\"\\nMedian Target by Target Name:\")\ndisplay(median_target_by_name)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:37:11.047456Z","iopub.execute_input":"2025-10-29T04:37:11.047865Z","iopub.status.idle":"2025-10-29T04:37:11.075271Z","shell.execute_reply.started":"2025-10-29T04:37:11.047834Z","shell.execute_reply":"2025-10-29T04:37:11.074278Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,5))\nplt.bar(median_target_by_name['target_name'], median_target_by_name['target'])\nplt.title('Median Target Value per Target Type')\nplt.xlabel('Target Name')\nplt.ylabel('Median Target')\nplt.xticks(rotation=30)\nplt.grid(axis='y', linestyle='--', alpha=0.7)\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:37:30.354798Z","iopub.execute_input":"2025-10-29T04:37:30.355125Z","iopub.status.idle":"2025-10-29T04:37:30.676931Z","shell.execute_reply.started":"2025-10-29T04:37:30.355105Z","shell.execute_reply":"2025-10-29T04:37:30.675919Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure(figsize=(8,5))\nplt.scatter(df_train['Height_Ave_cm'], df_train['target'], alpha=0.6)\nplt.title('Height vs Target')\nplt.xlabel('Average Height (cm)')\nplt.ylabel('Target')\nplt.grid(alpha=0.3)\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:37:50.105101Z","iopub.execute_input":"2025-10-29T04:37:50.105442Z","iopub.status.idle":"2025-10-29T04:37:50.386519Z","shell.execute_reply.started":"2025-10-29T04:37:50.105417Z","shell.execute_reply":"2025-10-29T04:37:50.385466Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_submission = (\n    df_test\n    .merge(median_target_by_name, on='target_name', how='left')\n    [[\"sample_id\", \"target\"]]\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:38:12.393649Z","iopub.execute_input":"2025-10-29T04:38:12.394014Z","iopub.status.idle":"2025-10-29T04:38:12.404661Z","shell.execute_reply.started":"2025-10-29T04:38:12.393990Z","shell.execute_reply":"2025-10-29T04:38:12.403618Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_submission['target'] = (\n    df_submission['target'] * random.choice([1.0000107, 1.0000104]) * 0.50 +\n    df_submission['target'] / random.choice([1.0000107, 1.0000104]) * 0.50\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:38:27.211943Z","iopub.execute_input":"2025-10-29T04:38:27.212360Z","iopub.status.idle":"2025-10-29T04:38:27.219153Z","shell.execute_reply.started":"2025-10-29T04:38:27.212327Z","shell.execute_reply":"2025-10-29T04:38:27.218112Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_submission.to_csv('submission.csv', index=False)\n\nprint(\"\\nSubmission file saved as 'submission.csv'\")\ndisplay(df_submission.head())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-10-29T04:38:45.530346Z","iopub.execute_input":"2025-10-29T04:38:45.530780Z","iopub.status.idle":"2025-10-29T04:38:45.548707Z","shell.execute_reply.started":"2025-10-29T04:38:45.530753Z","shell.execute_reply":"2025-10-29T04:38:45.547640Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}