{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.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":67356,"databundleVersionId":8006601,"sourceType":"competition"},{"sourceId":8048149,"sourceType":"datasetVersion","datasetId":4745893},{"sourceId":170653109,"sourceType":"kernelVersion"}],"dockerImageVersionId":30673,"isInternetEnabled":true,"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)\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":"2024-04-07T17:20:40.824242Z","iopub.execute_input":"2024-04-07T17:20:40.824758Z","iopub.status.idle":"2024-04-07T17:20:40.894173Z","shell.execute_reply.started":"2024-04-07T17:20:40.824719Z","shell.execute_reply":"2024-04-07T17:20:40.893041Z"},"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":{"execution":{"iopub.status.busy":"2024-04-07T17:20:42.063041Z","iopub.execute_input":"2024-04-07T17:20:42.063771Z","iopub.status.idle":"2024-04-07T17:20:42.332390Z","shell.execute_reply.started":"2024-04-07T17:20:42.063731Z","shell.execute_reply":"2024-04-07T17:20:42.331338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub1.head()","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:43.277916Z","iopub.execute_input":"2024-04-07T17:20:43.278394Z","iopub.status.idle":"2024-04-07T17:20:43.288046Z","shell.execute_reply.started":"2024-04-07T17:20:43.278360Z","shell.execute_reply":"2024-04-07T17:20:43.286632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub2.head()","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:45.177993Z","iopub.execute_input":"2024-04-07T17:20:45.178549Z","iopub.status.idle":"2024-04-07T17:20:45.188561Z","shell.execute_reply.started":"2024-04-07T17:20:45.178436Z","shell.execute_reply":"2024-04-07T17:20:45.187222Z"},"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":{"execution":{"iopub.status.busy":"2024-04-07T17:20:47.209183Z","iopub.execute_input":"2024-04-07T17:20:47.209700Z","iopub.status.idle":"2024-04-07T17:20:47.326129Z","shell.execute_reply.started":"2024-04-07T17:20:47.209656Z","shell.execute_reply":"2024-04-07T17:20:47.324579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:48.418211Z","iopub.execute_input":"2024-04-07T17:20:48.418752Z","iopub.status.idle":"2024-04-07T17:20:48.428966Z","shell.execute_reply.started":"2024-04-07T17:20:48.418710Z","shell.execute_reply":"2024-04-07T17:20:48.427167Z"},"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":{"execution":{"iopub.status.busy":"2024-04-07T17:20:49.427652Z","iopub.execute_input":"2024-04-07T17:20:49.428148Z","iopub.status.idle":"2024-04-07T17:20:49.436889Z","shell.execute_reply.started":"2024-04-07T17:20:49.428113Z","shell.execute_reply":"2024-04-07T17:20:49.435413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_fl.head()","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:51.518182Z","iopub.execute_input":"2024-04-07T17:20:51.518642Z","iopub.status.idle":"2024-04-07T17:20:51.528740Z","shell.execute_reply.started":"2024-04-07T17:20:51.518606Z","shell.execute_reply":"2024-04-07T17:20:51.527351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"\\nFinal submission file\\n\")\ndisplay(sub_fl.head(10))","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:52.692249Z","iopub.execute_input":"2024-04-07T17:20:52.692788Z","iopub.status.idle":"2024-04-07T17:20:52.703981Z","shell.execute_reply.started":"2024-04-07T17:20:52.692731Z","shell.execute_reply":"2024-04-07T17:20:52.702297Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_fl.select([\"id\", target]).write_parquet(\"submission.parquet\")\nprint(\"DONE!!!\")","metadata":{"execution":{"iopub.status.busy":"2024-04-07T17:20:53.810442Z","iopub.execute_input":"2024-04-07T17:20:53.811001Z","iopub.status.idle":"2024-04-07T17:20:54.224665Z","shell.execute_reply.started":"2024-04-07T17:20:53.810957Z","shell.execute_reply":"2024-04-07T17:20:54.223326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}