{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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 glob","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-14T14:39:57.198267Z","iopub.execute_input":"2022-08-14T14:39:57.198745Z","iopub.status.idle":"2022-08-14T14:39:57.226224Z","shell.execute_reply.started":"2022-08-14T14:39:57.198650Z","shell.execute_reply":"2022-08-14T14:39:57.225321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"This notebook ensembles four different submissions and weights them according to the model's different performance. It is based on the following notebook:\nhttps://www.kaggle.com/code/finlay/amex-rank-ensemble","metadata":{}},{"cell_type":"code","source":"paths = ['../input/lag-features-are-all-you-need/submission.csv',\n '../input/amex-lgbm-dart-cv-0-7963-improved/submission.csv',\n '../input/amex-lightautoml-starter/lightautoml_tabularautoml.csv',\n '../input/expressions-of-gluttony/submission.csv']","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:39:57.245234Z","iopub.execute_input":"2022-08-14T14:39:57.245847Z","iopub.status.idle":"2022-08-14T14:39:57.250550Z","shell.execute_reply.started":"2022-08-14T14:39:57.245803Z","shell.execute_reply":"2022-08-14T14:39:57.249752Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#['../input/lag-features-are-all-you-need/submission.csv', --> 0.797 0\n# '../input/amex-lgbm-dart-cv-0-7963-improved/submission.csv', --> 0.799 1\n# '../input/amex-lightautoml-starter/lightautoml_tabularautoml.csv', --> 0.795 2\n# '../input/expressions-of-gluttony/submission.csv'] --> 0.796 3","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:39:57.294974Z","iopub.execute_input":"2022-08-14T14:39:57.295381Z","iopub.status.idle":"2022-08-14T14:39:57.301061Z","shell.execute_reply.started":"2022-08-14T14:39:57.295344Z","shell.execute_reply":"2022-08-14T14:39:57.299964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dfs = [pd.read_csv(x) for x in paths]\ndfs = [x.sort_values(by='customer_ID') for x in dfs]","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:39:57.314707Z","iopub.execute_input":"2022-08-14T14:39:57.315093Z","iopub.status.idle":"2022-08-14T14:40:08.201958Z","shell.execute_reply.started":"2022-08-14T14:39:57.315059Z","shell.execute_reply":"2022-08-14T14:40:08.200718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for df in dfs:\n    df['prediction'] = np.clip(df['prediction'], 0, 1)","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:40:08.203779Z","iopub.execute_input":"2022-08-14T14:40:08.204209Z","iopub.status.idle":"2022-08-14T14:40:08.262773Z","shell.execute_reply.started":"2022-08-14T14:40:08.204179Z","shell.execute_reply":"2022-08-14T14:40:08.261709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"params = [0.441,0.529,0.015,0.015 ]\n\npred_ensembled = params[0] * dfs[0]['prediction'] +params[1] * dfs[1]['prediction']  + params[2] * dfs[2]['prediction']+  params[3] * dfs[3]['prediction']","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:40:08.263974Z","iopub.execute_input":"2022-08-14T14:40:08.264308Z","iopub.status.idle":"2022-08-14T14:40:08.287637Z","shell.execute_reply.started":"2022-08-14T14:40:08.264279Z","shell.execute_reply":"2022-08-14T14:40:08.286648Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:40:08.289432Z","iopub.execute_input":"2022-08-14T14:40:08.289755Z","iopub.status.idle":"2022-08-14T14:40:10.006929Z","shell.execute_reply.started":"2022-08-14T14:40:08.289727Z","shell.execute_reply":"2022-08-14T14:40:10.005870Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit['prediction'] = pred_ensembled","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:40:10.008551Z","iopub.execute_input":"2022-08-14T14:40:10.009029Z","iopub.status.idle":"2022-08-14T14:40:10.018419Z","shell.execute_reply.started":"2022-08-14T14:40:10.008986Z","shell.execute_reply":"2022-08-14T14:40:10.017595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit.to_csv('submission', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-14T14:40:10.019899Z","iopub.execute_input":"2022-08-14T14:40:10.020514Z","iopub.status.idle":"2022-08-14T14:40:13.274372Z","shell.execute_reply.started":"2022-08-14T14:40:10.020481Z","shell.execute_reply":"2022-08-14T14:40:13.273422Z"},"trusted":true},"execution_count":null,"outputs":[]}]}