{"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":"### Thanks for the insights [Martin Kovacevic Buvinic](https://www.kaggle.com/ragnar123)\n","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-07-23T12:01:34.719334Z","iopub.execute_input":"2022-07-23T12:01:34.719737Z","iopub.status.idle":"2022-07-23T12:01:34.724500Z","shell.execute_reply.started":"2022-07-23T12:01:34.719703Z","shell.execute_reply":"2022-07-23T12:01:34.723620Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = [x for x in glob.glob('../input/*/*.csv') if 'amex-default-prediction' not in x]\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-07-23T12:01:34.733644Z","iopub.execute_input":"2022-07-23T12:01:34.734374Z","iopub.status.idle":"2022-07-23T12:01:43.093060Z","shell.execute_reply.started":"2022-07-23T12:01:34.734338Z","shell.execute_reply":"2022-07-23T12:01:43.091876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"paths = [x for x in glob.glob('../input/*/*.csv') if 'amex-default-prediction' not in x]\npaths","metadata":{"execution":{"iopub.status.busy":"2022-07-23T12:01:43.095094Z","iopub.execute_input":"2022-07-23T12:01:43.095750Z","iopub.status.idle":"2022-07-23T12:01:43.109597Z","shell.execute_reply.started":"2022-07-23T12:01:43.095701Z","shell.execute_reply":"2022-07-23T12:01:43.108392Z"},"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-07-23T12:01:43.111242Z","iopub.execute_input":"2022-07-23T12:01:43.112259Z","iopub.status.idle":"2022-07-23T12:01:43.169063Z","shell.execute_reply.started":"2022-07-23T12:01:43.112221Z","shell.execute_reply":"2022-07-23T12:01:43.168174Z"},"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 in dfs:\n    submit['prediction'] += df['prediction']\n    \nsubmit['prediction'] /= 4\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-07-23T12:01:43.171022Z","iopub.execute_input":"2022-07-23T12:01:43.171747Z","iopub.status.idle":"2022-07-23T12:01:47.472407Z","shell.execute_reply.started":"2022-07-23T12:01:43.171714Z","shell.execute_reply":"2022-07-23T12:01:47.470972Z"},"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 in dfs:\n    submit['prediction'] += rankdata(df['prediction'])/df.shape[0]\n    \nsubmit['prediction'] /= 4\n\nsubmit.to_csv('rank_submission.csv', index=None)","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-07-23T12:01:47.474050Z","iopub.execute_input":"2022-07-23T12:01:47.474498Z","iopub.status.idle":"2022-07-23T12:01:52.551445Z","shell.execute_reply.started":"2022-07-23T12:01:47.474454Z","shell.execute_reply":"2022-07-23T12:01:52.550279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"weights = [0.52, 0.87, 0.95, 0.57, 1, 0.8]","metadata":{"execution":{"iopub.status.busy":"2022-07-23T12:01:52.553025Z","iopub.execute_input":"2022-07-23T12:01:52.553453Z","iopub.status.idle":"2022-07-23T12:01:52.558373Z","shell.execute_reply.started":"2022-07-23T12:01:52.553408Z","shell.execute_reply":"2022-07-23T12:01:52.557471Z"},"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-07-23T12:01:52.559633Z","iopub.execute_input":"2022-07-23T12:01:52.560119Z","iopub.status.idle":"2022-07-23T12:01:56.952668Z","shell.execute_reply.started":"2022-07-23T12:01:52.560087Z","shell.execute_reply":"2022-07-23T12:01:56.951736Z"},"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'] += (rankdata(df['prediction'])/df.shape[0]) * weight\n    \nsubmit['prediction'] /= 4\n\nsubmit.to_csv('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-07-23T12:01:56.953924Z","iopub.execute_input":"2022-07-23T12:01:56.954421Z","iopub.status.idle":"2022-07-23T12:02:01.601477Z","shell.execute_reply.started":"2022-07-23T12:01:56.954388Z","shell.execute_reply":"2022-07-23T12:02:01.600302Z"},"trusted":true},"execution_count":null,"outputs":[]}]}