{"metadata":{"kaggle":{"accelerator":"none","dataSources":[{"sourceId":67356,"databundleVersionId":8006601,"sourceType":"competition"},{"sourceId":8048149,"sourceType":"datasetVersion","datasetId":4745893},{"sourceId":170653109,"sourceType":"kernelVersion"}],"dockerImageVersionId":30684,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.13"},"papermill":{"default_parameters":{},"duration":6.754819,"end_time":"2024-04-07T17:23:48.704760","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2024-04-07T17:23:41.949941","version":"2.5.0"}},"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)\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":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.92656,"end_time":"2024-04-07T17:23:46.310857","exception":false,"start_time":"2024-04-07T17:23:45.384297","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:03.056291Z","iopub.execute_input":"2024-04-13T15:28:03.056762Z","iopub.status.idle":"2024-04-13T15:28:03.618752Z","shell.execute_reply.started":"2024-04-13T15:28:03.056716Z","shell.execute_reply":"2024-04-13T15:28:03.617439Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import polars as pl\nimport numpy as np\nfrom gc import collect\n\n# Preparing the blend\ntarget = \"binds\"\nsub1 = pl.read_parquet(\"/kaggle/input/belka2024ancillary/Submission_E1V1.parquet\")\nsub2 = pl.read_csv(\"/kaggle/input/leash-bio-automl-baseline/submission.csv\")\nsub_fl = pl.read_csv(\"/kaggle/input/leash-BELKA/sample_submission.csv\")\n","metadata":{"papermill":{"duration":1.150614,"end_time":"2024-04-07T17:23:47.466656","exception":false,"start_time":"2024-04-07T17:23:46.316042","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:03.621093Z","iopub.execute_input":"2024-04-13T15:28:03.621584Z","iopub.status.idle":"2024-04-13T15:28:05.624416Z","shell.execute_reply.started":"2024-04-13T15:28:03.621549Z","shell.execute_reply":"2024-04-13T15:28:05.623108Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub1.head()","metadata":{"papermill":{"duration":0.026764,"end_time":"2024-04-07T17:23:47.498626","exception":false,"start_time":"2024-04-07T17:23:47.471862","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.625923Z","iopub.execute_input":"2024-04-13T15:28:05.626341Z","iopub.status.idle":"2024-04-13T15:28:05.646382Z","shell.execute_reply.started":"2024-04-13T15:28:05.626305Z","shell.execute_reply":"2024-04-13T15:28:05.645110Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub2.head()","metadata":{"papermill":{"duration":0.018079,"end_time":"2024-04-07T17:23:47.522035","exception":false,"start_time":"2024-04-07T17:23:47.503956","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.649642Z","iopub.execute_input":"2024-04-13T15:28:05.650119Z","iopub.status.idle":"2024-04-13T15:28:05.659377Z","shell.execute_reply.started":"2024-04-13T15:28:05.650075Z","shell.execute_reply":"2024-04-13T15:28:05.658106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Calculate the blended predictions\nprediction = np.average(np.c_[sub1.select(pl.col(target)).to_numpy(), \n                         sub2.select(pl.col(target)).to_numpy()], \n                   axis=1, \n                   weights=[0.15, 0.85])","metadata":{"papermill":{"duration":0.136666,"end_time":"2024-04-07T17:23:47.664300","exception":false,"start_time":"2024-04-07T17:23:47.527634","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.660896Z","iopub.execute_input":"2024-04-13T15:28:05.661343Z","iopub.status.idle":"2024-04-13T15:28:05.800158Z","shell.execute_reply.started":"2024-04-13T15:28:05.661306Z","shell.execute_reply":"2024-04-13T15:28:05.798832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"papermill":{"duration":0.018181,"end_time":"2024-04-07T17:23:47.688168","exception":false,"start_time":"2024-04-07T17:23:47.669987","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.801646Z","iopub.execute_input":"2024-04-13T15:28:05.802132Z","iopub.status.idle":"2024-04-13T15:28:05.810654Z","shell.execute_reply.started":"2024-04-13T15:28:05.802088Z","shell.execute_reply":"2024-04-13T15:28:05.809365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_fl = sub_fl.with_columns(pl.Series(name=target, values=prediction.flatten()))\n","metadata":{"papermill":{"duration":0.025464,"end_time":"2024-04-07T17:23:47.719333","exception":false,"start_time":"2024-04-07T17:23:47.693869","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.812407Z","iopub.execute_input":"2024-04-13T15:28:05.812846Z","iopub.status.idle":"2024-04-13T15:28:05.837000Z","shell.execute_reply.started":"2024-04-13T15:28:05.812806Z","shell.execute_reply":"2024-04-13T15:28:05.835838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_fl.head()","metadata":{"papermill":{"duration":0.016659,"end_time":"2024-04-07T17:23:47.741413","exception":false,"start_time":"2024-04-07T17:23:47.724754","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.839321Z","iopub.execute_input":"2024-04-13T15:28:05.839846Z","iopub.status.idle":"2024-04-13T15:28:05.849244Z","shell.execute_reply.started":"2024-04-13T15:28:05.839734Z","shell.execute_reply":"2024-04-13T15:28:05.847923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"\\nFinal submission file\\n\")\ndisplay(sub_fl.head(10))","metadata":{"papermill":{"duration":0.018253,"end_time":"2024-04-07T17:23:47.765189","exception":false,"start_time":"2024-04-07T17:23:47.746936","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.851162Z","iopub.execute_input":"2024-04-13T15:28:05.852194Z","iopub.status.idle":"2024-04-13T15:28:05.863045Z","shell.execute_reply.started":"2024-04-13T15:28:05.852134Z","shell.execute_reply":"2024-04-13T15:28:05.861679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_fl.select([\"id\", target]).write_parquet(\"submission.parquet\")\nprint(\"DONE!!!\")","metadata":{"papermill":{"duration":0.393396,"end_time":"2024-04-07T17:23:48.164909","exception":false,"start_time":"2024-04-07T17:23:47.771513","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2024-04-13T15:28:05.866870Z","iopub.execute_input":"2024-04-13T15:28:05.868134Z","iopub.status.idle":"2024-04-13T15:28:06.267157Z","shell.execute_reply.started":"2024-04-13T15:28:05.868083Z","shell.execute_reply":"2024-04-13T15:28:06.265781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.005914,"end_time":"2024-04-07T17:23:48.177114","exception":false,"start_time":"2024-04-07T17:23:48.171200","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}