{"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":31239,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# ===============================\n# 1. Imports\n# ===============================\nimport os\nimport pandas as pd\nimport numpy as np\n\n# ===============================\n# 2. Auto-detect dataset folder\n# ===============================\nBASE_PATH = \"/kaggle/input\"\ndataset_path = None\n\nfor folder in os.listdir(BASE_PATH):\n    full_path = os.path.join(BASE_PATH, folder)\n    if os.path.isdir(full_path):\n        files = os.listdir(full_path)\n        if \"train.csv\" in files and \"test.csv\" in files:\n            dataset_path = full_path\n            break\n\nif dataset_path is None:\n    raise FileNotFoundError(\"train.csv and test.csv not found\")\n\nprint(\"✅ Dataset found at:\", dataset_path)\n\n# ===============================\n# 3. Load train & test\n# ===============================\ntrain = pd.read_csv(os.path.join(dataset_path, \"train.csv\"))\ntest = pd.read_csv(os.path.join(dataset_path, \"test.csv\"))\n\nprint(\"Train columns:\", train.columns)\nprint(\"Test columns:\", test.columns)\n\n# ===============================\n# 4. Baseline: mean per target_name\n# ===============================\ntarget_means = train.groupby(\"target_name\")[\"target\"].mean()\nprint(\"\\nTarget means:\\n\", target_means)\n\n# ===============================\n# 5. Predict on test\n# ===============================\ntest[\"target\"] = test[\"target_name\"].map(target_means)\n\n# Safety fallback (should not be needed, but safe)\nglobal_mean = train[\"target\"].mean()\ntest[\"target\"] = test[\"target\"].fillna(global_mean)\n\n# ===============================\n# 6. Create submission.csv\n# ===============================\nsubmission = test[[\"sample_id\", \"target\"]]\nsubmission.to_csv(\"submission.csv\", index=False)\n\nprint(\"\\n✅ submission.csv created successfully\")\nsubmission.head()\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2025-12-22T01:08:07.824437Z","iopub.execute_input":"2025-12-22T01:08:07.824855Z","iopub.status.idle":"2025-12-22T01:08:07.855914Z","shell.execute_reply.started":"2025-12-22T01:08:07.824821Z","shell.execute_reply":"2025-12-22T01:08:07.854655Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}