{"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":"markdown","source":"<h1 style=\"color: #6cb4e4;  text-align: center;  padding: 0.25em;  border-top: solid 2.5px #6cb4e4;  border-bottom: solid 2.5px #6cb4e4;  background: -webkit-repeating-linear-gradient(-45deg, #f0f8ff, #f0f8ff 3px,#e9f4ff 3px, #e9f4ff 7px);  background: repeating-linear-gradient(-45deg, #f0f8ff, #f0f8ff 3px,#e9f4ff 3px, #e9f4ff 7px);height:45px;\">\n<b>\nInf\n</b></h1> ","metadata":{}},{"cell_type":"code","source":"import numpy as np \nimport pandas as pd \nimport glob\nfrom scipy.stats import rankdata","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.01681,"end_time":"2022-07-23T10:57:31.799527","exception":false,"start_time":"2022-07-23T10:57:31.782717","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:13:25.676415Z","iopub.execute_input":"2022-08-23T16:13:25.676892Z","iopub.status.idle":"2022-08-23T16:13:25.684311Z","shell.execute_reply.started":"2022-08-23T16:13:25.676845Z","shell.execute_reply":"2022-08-23T16:13:25.682584Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"INF_FILES = [\n    '../input/amex-dc-re-c-201-20220726094926/test_lgbm_dart_baseline_10fold_seed42.csv',      # 0.7978147170998888\n    '../input/amex-dc-re-c-202-20220727101252/test_lgbm_dart_baseline_10fold_seed42.csv',      # 0.7976031581477059\n    '../input/amex-dc-c-204-20220729101322/test_lgbm_dart_baseline_10fold_seed72.csv',         # 0.7978160603673135\n    '../input/colabytc500trainlgbs82p2b9fe/test_lgbm_dart_baseline_10fold_seed82.csv',         # 0.796859083182589\n    '../input/amex-coalb-zh-c-502-20220731075605/test_lgbm_dart_baseline_10fold_seed92.csv',   # 0.7973483452762729\n    '../input/colabytc500trainlgbs22p2b9fe/test_lgbm_dart_baseline_10fold_seed22.csv',         # 0.7970505189757134\n    '../input/amex-coalb2-zhc2-d-200-20220803064030/test_lgbm_dart_baseline_15fold_seed72.csv',# 0.7977565762675183\n    '../input/amex-train-rnn-gru-e10-changelr/submission.csv',                                 # 0.7866492409756475\n    '../input/amex-coalb-zhc2-d-202-20220804140921/test_lgbm_dart_baseline_15fold_seed92.csv', # 0.7971871173047718\n    '../input/amexlocal1106traintabnet20220814040949/submission_tabnet.csv',                   # 0.7894859415904192\n    '../input/amex-coalb-7--20220815223219/Predictions/test_cat_baseline_15fold_seed72.csv'    # 0.7893212698586383\n]\nlen(INF_FILES)","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:13:25.687025Z","iopub.execute_input":"2022-08-23T16:13:25.687883Z","iopub.status.idle":"2022-08-23T16:13:25.704010Z","shell.execute_reply.started":"2022-08-23T16:13:25.687809Z","shell.execute_reply":"2022-08-23T16:13:25.702640Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\"\"\" Weight \"\"\"\nweights = [\n    0.97,\n    0.97,\n    0.97,\n    0.96,\n    0.97,\n    0.97,\n    0.97,\n    0.86,\n    0.97,\n    0.89,\n    0.89,\n]\nlen(weights)","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:13:25.706400Z","iopub.execute_input":"2022-08-23T16:13:25.707939Z","iopub.status.idle":"2022-08-23T16:13:25.723492Z","shell.execute_reply.started":"2022-08-23T16:13:25.707887Z","shell.execute_reply":"2022-08-23T16:13:25.721908Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = INF_FILES\ndfs = [pd.read_csv(x) for x in paths]\ndfs = [x.sort_values(by='customer_ID') for x in dfs]","metadata":{"papermill":{"duration":12.085843,"end_time":"2022-07-23T10:57:43.887896","exception":false,"start_time":"2022-07-23T10:57:31.802053","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:13:25.726340Z","iopub.execute_input":"2022-08-23T16:13:25.726890Z","iopub.status.idle":"2022-08-23T16:13:46.834982Z","shell.execute_reply.started":"2022-08-23T16:13:25.726805Z","shell.execute_reply":"2022-08-23T16:13:46.833390Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = INF_FILES\npaths","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:13:46.838116Z","iopub.execute_input":"2022-08-23T16:13:46.838625Z","iopub.status.idle":"2022-08-23T16:13:46.847416Z","shell.execute_reply.started":"2022-08-23T16:13:46.838578Z","shell.execute_reply":"2022-08-23T16:13:46.846164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for df in dfs:\n    df['prediction'] = np.clip(df['prediction'], 0, 1)","metadata":{"papermill":{"duration":0.059803,"end_time":"2022-07-23T10:57:43.950258","exception":false,"start_time":"2022-07-23T10:57:43.890455","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:13:46.848996Z","iopub.execute_input":"2022-08-23T16:13:46.850361Z","iopub.status.idle":"2022-08-23T16:13:46.999257Z","shell.execute_reply.started":"2022-08-23T16:13:46.850310Z","shell.execute_reply":"2022-08-23T16:13:46.997409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=#cbb></a>\n<h2 style=\"color: #6cb4e4; background: #dfefff;  box-shadow: 0px 0px 0px 5px #dfefff;  border: dashed 4px white;  padding: 0.2em 0.5em;\">\n<b>\nMean\n</b></h2> ","metadata":{}},{"cell_type":"code","source":"submit = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')\nsubmit['prediction'] = 0\n\nfor df in dfs:\n    submit['prediction'] += df['prediction']\n    \nsubmit['prediction'] /= len(INF_FILES)\n\nsubmit.to_csv('mean_submission.csv', index=None)","metadata":{"papermill":{"duration":6.463091,"end_time":"2022-07-23T10:57:50.415918","exception":false,"start_time":"2022-07-23T10:57:43.952827","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:13:47.001012Z","iopub.execute_input":"2022-08-23T16:13:47.001432Z","iopub.status.idle":"2022-08-23T16:13:51.719519Z","shell.execute_reply.started":"2022-08-23T16:13:47.001396Z","shell.execute_reply":"2022-08-23T16:13:51.718037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=#cbb></a>\n<h2 style=\"color: #6cb4e4; background: #dfefff;  box-shadow: 0px 0px 0px 5px #dfefff;  border: dashed 4px white;  padding: 0.2em 0.5em;\">\n<b>\nRank\n</b></h2> ","metadata":{}},{"cell_type":"code","source":"submit = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')\nsubmit['prediction'] = 0\n\nfor df in dfs:\n    submit['prediction'] += rankdata(df['prediction'])/df.shape[0]\n    \nsubmit['prediction'] /= len(INF_FILES)\n\nsubmit.to_csv('rank_submission.csv', index=None)\nsubmit.head(20)","metadata":{"papermill":{"duration":7.151167,"end_time":"2022-07-23T10:57:57.569679","exception":false,"start_time":"2022-07-23T10:57:50.418512","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:13:51.721432Z","iopub.execute_input":"2022-08-23T16:13:51.725242Z","iopub.status.idle":"2022-08-23T16:13:58.261538Z","shell.execute_reply.started":"2022-08-23T16:13:51.725184Z","shell.execute_reply":"2022-08-23T16:13:58.260337Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=#cbb></a>\n<h2 style=\"color: #6cb4e4; background: #dfefff;  box-shadow: 0px 0px 0px 5px #dfefff;  border: dashed 4px white;  padding: 0.2em 0.5em;\">\n<b>\nweights\n</b></h2> ","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')\nsubmit['prediction'] = 0\n\nfor df, weight in zip(dfs, weights):\n    submit['prediction'] += (df['prediction'] * weight)\n    \nsubmit['prediction'] /= np.sum(weights)\n\nsubmit.to_csv('mean_submission.csv', index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:13:58.264301Z","iopub.execute_input":"2022-08-23T16:13:58.264896Z","iopub.status.idle":"2022-08-23T16:14:03.067443Z","shell.execute_reply.started":"2022-08-23T16:13:58.264842Z","shell.execute_reply":"2022-08-23T16:14:03.066205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=#cbb></a>\n<h2 style=\"color: #6cb4e4; background: #dfefff;  box-shadow: 0px 0px 0px 5px #dfefff;  border: dashed 4px white;  padding: 0.2em 0.5em;\">\n<b>\nRank Weights\n</b></h2> ","metadata":{}},{"cell_type":"code","source":"\"\"\" Blend \"\"\"\nsubmit = pd.read_csv('../input/amex-default-prediction/sample_submission.csv')\nsubmit['prediction'] = 0\n\nfor df, weight in zip(dfs, weights):\n    submit['prediction'] += (rankdata(df['prediction'])/df.shape[0]) * weight\n    \nsubmit['prediction'] /= len(INF_FILES)\n\nsubmit.to_csv('rank_weights_submission.csv', index=None)\n\n","metadata":{"papermill":{"duration":0.001964,"end_time":"2022-07-23T10:57:57.574233","exception":false,"start_time":"2022-07-23T10:57:57.572269","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2022-08-23T16:14:03.071328Z","iopub.execute_input":"2022-08-23T16:14:03.072606Z","iopub.status.idle":"2022-08-23T16:14:09.700939Z","shell.execute_reply.started":"2022-08-23T16:14:03.072558Z","shell.execute_reply":"2022-08-23T16:14:09.699883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submit.head(20)","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:14:09.704928Z","iopub.execute_input":"2022-08-23T16:14:09.705915Z","iopub.status.idle":"2022-08-23T16:14:09.719514Z","shell.execute_reply.started":"2022-08-23T16:14:09.705858Z","shell.execute_reply":"2022-08-23T16:14:09.718311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(weights)","metadata":{"execution":{"iopub.status.busy":"2022-08-23T16:14:09.721741Z","iopub.execute_input":"2022-08-23T16:14:09.722666Z","iopub.status.idle":"2022-08-23T16:14:09.734550Z","shell.execute_reply.started":"2022-08-23T16:14:09.722611Z","shell.execute_reply":"2022-08-23T16:14:09.733248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}