{"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":119699,"databundleVersionId":14318436,"sourceType":"competition"}],"dockerImageVersionId":31153,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport seaborn as sns # plotting\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2025-11-02T15:18:57.157492Z","iopub.execute_input":"2025-11-02T15:18:57.157737Z","iopub.status.idle":"2025-11-02T15:19:01.331291Z","shell.execute_reply.started":"2025-11-02T15:18:57.157708Z","shell.execute_reply":"2025-11-02T15:19:01.330275Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def load_data(crop: str, mode: str=\"train\"):\n    # note that years represent an offset from model spinup;\n    # soil co2 dataset has real year;\n    # 0-30 are days before sowing, 31-238 are days after sowing\n    #tasmax = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/tasmax_{crop}_{mode}.parquet\")\n    #tasmin = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/tasmin_{crop}_{mode}.parquet\")\n    #pr = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/pr_{crop}_{mode}.parquet\")\n    #rsds = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/rsds_{crop}_{mode}.parquet\")\n    soil_co2 = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/soil_co2_{crop}_{mode}.parquet\")\n    target = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/{mode}_solutions_{crop}.parquet\")\n    return {\n        #'tasmax': tasmax,\n        #'tasmin': tasmin,\n        #'pr': pr,\n        #'rsds': rsds,\n        'soil_co2': soil_co2,\n        'target': target,\n    }","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:34.898524Z","iopub.execute_input":"2025-11-02T15:19:34.898869Z","iopub.status.idle":"2025-11-02T15:19:34.904566Z","shell.execute_reply.started":"2025-11-02T15:19:34.898841Z","shell.execute_reply":"2025-11-02T15:19:34.903666Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"maize_train = load_data(\"maize\", \"train\")\nmaize_train.keys()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:39.476066Z","iopub.execute_input":"2025-11-02T15:19:39.476452Z","iopub.status.idle":"2025-11-02T15:19:39.904345Z","shell.execute_reply.started":"2025-11-02T15:19:39.476417Z","shell.execute_reply":"2025-11-02T15:19:39.903193Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"wheat_train = load_data(\"wheat\", \"train\")\nwheat_train.keys()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:39.905923Z","iopub.execute_input":"2025-11-02T15:19:39.906249Z","iopub.status.idle":"2025-11-02T15:19:40.062989Z","shell.execute_reply.started":"2025-11-02T15:19:39.906221Z","shell.execute_reply":"2025-11-02T15:19:40.061622Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"maize_train['soil_co2'].join(maize_train['target'])['yield'].mean()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:40.119357Z","iopub.execute_input":"2025-11-02T15:19:40.119756Z","iopub.status.idle":"2025-11-02T15:19:40.169245Z","shell.execute_reply.started":"2025-11-02T15:19:40.119720Z","shell.execute_reply":"2025-11-02T15:19:40.168138Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"wheat_train['soil_co2'].join(wheat_train['target'])['yield'].mean()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:40.541278Z","iopub.execute_input":"2025-11-02T15:19:40.541556Z","iopub.status.idle":"2025-11-02T15:19:40.566248Z","shell.execute_reply.started":"2025-11-02T15:19:40.541526Z","shell.execute_reply":"2025-11-02T15:19:40.565423Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"soil_co2_maize_test = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/soil_co2_maize_test.parquet\")","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:43.690465Z","iopub.execute_input":"2025-11-02T15:19:43.690924Z","iopub.status.idle":"2025-11-02T15:19:43.807680Z","shell.execute_reply.started":"2025-11-02T15:19:43.690898Z","shell.execute_reply":"2025-11-02T15:19:43.806797Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"soil_co2_maize_test['yield'] = maize_train['soil_co2'].join(maize_train['target'])['yield'].mean()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:44.046796Z","iopub.execute_input":"2025-11-02T15:19:44.047113Z","iopub.status.idle":"2025-11-02T15:19:44.068856Z","shell.execute_reply.started":"2025-11-02T15:19:44.047088Z","shell.execute_reply":"2025-11-02T15:19:44.067897Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"soil_co2_wheat_test = pd.read_parquet(f\"/kaggle/input/ag-ml-leipzig-2025-future-crop/soil_co2_wheat_test.parquet\")","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:44.422873Z","iopub.execute_input":"2025-11-02T15:19:44.423179Z","iopub.status.idle":"2025-11-02T15:19:44.540870Z","shell.execute_reply.started":"2025-11-02T15:19:44.423158Z","shell.execute_reply":"2025-11-02T15:19:44.539564Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"soil_co2_wheat_test['yield'] = wheat_train['soil_co2'].join(wheat_train['target'])['yield'].mean()","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:45.761088Z","iopub.execute_input":"2025-11-02T15:19:45.761400Z","iopub.status.idle":"2025-11-02T15:19:45.778272Z","shell.execute_reply.started":"2025-11-02T15:19:45.761375Z","shell.execute_reply":"2025-11-02T15:19:45.777313Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pd.concat([soil_co2_maize_test, soil_co2_wheat_test])[['yield']].to_csv('submission.csv', index_label='ID')","metadata":{"execution":{"iopub.status.busy":"2025-11-02T15:19:46.201151Z","iopub.execute_input":"2025-11-02T15:19:46.201421Z","iopub.status.idle":"2025-11-02T15:19:49.016636Z","shell.execute_reply.started":"2025-11-02T15:19:46.201401Z","shell.execute_reply":"2025-11-02T15:19:49.015657Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{},"outputs":[],"execution_count":null}]}