{"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-07-27T05:52:07.064832Z","iopub.execute_input":"2022-07-27T05:52:07.065523Z","iopub.status.idle":"2022-07-27T05:52:07.097189Z","shell.execute_reply.started":"2022-07-27T05:52:07.06538Z","shell.execute_reply":"2022-07-27T05:52:07.095994Z"},"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 = [\n '../input/lag-features-are-all-you-need/submission.csv',\n '../input/amex-bruteforce-feature-engineering/submission.csv',\n '../input/amex-lightautoml-starter/lightautoml_tabularautoml.csv',\n '../input/expressions-of-gluttony/submission.csv']","metadata":{"execution":{"iopub.status.busy":"2022-07-27T05:53:41.87243Z","iopub.execute_input":"2022-07-27T05:53:41.873634Z","iopub.status.idle":"2022-07-27T05:53:41.878496Z","shell.execute_reply.started":"2022-07-27T05:53:41.873584Z","shell.execute_reply":"2022-07-27T05:53:41.877536Z"},"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_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-07-27T05:53:43.742338Z","iopub.execute_input":"2022-07-27T05:53:43.743503Z","iopub.status.idle":"2022-07-27T05:53:54.275193Z","shell.execute_reply.started":"2022-07-27T05:53:43.743455Z","shell.execute_reply":"2022-07-27T05:53:54.274156Z"},"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-07-24T06:57:41.745182Z","iopub.execute_input":"2022-07-24T06:57:41.746054Z","iopub.status.idle":"2022-07-24T06:57:41.799128Z","shell.execute_reply.started":"2022-07-24T06:57:41.746002Z","shell.execute_reply":"2022-07-24T06:57:41.798011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_ensembled = 0.529 * dfs[1]['prediction'] + 0.441 * dfs[0]['prediction'] + 0.02 * dfs[3]['prediction'] + 0.01 * dfs[2]['prediction']","metadata":{"execution":{"iopub.status.busy":"2022-07-23T14:47:11.907363Z","iopub.execute_input":"2022-07-23T14:47:11.907777Z","iopub.status.idle":"2022-07-23T14:47:12.110478Z","shell.execute_reply.started":"2022-07-23T14:47:11.907734Z","shell.execute_reply":"2022-07-23T14:47:12.109206Z"},"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-07-23T14:47:24.366626Z","iopub.execute_input":"2022-07-23T14:47:24.367067Z","iopub.status.idle":"2022-07-23T14:47:26.679179Z","shell.execute_reply.started":"2022-07-23T14:47:24.367027Z","shell.execute_reply":"2022-07-23T14:47:26.677966Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit['prediction'] = pred_ensembled","metadata":{"execution":{"iopub.status.busy":"2022-07-23T14:47:40.559609Z","iopub.execute_input":"2022-07-23T14:47:40.560023Z","iopub.status.idle":"2022-07-23T14:47:40.569498Z","shell.execute_reply.started":"2022-07-23T14:47:40.559978Z","shell.execute_reply":"2022-07-23T14:47:40.568195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit.to_csv('submission', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-07-23T14:47:43.748763Z","iopub.execute_input":"2022-07-23T14:47:43.749174Z","iopub.status.idle":"2022-07-23T14:47:43.766134Z","shell.execute_reply.started":"2022-07-23T14:47:43.74914Z","shell.execute_reply":"2022-07-23T14:47:43.764362Z"},"trusted":true},"execution_count":null,"outputs":[]}]}