{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":35332,"databundleVersionId":3723648,"sourceType":"competition"}],"dockerImageVersionId":30213,"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":"2022-08-10T10:51:14.680666Z","iopub.execute_input":"2022-08-10T10:51:14.681436Z","iopub.status.idle":"2022-08-10T10:51:14.709939Z","shell.execute_reply.started":"2022-08-10T10:51:14.681316Z","shell.execute_reply":"2022-08-10T10:51:14.709116Z"},"trusted":true},"outputs":[{"name":"stdout","text":"/kaggle/input/amex-default-prediction/sample_submission.csv\n/kaggle/input/amex-default-prediction/train_data.csv\n/kaggle/input/amex-default-prediction/test_data.csv\n/kaggle/input/amex-default-prediction/train_labels.csv\n","output_type":"stream"}],"execution_count":1},{"cell_type":"code","source":"#!apt-get remove swig","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:51:34.640863Z","iopub.execute_input":"2022-08-10T10:51:34.641269Z","iopub.status.idle":"2022-08-10T10:51:37.629009Z","shell.execute_reply.started":"2022-08-10T10:51:34.641235Z","shell.execute_reply":"2022-08-10T10:51:37.627833Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Reading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nPackage 'swig' is not installed, so not removed\n0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.\n","output_type":"stream"}],"execution_count":2},{"cell_type":"code","source":"#!apt-get install swig3.0 build-essential -y","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:51:51.605895Z","iopub.execute_input":"2022-08-10T10:51:51.606659Z","iopub.status.idle":"2022-08-10T10:51:57.263447Z","shell.execute_reply.started":"2022-08-10T10:51:51.606613Z","shell.execute_reply":"2022-08-10T10:51:57.262255Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Reading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nbuild-essential is already the newest version (12.8ubuntu1.1).\nSuggested packages:\n  swig3.0-examples swig3.0-doc\nThe following NEW packages will be installed:\n  swig3.0\n0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.\nNeed to get 1109 kB of archives.\nAfter this operation, 5555 kB of additional disk space will be used.\nGet:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 swig3.0 amd64 3.0.12-2.2ubuntu1 [1109 kB]\nFetched 1109 kB in 0s (4648 kB/s)\nSelecting previously unselected package swig3.0.\n(Reading database ... 106350 files and directories currently installed.)\nPreparing to unpack .../swig3.0_3.0.12-2.2ubuntu1_amd64.deb ...\nUnpacking swig3.0 (3.0.12-2.2ubuntu1) ...\nSetting up swig3.0 (3.0.12-2.2ubuntu1) ...\nProcessing triggers for man-db (2.9.1-1) ...\n","output_type":"stream"}],"execution_count":3},{"cell_type":"code","source":"#!ln -s /usr/bin/swig3.0 /usr/bin/swig","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:52:22.146122Z","iopub.execute_input":"2022-08-10T10:52:22.146531Z","iopub.status.idle":"2022-08-10T10:52:23.183947Z","shell.execute_reply.started":"2022-08-10T10:52:22.146497Z","shell.execute_reply":"2022-08-10T10:52:23.182539Z"},"trusted":true},"outputs":[{"name":"stdout","text":"ln: failed to create symbolic link '/usr/bin/swig': File exists\n","output_type":"stream"}],"execution_count":5},{"cell_type":"code","source":"#!apt-get install build-essential","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:52:33.960651Z","iopub.execute_input":"2022-08-10T10:52:33.961075Z","iopub.status.idle":"2022-08-10T10:52:36.538986Z","shell.execute_reply.started":"2022-08-10T10:52:33.961037Z","shell.execute_reply":"2022-08-10T10:52:36.537669Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Reading package lists... Done\nBuilding dependency tree       \nReading state information... Done\nbuild-essential is already the newest version (12.8ubuntu1.1).\n0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.\n","output_type":"stream"}],"execution_count":6},{"cell_type":"code","source":"#!pip install --upgrade setuptools","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:52:57.300794Z","iopub.execute_input":"2022-08-10T10:52:57.30124Z","iopub.status.idle":"2022-08-10T10:53:22.692229Z","shell.execute_reply.started":"2022-08-10T10:52:57.301201Z","shell.execute_reply":"2022-08-10T10:53:22.691217Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Requirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (59.8.0)\nCollecting setuptools\n  Downloading setuptools-63.4.2-py3-none-any.whl (1.2 MB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m0m\n\u001b[?25hInstalling collected packages: setuptools\n  Attempting uninstall: setuptools\n    Found existing installation: setuptools 59.8.0\n    Uninstalling setuptools-59.8.0:\n      Successfully uninstalled setuptools-59.8.0\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\nbeatrix-jupyterlab 3.1.7 requires google-cloud-bigquery-storage, which is not installed.\ncloud-tpu-client 0.10 requires google-api-python-client==1.8.0, but you have google-api-python-client 1.12.11 which is incompatible.\nallennlp 2.10.0 requires protobuf==3.20.0, but you have protobuf 3.19.4 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed setuptools-63.4.2\n\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n\u001b[0m","output_type":"stream"}],"execution_count":7},{"cell_type":"code","source":"#!pip install auto-sklearn","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:53:42.121051Z","iopub.execute_input":"2022-08-10T10:53:42.121514Z","iopub.status.idle":"2022-08-10T10:54:17.431543Z","shell.execute_reply.started":"2022-08-10T10:53:42.121477Z","shell.execute_reply":"2022-08-10T10:54:17.430351Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Collecting auto-sklearn\n  Downloading auto-sklearn-0.14.7.tar.gz (6.4 MB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.4/6.4 MB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m0:01\u001b[0m\n\u001b[?25h  Preparing metadata (setup.py) ... \u001b[?25ldone\n\u001b[?25hRequirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (63.4.2)\nRequirement already satisfied: typing_extensions in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (4.1.1)\nCollecting distro\n  Downloading distro-1.7.0-py3-none-any.whl (20 kB)\nRequirement already satisfied: numpy>=1.9.0 in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (1.21.6)\nRequirement already satisfied: scipy>=1.7.0 in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (1.7.3)\nRequirement already satisfied: joblib in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (1.0.1)\nCollecting scikit-learn<0.25.0,>=0.24.0\n  Downloading scikit_learn-0.24.2-cp37-cp37m-manylinux2010_x86_64.whl (22.3 MB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m22.3/22.3 MB\u001b[0m \u001b[31m24.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n\u001b[?25hRequirement already satisfied: dask>=2021.12 in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (2022.2.0)\nRequirement already satisfied: distributed>=2012.12 in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (2022.2.0)\nRequirement already satisfied: pyyaml in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (6.0)\nRequirement already satisfied: pandas>=1.0 in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (1.3.5)\nCollecting liac-arff\n  Downloading liac-arff-2.5.0.tar.gz (13 kB)\n  Preparing metadata (setup.py) ... \u001b[?25ldone\n\u001b[?25hRequirement already satisfied: threadpoolctl in /opt/conda/lib/python3.7/site-packages (from auto-sklearn) (3.1.0)\nCollecting ConfigSpace<0.5,>=0.4.21\n  Downloading ConfigSpace-0.4.21-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.3/4.3 MB\u001b[0m \u001b[31m34.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m:00:01\u001b[0m\n\u001b[?25hCollecting pynisher<0.7,>=0.6.3\n  Downloading pynisher-0.6.4.tar.gz (11 kB)\n  Preparing metadata (setup.py) ... \u001b[?25ldone\n\u001b[?25hCollecting pyrfr<0.9,>=0.8.1\n  Downloading pyrfr-0.8.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.4/4.4 MB\u001b[0m \u001b[31m35.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m:00:01\u001b[0m\n\u001b[?25hCollecting smac<1.3,>=1.2\n  Downloading smac-1.2.tar.gz (260 kB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m260.9/260.9 kB\u001b[0m \u001b[31m20.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25h  Preparing metadata (setup.py) ... \u001b[?25ldone\n\u001b[?25hRequirement already satisfied: cython in /opt/conda/lib/python3.7/site-packages (from ConfigSpace<0.5,>=0.4.21->auto-sklearn) (0.29.30)\nRequirement already satisfied: pyparsing in /opt/conda/lib/python3.7/site-packages (from ConfigSpace<0.5,>=0.4.21->auto-sklearn) (3.0.9)\nRequirement already satisfied: fsspec>=0.6.0 in /opt/conda/lib/python3.7/site-packages (from dask>=2021.12->auto-sklearn) (2022.5.0)\nRequirement already satisfied: toolz>=0.8.2 in /opt/conda/lib/python3.7/site-packages (from dask>=2021.12->auto-sklearn) (0.11.2)\nRequirement already satisfied: partd>=0.3.10 in /opt/conda/lib/python3.7/site-packages (from dask>=2021.12->auto-sklearn) (1.2.0)\nRequirement already satisfied: cloudpickle>=1.1.1 in /opt/conda/lib/python3.7/site-packages (from dask>=2021.12->auto-sklearn) (2.1.0)\nRequirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.7/site-packages (from dask>=2021.12->auto-sklearn) (21.3)\nRequirement already satisfied: tblib>=1.6.0 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (1.7.0)\nRequirement already satisfied: psutil>=5.0 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (5.9.1)\nRequirement already satisfied: sortedcontainers!=2.0.0,!=2.0.1 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (2.4.0)\nRequirement already satisfied: msgpack>=0.6.0 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (1.0.4)\nRequirement already satisfied: jinja2 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (3.1.2)\nRequirement already satisfied: zict>=0.1.3 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (2.2.0)\nRequirement already satisfied: click>=6.6 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (8.0.4)\nRequirement already satisfied: tornado>=5 in /opt/conda/lib/python3.7/site-packages (from distributed>=2012.12->auto-sklearn) (6.1)\nRequirement already satisfied: python-dateutil>=2.7.3 in /opt/conda/lib/python3.7/site-packages (from pandas>=1.0->auto-sklearn) (2.8.2)\nRequirement already satisfied: pytz>=2017.3 in /opt/conda/lib/python3.7/site-packages (from pandas>=1.0->auto-sklearn) (2022.1)\nCollecting emcee>=3.0.0\n  Downloading emcee-3.1.2-py2.py3-none-any.whl (46 kB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.2/46.2 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hRequirement already satisfied: importlib-metadata in /opt/conda/lib/python3.7/site-packages (from click>=6.6->distributed>=2012.12->auto-sklearn) (4.12.0)\nRequirement already satisfied: locket in /opt/conda/lib/python3.7/site-packages (from partd>=0.3.10->dask>=2021.12->auto-sklearn) (1.0.0)\nRequirement already satisfied: six>=1.5 in /opt/conda/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas>=1.0->auto-sklearn) (1.16.0)\nRequirement already satisfied: heapdict in /opt/conda/lib/python3.7/site-packages (from zict>=0.1.3->distributed>=2012.12->auto-sklearn) (1.0.1)\nRequirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.7/site-packages (from jinja2->distributed>=2012.12->auto-sklearn) (2.0.1)\nRequirement already satisfied: zipp>=0.5 in /opt/conda/lib/python3.7/site-packages (from importlib-metadata->click>=6.6->distributed>=2012.12->auto-sklearn) (3.8.0)\nBuilding wheels for collected packages: auto-sklearn, pynisher, smac, liac-arff\n  Building wheel for auto-sklearn (setup.py) ... \u001b[?25ldone\n\u001b[?25h  Created wheel for auto-sklearn: filename=auto_sklearn-0.14.7-py3-none-any.whl size=6602870 sha256=eafa491efb49d3d1c38e81267a5c5222ad6587744810b8c64e99c2e361e8b696\n  Stored in directory: /root/.cache/pip/wheels/ba/43/5c/2fbe6fd19e3af314cbc4aa808378068d8ddd6792064f4a2448\n  Building wheel for pynisher (setup.py) ... \u001b[?25ldone\n\u001b[?25h  Created wheel for pynisher: filename=pynisher-0.6.4-py3-none-any.whl size=7027 sha256=48cdc16f6a89019871d2224f052c06b33b4f887556f2a552a50c413881e0ae3b\n  Stored in directory: /root/.cache/pip/wheels/42/71/95/7555ec3253e1ba8add72ae5febf1b015d297f3b73ba296d6f6\n  Building wheel for smac (setup.py) ... \u001b[?25ldone\n\u001b[?25h  Created wheel for smac: filename=smac-1.2-py3-none-any.whl size=215919 sha256=8072225d2325d65821868e8643f3aa34841999ca02885d84ab94e6f20c5fe022\n  Stored in directory: /root/.cache/pip/wheels/ad/95/67/6afc6b04d3715070c853d0a9d7c7b1fb822def38671dfbbb9f\n  Building wheel for liac-arff (setup.py) ... \u001b[?25ldone\n\u001b[?25h  Created wheel for liac-arff: filename=liac_arff-2.5.0-py3-none-any.whl size=11716 sha256=ec26964156794176ebc2062315fe29b235d497a1b732b3a4b7594b2a3e648783\n  Stored in directory: /root/.cache/pip/wheels/1f/0f/15/332ca86cbebf25ddf98518caaf887945fbe1712b97a0f2493b\nSuccessfully built auto-sklearn pynisher smac liac-arff\nInstalling collected packages: pyrfr, pynisher, liac-arff, emcee, distro, scikit-learn, ConfigSpace, smac, auto-sklearn\n  Attempting uninstall: scikit-learn\n    Found existing installation: scikit-learn 1.0.2\n    Uninstalling scikit-learn-1.0.2:\n      Successfully uninstalled scikit-learn-1.0.2\n\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\nyellowbrick 1.4 requires scikit-learn>=1.0.0, but you have scikit-learn 0.24.2 which is incompatible.\npdpbox 0.2.1 requires matplotlib==3.1.1, but you have matplotlib 3.5.2 which is incompatible.\nmlxtend 0.20.0 requires scikit-learn>=1.0.2, but you have scikit-learn 0.24.2 which is incompatible.\nimbalanced-learn 0.9.0 requires scikit-learn>=1.0.1, but you have scikit-learn 0.24.2 which is incompatible.\ngplearn 0.4.2 requires scikit-learn>=1.0.2, but you have scikit-learn 0.24.2 which is incompatible.\nallennlp 2.10.0 requires protobuf==3.20.0, but you have protobuf 3.19.4 which is incompatible.\nallennlp 2.10.0 requires scikit-learn>=1.0.1, but you have scikit-learn 0.24.2 which is incompatible.\u001b[0m\u001b[31m\n\u001b[0mSuccessfully installed ConfigSpace-0.4.21 auto-sklearn-0.14.7 distro-1.7.0 emcee-3.1.2 liac-arff-2.5.0 pynisher-0.6.4 pyrfr-0.8.3 scikit-learn-0.24.2 smac-1.2\n\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n\u001b[0m","output_type":"stream"}],"execution_count":8},{"cell_type":"code","source":"import autosklearn.classification","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:57:10.800711Z","iopub.execute_input":"2022-08-10T10:57:10.801168Z","iopub.status.idle":"2022-08-10T10:57:11.885212Z","shell.execute_reply.started":"2022-08-10T10:57:10.801121Z","shell.execute_reply":"2022-08-10T10:57:11.883957Z"},"trusted":true},"outputs":[],"execution_count":9},{"cell_type":"code","source":"import dask.dataframe as dd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom dask.diagnostics import ProgressBar\nimport warnings \nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:57:46.219721Z","iopub.execute_input":"2022-08-10T10:57:46.220158Z","iopub.status.idle":"2022-08-10T10:57:46.768579Z","shell.execute_reply.started":"2022-08-10T10:57:46.22012Z","shell.execute_reply":"2022-08-10T10:57:46.767545Z"},"trusted":true},"outputs":[],"execution_count":10},{"cell_type":"markdown","source":"### Importing all the necessary file","metadata":{}},{"cell_type":"code","source":"train=dd.read_csv('/kaggle/input/amex-default-prediction/train_data.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:58:23.980747Z","iopub.execute_input":"2022-08-10T10:58:23.981723Z","iopub.status.idle":"2022-08-10T10:58:24.214563Z","shell.execute_reply.started":"2022-08-10T10:58:23.98168Z","shell.execute_reply":"2022-08-10T10:58:24.213422Z"},"trusted":true},"outputs":[],"execution_count":11},{"cell_type":"code","source":"train1 = train.drop_duplicates(subset=['customer_ID'], keep='last').compute()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T10:58:36.400868Z","iopub.execute_input":"2022-08-10T10:58:36.401781Z","iopub.status.idle":"2022-08-10T11:01:12.395436Z","shell.execute_reply.started":"2022-08-10T10:58:36.401727Z","shell.execute_reply":"2022-08-10T11:01:12.394377Z"},"trusted":true},"outputs":[],"execution_count":12},{"cell_type":"code","source":"train1['customer_ID'].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:24.642017Z","iopub.execute_input":"2022-08-10T11:01:24.642454Z","iopub.status.idle":"2022-08-10T11:01:24.844245Z","shell.execute_reply.started":"2022-08-10T11:01:24.642418Z","shell.execute_reply":"2022-08-10T11:01:24.842974Z"},"trusted":true},"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"458913"},"metadata":{}}],"execution_count":13},{"cell_type":"markdown","source":"### Reading and Sorting data by dropping any duplicates that exists","metadata":{}},{"cell_type":"code","source":"df = train1.filter(['customer_ID','S_2','P_2','D_39','B_1','R_1','S_3',\n                 'D_41','D_43','D_44','B_4','D_45','B_5','R_2','D_46',\n                 'D_47','D_48','B_6','B_7','B_8','D_51','B_9','R_3',\n                 'D_52','P_3','S_5','S_6','D_54','B_12','R_5','D_58',\n                 'B_14','D_59','D_60','D_61','B_15','S_11','D_62','D_63',\n                 'D_64','D_65','B_16','B_18','B_19','D_68','S_12','R_6','S_13',\n                 'B_21','D_69','B_22','D_70','D_71','D_72','S_15','B_23','P_4',\n                 'D_75','B_24','R_7','B_25','B_26','D_78','D_79','S_16','D_80',\n                 'R_10','R_11','B_27','D_81','S_17','R_12','R_13','D_83','R_14',\n                 'R_15','D_84','R_16','B_30','S_18','D_86','R_17','R_18','S_19',\n                 'R_19','B_32','S_20','R_20','R_21','D_89','R_22','R_23','D_91',\n                 'D_92','D_93','D_94','R_24','R_25','D_96','S_22','S_23','S_25',\n                 'S_26','D_102','D_103','B_36','R_27','D_109','D_112','S_27',\n                 'D_113','D_114','D_115','D_116','D_117','D_120','D_121','D_122',\n                 'D_123','D_124','D_125','D_126','D_127','D_128','B_41','D_130',\n                 'D_133','R_28','D_139','D_140','D_144','D_145','B_3', 'B_20'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:27.819977Z","iopub.execute_input":"2022-08-10T11:01:27.820438Z","iopub.status.idle":"2022-08-10T11:01:28.00657Z","shell.execute_reply.started":"2022-08-10T11:01:27.8204Z","shell.execute_reply":"2022-08-10T11:01:28.005379Z"},"trusted":true},"outputs":[],"execution_count":14},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:31.700068Z","iopub.execute_input":"2022-08-10T11:01:31.700483Z","iopub.status.idle":"2022-08-10T11:01:31.708264Z","shell.execute_reply.started":"2022-08-10T11:01:31.700451Z","shell.execute_reply":"2022-08-10T11:01:31.707055Z"},"trusted":true},"outputs":[{"execution_count":15,"output_type":"execute_result","data":{"text/plain":"(458913, 134)"},"metadata":{}}],"execution_count":15},{"cell_type":"code","source":"train_label=dd.read_csv('/kaggle/input/amex-default-prediction/train_labels.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:35.34007Z","iopub.execute_input":"2022-08-10T11:01:35.340512Z","iopub.status.idle":"2022-08-10T11:01:35.367085Z","shell.execute_reply.started":"2022-08-10T11:01:35.340478Z","shell.execute_reply":"2022-08-10T11:01:35.366112Z"},"trusted":true},"outputs":[],"execution_count":16},{"cell_type":"code","source":"train_label1 = train_label.drop_duplicates(subset=['customer_ID'], keep='last').compute()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:38.479842Z","iopub.execute_input":"2022-08-10T11:01:38.480861Z","iopub.status.idle":"2022-08-10T11:01:39.719364Z","shell.execute_reply.started":"2022-08-10T11:01:38.480811Z","shell.execute_reply":"2022-08-10T11:01:39.717943Z"},"trusted":true},"outputs":[],"execution_count":17},{"cell_type":"code","source":"train_label1['customer_ID'].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:43.239853Z","iopub.execute_input":"2022-08-10T11:01:43.240284Z","iopub.status.idle":"2022-08-10T11:01:43.433177Z","shell.execute_reply.started":"2022-08-10T11:01:43.240247Z","shell.execute_reply":"2022-08-10T11:01:43.432107Z"},"trusted":true},"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"458913"},"metadata":{}}],"execution_count":18},{"cell_type":"code","source":"tdf = pd.merge(df,train_label1, on='customer_ID')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:46.239684Z","iopub.execute_input":"2022-08-10T11:01:46.240386Z","iopub.status.idle":"2022-08-10T11:01:47.742172Z","shell.execute_reply.started":"2022-08-10T11:01:46.240343Z","shell.execute_reply":"2022-08-10T11:01:47.740804Z"},"trusted":true},"outputs":[],"execution_count":19},{"cell_type":"code","source":"tdf['customer_ID'].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:01:50.419961Z","iopub.execute_input":"2022-08-10T11:01:50.421171Z","iopub.status.idle":"2022-08-10T11:01:50.62264Z","shell.execute_reply.started":"2022-08-10T11:01:50.421123Z","shell.execute_reply":"2022-08-10T11:01:50.621341Z"},"trusted":true},"outputs":[{"execution_count":20,"output_type":"execute_result","data":{"text/plain":"458913"},"metadata":{}}],"execution_count":20},{"cell_type":"markdown","source":"### Trying to reduce the memory usage","metadata":{}},{"cell_type":"code","source":"def reduce_mem_usage(gdt, verbose=True):\n    numerics = ['int16', 'int32', 'int64', 'float16', 'float32', 'float64']\n    start_mem = gdt.memory_usage().sum()/1024**2\n    for col in gdt.columns:\n        col_type = gdt[col].dtypes\n        if col_type in numerics:\n            c_min = gdt[col].min()\n            c_max = gdt[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min >np.iinfo(np.int8).min and c_max <np.iinfo(np.int8).max:\n                    gdt[col] = gdt[col].astype(np.int8)\n                elif c_min >np.iinfo(np.int16).min and c_max <np.iinfo(np.int16).max:\n                    gdt[col] = gdt[col].astype(np.int16)\n                elif c_min >np.iinfo(np.int32).min and c_max <np.iinfo(np.int32).max:\n                    gdt[col] = gdt[col].astype(np.int32)\n                elif c_min >np.iinfo(np.int64).min and c_max <np.iinfo(np.int64).max:\n                    gdt[col] = gdt[col].astype(np.int64)\n                else:\n                    if c_min >np.finfo(np.float32).min and c_max <np.finfo(np.float32).max:\n                        gdt[col] = gdt[col].astype(np.float32)\n                    else:\n                        gdt[col] = gdt[col].astype(np.float64)\n    end_mem = gdt.memory_usage().sum()/1024**2\n    if verbose: print('Mem. usage decreased to {:5.2f} Mb ({:.1f}% reduction)'.format(end_mem, 100*(start_mem-end_mem)/start_mem))\n    return gdt","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:02:21.831195Z","iopub.execute_input":"2022-08-10T11:02:21.83165Z","iopub.status.idle":"2022-08-10T11:02:21.844445Z","shell.execute_reply.started":"2022-08-10T11:02:21.831615Z","shell.execute_reply":"2022-08-10T11:02:21.843281Z"},"trusted":true},"outputs":[],"execution_count":21},{"cell_type":"code","source":"reduce_mem_usage(tdf, verbose=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:02:40.240387Z","iopub.execute_input":"2022-08-10T11:02:40.240825Z","iopub.status.idle":"2022-08-10T11:02:40.906485Z","shell.execute_reply.started":"2022-08-10T11:02:40.240787Z","shell.execute_reply":"2022-08-10T11:02:40.9053Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Mem. usage decreased to 473.10 Mb (0.6% reduction)\n","output_type":"stream"},{"execution_count":22,"output_type":"execute_result","data":{"text/plain":"                                              customer_ID         S_2  \\\n0       0000099d6bd597052cdcda90ffabf56573fe9d7c79be5f...  2018-03-13   \n1       00000fd6641609c6ece5454664794f0340ad84dddce9a2...  2018-03-25   \n2       00001b22f846c82c51f6e3958ccd81970162bae8b007e8...  2018-03-12   \n3       000041bdba6ecadd89a52d11886e8eaaec9325906c9723...  2018-03-29   \n4       00007889e4fcd2614b6cbe7f8f3d2e5c728eca32d9eb8a...  2018-03-30   \n...                                                   ...         ...   \n458908  ffff41c8a52833b56430603969b9ca48d208e7c192c6a4...  2018-03-31   \n458909  ffff518bb2075e4816ee3fe9f3b152c57fc0e6f01bf7fd...  2018-03-22   \n458910  ffff9984b999fccb2b6127635ed0736dda94e544e67e02...  2018-03-07   \n458911  ffffa5c46bc8de74f5a4554e74e239c8dee6b9baf38814...  2018-03-23   \n458912  fffff1d38b785cef84adeace64f8f83db3a0c31e8d92ea...  2018-03-14   \n\n             P_2      D_39       B_1       R_1       S_3      D_41      D_43  \\\n0       0.934745  0.009119  0.009382  0.006104  0.135021  0.001604       NaN   \n1       0.880519  0.178126  0.034684  0.006911  0.165509  0.005552  0.060646   \n2       0.880875  0.009704  0.004284  0.006450       NaN  0.003796       NaN   \n3       0.621776  0.001083  0.012564  0.007829  0.287766  0.004532  0.046104   \n4       0.871900  0.005573  0.007679  0.001247       NaN  0.000231  0.044671   \n...          ...       ...       ...       ...       ...       ...       ...   \n458908  0.844229  0.447585  0.028515  0.001928  0.128707  0.003482  0.113053   \n458909  0.831279  0.033670  0.292360  0.006953       NaN  0.005791  0.134540   \n458910  0.800522  0.267018  0.020563  0.000957  0.066648  0.007424  0.049778   \n458911  0.754129  0.008619  0.015838  0.000993  0.408849  0.003392  0.046125   \n458912  0.982175  0.002474  0.000077  0.000809  0.119165  0.003287  0.013455   \n\n            D_44  ...     D_130     D_133      R_28     D_139     D_140  \\\n0       0.003258  ...  0.004186  0.006210  0.002715  0.007186  0.004234   \n1       0.008781  ...  0.002202  0.002996  0.001701  0.002980  0.007479   \n2       0.000628  ...  0.002654  0.009881  0.007691  0.007383  0.006623   \n3       0.007792  ...  0.000060  0.001789  0.005140  0.002704  0.006184   \n4       0.002436  ...  1.006119  0.005045  0.003706  0.002974  0.004162   \n...          ...  ...       ...       ...       ...       ...       ...   \n458908  0.002280  ...  0.006699  0.002072  0.004589  0.007917  0.001520   \n458909  0.132158  ...  1.005134  1.128725  0.004884  0.004393  0.006185   \n458910  0.001022  ...  0.003907  0.004513  0.008924  0.006035  0.002869   \n458911  0.133062  ...  1.001044  0.000479  0.006828  1.009894  0.004478   \n458912  0.006794  ...  0.000633  0.006312  0.005429  0.007316  0.002888   \n\n           D_144     D_145       B_3      B_20  target  \n0       0.002970  0.008533  0.007174  0.007630       0  \n1       0.003169  0.008514  0.005068  0.004319       0  \n2       0.000834  0.003444  0.007196  0.002835       0  \n3       0.005560  0.002983  0.009937  0.008557       0  \n4       0.006944  0.000905  0.005528  0.008807       0  \n...          ...       ...       ...       ...     ...  \n458908  0.003009  0.004843  0.005893  0.000525       0  \n458909  0.009230  0.006435  0.233078  1.001117       0  \n458910  0.000340  0.002148  0.006314  0.006032       0  \n458911  0.002502  0.185527  0.050048  0.180408       1  \n458912  0.003184  0.001914  0.014092  0.006743       0  \n\n[458913 rows x 135 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>S_2</th>\n      <th>P_2</th>\n      <th>D_39</th>\n      <th>B_1</th>\n      <th>R_1</th>\n      <th>S_3</th>\n      <th>D_41</th>\n      <th>D_43</th>\n      <th>D_44</th>\n      <th>...</th>\n      <th>D_130</th>\n      <th>D_133</th>\n      <th>R_28</th>\n      <th>D_139</th>\n      <th>D_140</th>\n      <th>D_144</th>\n      <th>D_145</th>\n      <th>B_3</th>\n      <th>B_20</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>0000099d6bd597052cdcda90ffabf56573fe9d7c79be5f...</td>\n      <td>2018-03-13</td>\n      <td>0.934745</td>\n      <td>0.009119</td>\n      <td>0.009382</td>\n      <td>0.006104</td>\n      <td>0.135021</td>\n      <td>0.001604</td>\n      <td>NaN</td>\n      <td>0.003258</td>\n      <td>...</td>\n      <td>0.004186</td>\n      <td>0.006210</td>\n      <td>0.002715</td>\n      <td>0.007186</td>\n      <td>0.004234</td>\n      <td>0.002970</td>\n      <td>0.008533</td>\n      <td>0.007174</td>\n      <td>0.007630</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>00000fd6641609c6ece5454664794f0340ad84dddce9a2...</td>\n      <td>2018-03-25</td>\n      <td>0.880519</td>\n      <td>0.178126</td>\n      <td>0.034684</td>\n      <td>0.006911</td>\n      <td>0.165509</td>\n      <td>0.005552</td>\n      <td>0.060646</td>\n      <td>0.008781</td>\n      <td>...</td>\n      <td>0.002202</td>\n      <td>0.002996</td>\n      <td>0.001701</td>\n      <td>0.002980</td>\n      <td>0.007479</td>\n      <td>0.003169</td>\n      <td>0.008514</td>\n      <td>0.005068</td>\n      <td>0.004319</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>00001b22f846c82c51f6e3958ccd81970162bae8b007e8...</td>\n      <td>2018-03-12</td>\n      <td>0.880875</td>\n      <td>0.009704</td>\n      <td>0.004284</td>\n      <td>0.006450</td>\n      <td>NaN</td>\n      <td>0.003796</td>\n      <td>NaN</td>\n      <td>0.000628</td>\n      <td>...</td>\n      <td>0.002654</td>\n      <td>0.009881</td>\n      <td>0.007691</td>\n      <td>0.007383</td>\n      <td>0.006623</td>\n      <td>0.000834</td>\n      <td>0.003444</td>\n      <td>0.007196</td>\n      <td>0.002835</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>000041bdba6ecadd89a52d11886e8eaaec9325906c9723...</td>\n      <td>2018-03-29</td>\n      <td>0.621776</td>\n      <td>0.001083</td>\n      <td>0.012564</td>\n      <td>0.007829</td>\n      <td>0.287766</td>\n      <td>0.004532</td>\n      <td>0.046104</td>\n      <td>0.007792</td>\n      <td>...</td>\n      <td>0.000060</td>\n      <td>0.001789</td>\n      <td>0.005140</td>\n      <td>0.002704</td>\n      <td>0.006184</td>\n      <td>0.005560</td>\n      <td>0.002983</td>\n      <td>0.009937</td>\n      <td>0.008557</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>00007889e4fcd2614b6cbe7f8f3d2e5c728eca32d9eb8a...</td>\n      <td>2018-03-30</td>\n      <td>0.871900</td>\n      <td>0.005573</td>\n      <td>0.007679</td>\n      <td>0.001247</td>\n      <td>NaN</td>\n      <td>0.000231</td>\n      <td>0.044671</td>\n      <td>0.002436</td>\n      <td>...</td>\n      <td>1.006119</td>\n      <td>0.005045</td>\n      <td>0.003706</td>\n      <td>0.002974</td>\n      <td>0.004162</td>\n      <td>0.006944</td>\n      <td>0.000905</td>\n      <td>0.005528</td>\n      <td>0.008807</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>458908</th>\n      <td>ffff41c8a52833b56430603969b9ca48d208e7c192c6a4...</td>\n      <td>2018-03-31</td>\n      <td>0.844229</td>\n      <td>0.447585</td>\n      <td>0.028515</td>\n      <td>0.001928</td>\n      <td>0.128707</td>\n      <td>0.003482</td>\n      <td>0.113053</td>\n      <td>0.002280</td>\n      <td>...</td>\n      <td>0.006699</td>\n      <td>0.002072</td>\n      <td>0.004589</td>\n      <td>0.007917</td>\n      <td>0.001520</td>\n      <td>0.003009</td>\n      <td>0.004843</td>\n      <td>0.005893</td>\n      <td>0.000525</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>458909</th>\n      <td>ffff518bb2075e4816ee3fe9f3b152c57fc0e6f01bf7fd...</td>\n      <td>2018-03-22</td>\n      <td>0.831279</td>\n      <td>0.033670</td>\n      <td>0.292360</td>\n      <td>0.006953</td>\n      <td>NaN</td>\n      <td>0.005791</td>\n      <td>0.134540</td>\n      <td>0.132158</td>\n      <td>...</td>\n      <td>1.005134</td>\n      <td>1.128725</td>\n      <td>0.004884</td>\n      <td>0.004393</td>\n      <td>0.006185</td>\n      <td>0.009230</td>\n      <td>0.006435</td>\n      <td>0.233078</td>\n      <td>1.001117</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>458910</th>\n      <td>ffff9984b999fccb2b6127635ed0736dda94e544e67e02...</td>\n      <td>2018-03-07</td>\n      <td>0.800522</td>\n      <td>0.267018</td>\n      <td>0.020563</td>\n      <td>0.000957</td>\n      <td>0.066648</td>\n      <td>0.007424</td>\n      <td>0.049778</td>\n      <td>0.001022</td>\n      <td>...</td>\n      <td>0.003907</td>\n      <td>0.004513</td>\n      <td>0.008924</td>\n      <td>0.006035</td>\n      <td>0.002869</td>\n      <td>0.000340</td>\n      <td>0.002148</td>\n      <td>0.006314</td>\n      <td>0.006032</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>458911</th>\n      <td>ffffa5c46bc8de74f5a4554e74e239c8dee6b9baf38814...</td>\n      <td>2018-03-23</td>\n      <td>0.754129</td>\n      <td>0.008619</td>\n      <td>0.015838</td>\n      <td>0.000993</td>\n      <td>0.408849</td>\n      <td>0.003392</td>\n      <td>0.046125</td>\n      <td>0.133062</td>\n      <td>...</td>\n      <td>1.001044</td>\n      <td>0.000479</td>\n      <td>0.006828</td>\n      <td>1.009894</td>\n      <td>0.004478</td>\n      <td>0.002502</td>\n      <td>0.185527</td>\n      <td>0.050048</td>\n      <td>0.180408</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>458912</th>\n      <td>fffff1d38b785cef84adeace64f8f83db3a0c31e8d92ea...</td>\n      <td>2018-03-14</td>\n      <td>0.982175</td>\n      <td>0.002474</td>\n      <td>0.000077</td>\n      <td>0.000809</td>\n      <td>0.119165</td>\n      <td>0.003287</td>\n      <td>0.013455</td>\n      <td>0.006794</td>\n      <td>...</td>\n      <td>0.000633</td>\n      <td>0.006312</td>\n      <td>0.005429</td>\n      <td>0.007316</td>\n      <td>0.002888</td>\n      <td>0.003184</td>\n      <td>0.001914</td>\n      <td>0.014092</td>\n      <td>0.006743</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n<p>458913 rows × 135 columns</p>\n</div>"},"metadata":{}}],"execution_count":22},{"cell_type":"code","source":"tdf['customer_ID'].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:02:54.220692Z","iopub.execute_input":"2022-08-10T11:02:54.221129Z","iopub.status.idle":"2022-08-10T11:02:54.425043Z","shell.execute_reply.started":"2022-08-10T11:02:54.221092Z","shell.execute_reply":"2022-08-10T11:02:54.423732Z"},"trusted":true},"outputs":[{"execution_count":23,"output_type":"execute_result","data":{"text/plain":"458913"},"metadata":{}}],"execution_count":23},{"cell_type":"markdown","source":"### Outliers detection and Capping function","metadata":{}},{"cell_type":"code","source":"def iqr_capping(sdf,cols,factor):\n    for col in cols:\n        q1 = sdf[col].quantile(0.25)\n        q3 = sdf[col].quantile(0.75)\n        iqr = q3-q1\n        upper_whisker = q3+(factor*iqr)\n        lower_whisker = q1-(factor*iqr)\n        sdf[col] = np.where(sdf[col]>upper_whisker,upper_whisker,np.where(sdf[col]<lower_whisker,lower_whisker,sdf[col]))","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:03:26.600738Z","iopub.execute_input":"2022-08-10T11:03:26.601201Z","iopub.status.idle":"2022-08-10T11:03:26.60899Z","shell.execute_reply.started":"2022-08-10T11:03:26.601159Z","shell.execute_reply":"2022-08-10T11:03:26.607713Z"},"trusted":true},"outputs":[],"execution_count":24},{"cell_type":"code","source":"from pandas.api.types import is_numeric_dtype\nnum_col = []\nfor nocol in tdf.columns:\n    if (is_numeric_dtype(tdf[nocol]) == True):\n        num_col.append(nocol) ","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:03:38.085989Z","iopub.execute_input":"2022-08-10T11:03:38.086389Z","iopub.status.idle":"2022-08-10T11:03:38.094021Z","shell.execute_reply.started":"2022-08-10T11:03:38.086356Z","shell.execute_reply":"2022-08-10T11:03:38.092775Z"},"trusted":true},"outputs":[],"execution_count":25},{"cell_type":"code","source":"iqr_capping(tdf,num_col,1.5)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:03:48.799811Z","iopub.execute_input":"2022-08-10T11:03:48.800663Z","iopub.status.idle":"2022-08-10T11:03:51.513699Z","shell.execute_reply.started":"2022-08-10T11:03:48.800615Z","shell.execute_reply":"2022-08-10T11:03:51.512189Z"},"trusted":true},"outputs":[],"execution_count":26},{"cell_type":"markdown","source":"### Handling the missing values","metadata":{}},{"cell_type":"code","source":"for col in tdf.columns:\n    tdf[col][tdf[col].isnull()] = tdf[col].dropna().sample(tdf[col].isnull().sum()).values","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:04:19.039915Z","iopub.execute_input":"2022-08-10T11:04:19.040963Z","iopub.status.idle":"2022-08-10T11:04:22.147601Z","shell.execute_reply.started":"2022-08-10T11:04:19.040918Z","shell.execute_reply":"2022-08-10T11:04:22.146524Z"},"trusted":true},"outputs":[],"execution_count":27},{"cell_type":"code","source":"tdf.drop(['B_30','D_114', 'D_116','D_120', 'D_126'], axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:04:33.682884Z","iopub.execute_input":"2022-08-10T11:04:33.683317Z","iopub.status.idle":"2022-08-10T11:04:34.659291Z","shell.execute_reply.started":"2022-08-10T11:04:33.683282Z","shell.execute_reply":"2022-08-10T11:04:34.65799Z"},"trusted":true},"outputs":[],"execution_count":28},{"cell_type":"code","source":"cat_col = ['D_117','D_63','D_64','D_68']","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:04:47.285154Z","iopub.execute_input":"2022-08-10T11:04:47.285581Z","iopub.status.idle":"2022-08-10T11:04:47.290835Z","shell.execute_reply.started":"2022-08-10T11:04:47.285541Z","shell.execute_reply":"2022-08-10T11:04:47.289741Z"},"trusted":true},"outputs":[],"execution_count":29},{"cell_type":"markdown","source":"### Encoding the Categorical variables","metadata":{}},{"cell_type":"code","source":"for col in tdf[cat_col].columns:\n    var = tdf[col].value_counts()\n    cat = tdf[col].value_counts().index.tolist()\n    \n    freq = []\n    for i in var:\n        freq.append(i/tdf[col].count())\n    print(cat)\n    print(freq)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:05:13.560834Z","iopub.execute_input":"2022-08-10T11:05:13.561276Z","iopub.status.idle":"2022-08-10T11:05:13.900006Z","shell.execute_reply.started":"2022-08-10T11:05:13.56124Z","shell.execute_reply":"2022-08-10T11:05:13.898442Z"},"trusted":true},"outputs":[{"name":"stdout","text":"[-1.0, 3.0, 4.0, 2.0, 5.0, 6.0, 1.0]\n[0.2727074630703423, 0.2161215742417408, 0.2136788454456509, 0.12191635451599758, 0.08690318208462171, 0.06719138485943958, 0.021481195782207085]\n['CO', 'CR', 'CL', 'XZ', 'XM', 'XL']\n[0.7515367836605196, 0.1594594182339572, 0.07685770505520655, 0.0071102801620350695, 0.0032751305803060712, 0.0017606823079755857]\n['O', 'U', 'R']\n[0.5448679815128358, 0.29571182337392926, 0.15942019511323496]\n[6.0, 5.0, 3.0, 4.0, 2.0, 1.0]\n[0.5146073438756366, 0.23458041066607396, 0.09308518172289737, 0.09200436684077375, 0.04296674968893886, 0.022755947205679507]\n","output_type":"stream"}],"execution_count":30},{"cell_type":"code","source":"tdf['D_117'].replace([-1.0, 3.0, 4.0, 2.0, 5.0, 6.0, 1.0],[0.2727, 0.2161,0.2136, 0.12189, 0.0868, 0.06716,0.02145], inplace=True)\ntdf['D_117'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:05:27.745968Z","iopub.execute_input":"2022-08-10T11:05:27.746403Z","iopub.status.idle":"2022-08-10T11:05:27.777267Z","shell.execute_reply.started":"2022-08-10T11:05:27.746368Z","shell.execute_reply":"2022-08-10T11:05:27.776068Z"},"trusted":true},"outputs":[{"execution_count":31,"output_type":"execute_result","data":{"text/plain":"0.27270    125149\n0.21610     99181\n0.21360     98060\n0.12189     55949\n0.08680     39881\n0.06716     30835\n0.02145      9858\nName: D_117, dtype: int64"},"metadata":{}}],"execution_count":31},{"cell_type":"code","source":"tdf['D_63'].replace(['CO', 'CR', 'CL', 'XZ', 'XM', 'XL'],[0.75153, 0.1594,0.0768,0.00711,0.00327, 0.00176], inplace=True)\ntdf['D_63'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:05:38.600744Z","iopub.execute_input":"2022-08-10T11:05:38.601186Z","iopub.status.idle":"2022-08-10T11:05:38.780697Z","shell.execute_reply.started":"2022-08-10T11:05:38.601145Z","shell.execute_reply":"2022-08-10T11:05:38.779544Z"},"trusted":true},"outputs":[{"execution_count":32,"output_type":"execute_result","data":{"text/plain":"0.75153    344890\n0.15940     73178\n0.07680     35271\n0.00711      3263\n0.00327      1503\n0.00176       808\nName: D_63, dtype: int64"},"metadata":{}}],"execution_count":32},{"cell_type":"code","source":"tdf['D_64'].replace(['O', 'U', 'R'],[0.54504, 0.29571,0.15923], inplace=True)\ntdf['D_64'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:05:50.881092Z","iopub.execute_input":"2022-08-10T11:05:50.881542Z","iopub.status.idle":"2022-08-10T11:05:51.034219Z","shell.execute_reply.started":"2022-08-10T11:05:50.881504Z","shell.execute_reply":"2022-08-10T11:05:51.033017Z"},"trusted":true},"outputs":[{"execution_count":33,"output_type":"execute_result","data":{"text/plain":"0.54504    250047\n0.29571    135706\n0.15923     73160\nName: D_64, dtype: int64"},"metadata":{}}],"execution_count":33},{"cell_type":"code","source":"tdf['D_68'].replace([6.0, 5.0, 3.0, 4.0, 2.0, 1.0],[0.5146, 0.2344,0.0931,0.09208,0.0429,0.0227], inplace=True)\ntdf['D_68'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:06:03.761472Z","iopub.execute_input":"2022-08-10T11:06:03.761948Z","iopub.status.idle":"2022-08-10T11:06:03.789878Z","shell.execute_reply.started":"2022-08-10T11:06:03.761906Z","shell.execute_reply":"2022-08-10T11:06:03.78868Z"},"trusted":true},"outputs":[{"execution_count":34,"output_type":"execute_result","data":{"text/plain":"0.51460    236160\n0.23440    107652\n0.09310     42718\n0.09208     42222\n0.04290     19718\n0.02270     10443\nName: D_68, dtype: int64"},"metadata":{}}],"execution_count":34},{"cell_type":"markdown","source":"### Preparing the test data by sorting and reducing the memory usage","metadata":{}},{"cell_type":"code","source":"test=dd.read_csv('../input/amex-default-prediction/test_data.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:06:39.741386Z","iopub.execute_input":"2022-08-10T11:06:39.741875Z","iopub.status.idle":"2022-08-10T11:06:39.811693Z","shell.execute_reply.started":"2022-08-10T11:06:39.741833Z","shell.execute_reply":"2022-08-10T11:06:39.810743Z"},"trusted":true},"outputs":[],"execution_count":35},{"cell_type":"code","source":"test1 = test.drop_duplicates(subset=['customer_ID'], keep='last').compute()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:06:53.000947Z","iopub.execute_input":"2022-08-10T11:06:53.001527Z","iopub.status.idle":"2022-08-10T11:12:07.201119Z","shell.execute_reply.started":"2022-08-10T11:06:53.001478Z","shell.execute_reply":"2022-08-10T11:12:07.199724Z"},"trusted":true},"outputs":[],"execution_count":36},{"cell_type":"code","source":"pred_df = test1.filter(['customer_ID','P_2','D_39','B_1','R_1','S_3',\n                 'D_41','D_43','D_44','B_4','D_45','B_5','R_2','D_46',\n                 'D_47','D_48','B_6','B_7','B_8','D_51','B_9','R_3',\n                 'D_52','P_3','S_5','S_6','D_54','B_12','R_5','D_58',\n                 'B_14','D_59','D_60','D_61','B_15','S_11','D_62','D_63',\n                 'D_64','D_65','B_16','B_18','B_19','D_68','S_12','R_6','S_13',\n                 'B_21','D_69','B_22','D_70','D_71','D_72','S_15','B_23','P_4',\n                 'D_75','B_24','R_7','B_25','B_26','D_78','D_79','S_16','D_80',\n                 'R_10','R_11','B_27','D_81','S_17','R_12','R_13','D_83','R_14',\n                 'R_15','D_84','R_16','S_18','D_86','R_17','R_18','S_19',\n                 'R_19','B_32','S_20','R_20','R_21','D_89','R_22','R_23','D_91',\n                 'D_92','D_93','D_94','R_24','R_25','D_96','S_22','S_23','S_25',\n                 'S_26','D_102','D_103','B_36','R_27','D_109','D_112','S_27',\n                 'D_113','D_115','D_117','D_121','D_122',\n                 'D_123','D_124','D_125','D_127','D_128','B_41','D_130',\n                 'D_133','R_28','D_139','D_140','D_144','D_145','B_3', 'B_20'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:17.260921Z","iopub.execute_input":"2022-08-10T11:13:17.261737Z","iopub.status.idle":"2022-08-10T11:13:17.653531Z","shell.execute_reply.started":"2022-08-10T11:13:17.261686Z","shell.execute_reply":"2022-08-10T11:13:17.652373Z"},"trusted":true},"outputs":[],"execution_count":37},{"cell_type":"code","source":"reduce_mem_usage(pred_df, verbose=True)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:22.980178Z","iopub.execute_input":"2022-08-10T11:13:22.980648Z","iopub.status.idle":"2022-08-10T11:13:24.2074Z","shell.execute_reply.started":"2022-08-10T11:13:22.98061Z","shell.execute_reply":"2022-08-10T11:13:24.206503Z"},"trusted":true},"outputs":[{"name":"stdout","text":"Mem. usage decreased to 910.00 Mb (0.0% reduction)\n","output_type":"stream"},{"execution_count":38,"output_type":"execute_result","data":{"text/plain":"                                             customer_ID       P_2      D_39  \\\n8      00000469ba478561f23a92a868bd366de6f6527a684c9a...  0.568930  0.121385   \n21     00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...  0.841177  0.126475   \n34     0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...  0.697522  0.002724   \n47     00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...  0.513186  0.324828   \n60     00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...  0.254478  0.768016   \n...                                                  ...       ...       ...   \n21473  ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...  0.646915  0.003873   \n21486  ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...  0.471303  0.001856   \n21499  ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...  0.206425  0.001037   \n21512  ffffddef1fc3643ea179c93245b68dca0f36941cd83977...  0.570670  0.034202   \n21520  fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...  0.454546  0.004400   \n\n            B_1       R_1       S_3      D_41      D_43      D_44       B_4  \\\n8      0.010779  0.006923  0.149413  0.000396  0.007398  0.006787  0.124780   \n21     0.016562  0.009715  0.112195  0.006192       NaN  0.004234  0.014831   \n34     0.001484  0.002620  0.166165  0.004888  0.105303  0.003381  0.417713   \n47     0.149511  0.002278  0.181200  0.005813  0.211615  0.258627  0.244689   \n60     0.563603  0.503154  0.168317  0.009480  0.071884  0.375839  0.235517   \n...         ...       ...       ...       ...       ...       ...       ...   \n21473  0.011309  0.003810  0.162921  0.008944  0.034703  0.000500  0.041485   \n21486  0.084163  0.508854  0.857136  0.000462  0.760330  0.254073  0.207625   \n21499  0.019952  0.009598  0.321134  0.077758  0.329028  0.508191  0.211724   \n21512  0.049776  0.002750  0.230847  0.001869  0.142936  0.376146  0.689184   \n21520  0.000346  0.008738       NaN  0.000936       NaN  0.004313  0.007904   \n\n       ...      B_41     D_130     D_133      R_28     D_139     D_140  \\\n8      ...  0.006789  0.004902  0.006273  0.008816  0.005912  0.001250   \n21     ...  0.007340  0.001252  0.002767  0.008789  0.004344  0.000866   \n34     ...  0.007062  1.003890  0.002045  0.001852  1.001246  0.008894   \n47     ...  0.002427  0.009438  0.009377  0.003622  1.008246  0.003753   \n60     ...  0.004532  0.003340  0.007940  0.009232  0.006623  0.001140   \n...    ...       ...       ...       ...       ...       ...       ...   \n21473  ...  0.007432  1.009325  0.009844  0.009843  0.003015  0.006851   \n21486  ...  0.005822  0.009905  0.001985  0.001197  0.007684  0.003375   \n21499  ...  0.007736  1.008923  0.274885  0.000414  0.002304  0.001640   \n21512  ...  0.007967  1.009811  0.750931  0.001444  0.005353  0.000086   \n21520  ...  0.005383  0.004691  0.000060  0.000280  0.003400  0.009588   \n\n          D_144     D_145       B_3      B_20  \n8      0.003690  0.003219  0.003576  0.004525  \n21     0.000247  0.007780  0.011386  0.000821  \n34     0.457819  0.092041  0.015938  0.001193  \n47     0.500924  0.183020  0.498516  1.007409  \n60     0.001558  0.000525  0.830857  1.004656  \n...         ...       ...       ...       ...  \n21473  0.003278  0.005294  0.028906  0.009576  \n21486  0.005432  0.009981  0.070524  0.241864  \n21499  0.004849  0.002120  0.014289  0.009973  \n21512  0.007482  0.006960  0.099891  1.009550  \n21520  0.006442  0.003142  0.003494  0.004350  \n\n[924621 rows x 128 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>P_2</th>\n      <th>D_39</th>\n      <th>B_1</th>\n      <th>R_1</th>\n      <th>S_3</th>\n      <th>D_41</th>\n      <th>D_43</th>\n      <th>D_44</th>\n      <th>B_4</th>\n      <th>...</th>\n      <th>B_41</th>\n      <th>D_130</th>\n      <th>D_133</th>\n      <th>R_28</th>\n      <th>D_139</th>\n      <th>D_140</th>\n      <th>D_144</th>\n      <th>D_145</th>\n      <th>B_3</th>\n      <th>B_20</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>8</th>\n      <td>00000469ba478561f23a92a868bd366de6f6527a684c9a...</td>\n      <td>0.568930</td>\n      <td>0.121385</td>\n      <td>0.010779</td>\n      <td>0.006923</td>\n      <td>0.149413</td>\n      <td>0.000396</td>\n      <td>0.007398</td>\n      <td>0.006787</td>\n      <td>0.124780</td>\n      <td>...</td>\n      <td>0.006789</td>\n      <td>0.004902</td>\n      <td>0.006273</td>\n      <td>0.008816</td>\n      <td>0.005912</td>\n      <td>0.001250</td>\n      <td>0.003690</td>\n      <td>0.003219</td>\n      <td>0.003576</td>\n      <td>0.004525</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...</td>\n      <td>0.841177</td>\n      <td>0.126475</td>\n      <td>0.016562</td>\n      <td>0.009715</td>\n      <td>0.112195</td>\n      <td>0.006192</td>\n      <td>NaN</td>\n      <td>0.004234</td>\n      <td>0.014831</td>\n      <td>...</td>\n      <td>0.007340</td>\n      <td>0.001252</td>\n      <td>0.002767</td>\n      <td>0.008789</td>\n      <td>0.004344</td>\n      <td>0.000866</td>\n      <td>0.000247</td>\n      <td>0.007780</td>\n      <td>0.011386</td>\n      <td>0.000821</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...</td>\n      <td>0.697522</td>\n      <td>0.002724</td>\n      <td>0.001484</td>\n      <td>0.002620</td>\n      <td>0.166165</td>\n      <td>0.004888</td>\n      <td>0.105303</td>\n      <td>0.003381</td>\n      <td>0.417713</td>\n      <td>...</td>\n      <td>0.007062</td>\n      <td>1.003890</td>\n      <td>0.002045</td>\n      <td>0.001852</td>\n      <td>1.001246</td>\n      <td>0.008894</td>\n      <td>0.457819</td>\n      <td>0.092041</td>\n      <td>0.015938</td>\n      <td>0.001193</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...</td>\n      <td>0.513186</td>\n      <td>0.324828</td>\n      <td>0.149511</td>\n      <td>0.002278</td>\n      <td>0.181200</td>\n      <td>0.005813</td>\n      <td>0.211615</td>\n      <td>0.258627</td>\n      <td>0.244689</td>\n      <td>...</td>\n      <td>0.002427</td>\n      <td>0.009438</td>\n      <td>0.009377</td>\n      <td>0.003622</td>\n      <td>1.008246</td>\n      <td>0.003753</td>\n      <td>0.500924</td>\n      <td>0.183020</td>\n      <td>0.498516</td>\n      <td>1.007409</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...</td>\n      <td>0.254478</td>\n      <td>0.768016</td>\n      <td>0.563603</td>\n      <td>0.503154</td>\n      <td>0.168317</td>\n      <td>0.009480</td>\n      <td>0.071884</td>\n      <td>0.375839</td>\n      <td>0.235517</td>\n      <td>...</td>\n      <td>0.004532</td>\n      <td>0.003340</td>\n      <td>0.007940</td>\n      <td>0.009232</td>\n      <td>0.006623</td>\n      <td>0.001140</td>\n      <td>0.001558</td>\n      <td>0.000525</td>\n      <td>0.830857</td>\n      <td>1.004656</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>21473</th>\n      <td>ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...</td>\n      <td>0.646915</td>\n      <td>0.003873</td>\n      <td>0.011309</td>\n      <td>0.003810</td>\n      <td>0.162921</td>\n      <td>0.008944</td>\n      <td>0.034703</td>\n      <td>0.000500</td>\n      <td>0.041485</td>\n      <td>...</td>\n      <td>0.007432</td>\n      <td>1.009325</td>\n      <td>0.009844</td>\n      <td>0.009843</td>\n      <td>0.003015</td>\n      <td>0.006851</td>\n      <td>0.003278</td>\n      <td>0.005294</td>\n      <td>0.028906</td>\n      <td>0.009576</td>\n    </tr>\n    <tr>\n      <th>21486</th>\n      <td>ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...</td>\n      <td>0.471303</td>\n      <td>0.001856</td>\n      <td>0.084163</td>\n      <td>0.508854</td>\n      <td>0.857136</td>\n      <td>0.000462</td>\n      <td>0.760330</td>\n      <td>0.254073</td>\n      <td>0.207625</td>\n      <td>...</td>\n      <td>0.005822</td>\n      <td>0.009905</td>\n      <td>0.001985</td>\n      <td>0.001197</td>\n      <td>0.007684</td>\n      <td>0.003375</td>\n      <td>0.005432</td>\n      <td>0.009981</td>\n      <td>0.070524</td>\n      <td>0.241864</td>\n    </tr>\n    <tr>\n      <th>21499</th>\n      <td>ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...</td>\n      <td>0.206425</td>\n      <td>0.001037</td>\n      <td>0.019952</td>\n      <td>0.009598</td>\n      <td>0.321134</td>\n      <td>0.077758</td>\n      <td>0.329028</td>\n      <td>0.508191</td>\n      <td>0.211724</td>\n      <td>...</td>\n      <td>0.007736</td>\n      <td>1.008923</td>\n      <td>0.274885</td>\n      <td>0.000414</td>\n      <td>0.002304</td>\n      <td>0.001640</td>\n      <td>0.004849</td>\n      <td>0.002120</td>\n      <td>0.014289</td>\n      <td>0.009973</td>\n    </tr>\n    <tr>\n      <th>21512</th>\n      <td>ffffddef1fc3643ea179c93245b68dca0f36941cd83977...</td>\n      <td>0.570670</td>\n      <td>0.034202</td>\n      <td>0.049776</td>\n      <td>0.002750</td>\n      <td>0.230847</td>\n      <td>0.001869</td>\n      <td>0.142936</td>\n      <td>0.376146</td>\n      <td>0.689184</td>\n      <td>...</td>\n      <td>0.007967</td>\n      <td>1.009811</td>\n      <td>0.750931</td>\n      <td>0.001444</td>\n      <td>0.005353</td>\n      <td>0.000086</td>\n      <td>0.007482</td>\n      <td>0.006960</td>\n      <td>0.099891</td>\n      <td>1.009550</td>\n    </tr>\n    <tr>\n      <th>21520</th>\n      <td>fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...</td>\n      <td>0.454546</td>\n      <td>0.004400</td>\n      <td>0.000346</td>\n      <td>0.008738</td>\n      <td>NaN</td>\n      <td>0.000936</td>\n      <td>NaN</td>\n      <td>0.004313</td>\n      <td>0.007904</td>\n      <td>...</td>\n      <td>0.005383</td>\n      <td>0.004691</td>\n      <td>0.000060</td>\n      <td>0.000280</td>\n      <td>0.003400</td>\n      <td>0.009588</td>\n      <td>0.006442</td>\n      <td>0.003142</td>\n      <td>0.003494</td>\n      <td>0.004350</td>\n    </tr>\n  </tbody>\n</table>\n<p>924621 rows × 128 columns</p>\n</div>"},"metadata":{}}],"execution_count":38},{"cell_type":"code","source":"pred_df['customer_ID'].nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:28.160701Z","iopub.execute_input":"2022-08-10T11:13:28.161425Z","iopub.status.idle":"2022-08-10T11:13:28.571583Z","shell.execute_reply.started":"2022-08-10T11:13:28.16138Z","shell.execute_reply":"2022-08-10T11:13:28.570648Z"},"trusted":true},"outputs":[{"execution_count":39,"output_type":"execute_result","data":{"text/plain":"924621"},"metadata":{}}],"execution_count":39},{"cell_type":"code","source":"for col in pred_df[cat_col].columns:\n    var = pred_df[col].value_counts()\n    cat = pred_df[col].value_counts().index.tolist()\n    \n    freq = []\n    for i in var:\n        freq.append(i/pred_df[col].count())\n    print(cat)\n    print(freq)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:32.180282Z","iopub.execute_input":"2022-08-10T11:13:32.180697Z","iopub.status.idle":"2022-08-10T11:13:32.848831Z","shell.execute_reply.started":"2022-08-10T11:13:32.180664Z","shell.execute_reply":"2022-08-10T11:13:32.84753Z"},"trusted":true},"outputs":[{"name":"stdout","text":"[-1.0, 4.0, 3.0, 2.0, 5.0, 6.0, 1.0]\n[0.2892465097625283, 0.21830249569470353, 0.20418949694965752, 0.10864221471282047, 0.08937608183313629, 0.07197420017342385, 0.018269000873730033]\n['CO', 'CR', 'CL', 'XZ', 'XM', 'XL']\n[0.7407370154906713, 0.1584043624360684, 0.08066223890653576, 0.012053587361740649, 0.005323262179855313, 0.002819533625128566]\n['O', 'U', 'R']\n[0.5356802315114255, 0.2695021037400564, 0.19481766474851805]\n[6.0, 5.0, 4.0, 3.0, 2.0, 1.0]\n[0.5011454810854307, 0.23858813775920182, 0.09840718832329721, 0.09451687520296684, 0.04334540327916821, 0.02399691434993533]\n","output_type":"stream"}],"execution_count":40},{"cell_type":"code","source":"pred_df['D_117'].replace([-1.0, 4.0, 3.0, 2.0, 5.0, 6.0, 1.0],[0.28924, 0.21830,0.2041, 0.1086, 0.0893,  0.0719,0.01826 ], inplace=True)\npred_df['D_117'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:36.566067Z","iopub.execute_input":"2022-08-10T11:13:36.567335Z","iopub.status.idle":"2022-08-10T11:13:36.615038Z","shell.execute_reply.started":"2022-08-10T11:13:36.567277Z","shell.execute_reply":"2022-08-10T11:13:36.6138Z"},"trusted":true},"outputs":[{"execution_count":41,"output_type":"execute_result","data":{"text/plain":"0.28924    262521\n0.21830    198132\n0.20410    185323\n0.10860     98604\n0.08930     81118\n0.07190     65324\n0.01826     16581\nName: D_117, dtype: int64"},"metadata":{}}],"execution_count":41},{"cell_type":"code","source":"pred_df['D_63'].replace(['CO', 'CR', 'CL', 'XZ', 'XM', 'XL'],[0.7407, 0.1584,0.0806, 0.01205,0.00532,0.00281], inplace=True)\npred_df['D_63'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:40.020239Z","iopub.execute_input":"2022-08-10T11:13:40.020646Z","iopub.status.idle":"2022-08-10T11:13:40.387828Z","shell.execute_reply.started":"2022-08-10T11:13:40.020612Z","shell.execute_reply":"2022-08-10T11:13:40.387029Z"},"trusted":true},"outputs":[{"execution_count":42,"output_type":"execute_result","data":{"text/plain":"0.74070    684901\n0.15840    146464\n0.08060     74582\n0.01205     11145\n0.00532      4922\n0.00281      2607\nName: D_63, dtype: int64"},"metadata":{}}],"execution_count":42},{"cell_type":"code","source":"pred_df['D_64'].replace(['O', 'U', 'R'],[0.5356, 0.26950,0.1948], inplace=True)\npred_df['D_64'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:44.160125Z","iopub.execute_input":"2022-08-10T11:13:44.160561Z","iopub.status.idle":"2022-08-10T11:13:44.422431Z","shell.execute_reply.started":"2022-08-10T11:13:44.160528Z","shell.execute_reply":"2022-08-10T11:13:44.421229Z"},"trusted":true},"outputs":[{"execution_count":43,"output_type":"execute_result","data":{"text/plain":"0.5356    482019\n0.2695    242505\n0.1948    175302\nName: D_64, dtype: int64"},"metadata":{}}],"execution_count":43},{"cell_type":"code","source":"pred_df['D_68'].replace([6.0, 5.0, 4.0, 3.0, 2.0, 1.0],[0.5011, 0.2385,0.0984,0.09451,0.04334,0.02399], inplace=True)\npred_df['D_68'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:47.579982Z","iopub.execute_input":"2022-08-10T11:13:47.581379Z","iopub.status.idle":"2022-08-10T11:13:47.628385Z","shell.execute_reply.started":"2022-08-10T11:13:47.581308Z","shell.execute_reply":"2022-08-10T11:13:47.627143Z"},"trusted":true},"outputs":[{"execution_count":44,"output_type":"execute_result","data":{"text/plain":"0.50110    452154\n0.23850    215264\n0.09840     88787\n0.09451     85277\n0.04334     39108\n0.02399     21651\nName: D_68, dtype: int64"},"metadata":{}}],"execution_count":44},{"cell_type":"code","source":"from sklearn.feature_selection import SelectKBest, f_classif\nfrom imblearn.ensemble import RUSBoostClassifier\nimport lightgbm as lgb\nimport catboost\nfrom catboost import *\nfrom sklearn.ensemble import StackingClassifier\nfrom sklearn.linear_model import LogisticRegression","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:50.840398Z","iopub.execute_input":"2022-08-10T11:13:50.840817Z","iopub.status.idle":"2022-08-10T11:13:51.437914Z","shell.execute_reply.started":"2022-08-10T11:13:50.840785Z","shell.execute_reply":"2022-08-10T11:13:51.436958Z"},"trusted":true},"outputs":[{"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"<style type='text/css'>\n.datatable table.frame { margin-bottom: 0; }\n.datatable table.frame thead { border-bottom: none; }\n.datatable table.frame tr.coltypes td {  color: #FFFFFF;  line-height: 6px;  padding: 0 0.5em;}\n.datatable .bool    { background: #DDDD99; }\n.datatable .object  { background: #565656; }\n.datatable .int     { background: #5D9E5D; }\n.datatable .float   { background: #4040CC; }\n.datatable .str     { background: #CC4040; }\n.datatable .time    { background: #40CC40; }\n.datatable .row_index {  background: var(--jp-border-color3);  border-right: 1px solid var(--jp-border-color0);  color: var(--jp-ui-font-color3);  font-size: 9px;}\n.datatable .frame tbody td { text-align: left; }\n.datatable .frame tr.coltypes .row_index {  background: var(--jp-border-color0);}\n.datatable th:nth-child(2) { padding-left: 12px; }\n.datatable .hellipsis {  color: var(--jp-cell-editor-border-color);}\n.datatable .vellipsis {  background: var(--jp-layout-color0);  color: var(--jp-cell-editor-border-color);}\n.datatable .na {  color: var(--jp-cell-editor-border-color);  font-size: 80%;}\n.datatable .sp {  opacity: 0.25;}\n.datatable .footer { font-size: 9px; }\n.datatable .frame_dimensions {  background: var(--jp-border-color3);  border-top: 1px solid var(--jp-border-color0);  color: var(--jp-ui-font-color3);  display: inline-block;  opacity: 0.6;  padding: 1px 10px 1px 5px;}\n</style>\n"},"metadata":{}}],"execution_count":45},{"cell_type":"code","source":"for col in pred_df.columns:\n    pred_df[col][pred_df[col].isnull()] = pred_df[col].dropna().sample(pred_df[col].isnull().sum()).values","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:13:56.040245Z","iopub.execute_input":"2022-08-10T11:13:56.041162Z","iopub.status.idle":"2022-08-10T11:14:01.547781Z","shell.execute_reply.started":"2022-08-10T11:13:56.041118Z","shell.execute_reply":"2022-08-10T11:14:01.546502Z"},"trusted":true},"outputs":[],"execution_count":46},{"cell_type":"code","source":"num_col1 = []\nfor nocol in pred_df.columns:\n    if (is_numeric_dtype(pred_df[nocol]) == True):\n        num_col1.append(nocol)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:14:06.220317Z","iopub.execute_input":"2022-08-10T11:14:06.220724Z","iopub.status.idle":"2022-08-10T11:14:06.227628Z","shell.execute_reply.started":"2022-08-10T11:14:06.220691Z","shell.execute_reply":"2022-08-10T11:14:06.226412Z"},"trusted":true},"outputs":[],"execution_count":47},{"cell_type":"code","source":"iqr_capping(pred_df,num_col1,1.5)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T11:14:09.280101Z","iopub.execute_input":"2022-08-10T11:14:09.280702Z","iopub.status.idle":"2022-08-10T11:14:14.447078Z","shell.execute_reply.started":"2022-08-10T11:14:09.28065Z","shell.execute_reply":"2022-08-10T11:14:14.446054Z"},"trusted":true},"outputs":[],"execution_count":48},{"cell_type":"code","source":"x = tdf.drop(['customer_ID', 'S_2', 'target'], axis=1)\ny = tdf.target","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:12:57.263948Z","iopub.execute_input":"2022-08-10T13:12:57.26449Z","iopub.status.idle":"2022-08-10T13:12:57.993964Z","shell.execute_reply.started":"2022-08-10T13:12:57.264449Z","shell.execute_reply":"2022-08-10T13:12:57.992561Z"},"trusted":true},"outputs":[],"execution_count":84},{"cell_type":"code","source":"x1 = x.iloc[:75000, :]\ny1 = y.iloc[ :75000]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:13:00.462934Z","iopub.execute_input":"2022-08-10T13:13:00.463392Z","iopub.status.idle":"2022-08-10T13:13:00.469407Z","shell.execute_reply.started":"2022-08-10T13:13:00.463354Z","shell.execute_reply":"2022-08-10T13:13:00.468227Z"},"trusted":true},"outputs":[],"execution_count":85},{"cell_type":"code","source":"x_test = pred_df.drop(['customer_ID'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:13:09.663701Z","iopub.execute_input":"2022-08-10T13:13:09.664144Z","iopub.status.idle":"2022-08-10T13:13:11.352074Z","shell.execute_reply.started":"2022-08-10T13:13:09.664108Z","shell.execute_reply":"2022-08-10T13:13:11.351078Z"},"trusted":true},"outputs":[],"execution_count":86},{"cell_type":"code","source":"from autosklearn.classification import AutoSklearnClassifier","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:13:18.023043Z","iopub.execute_input":"2022-08-10T13:13:18.023468Z","iopub.status.idle":"2022-08-10T13:13:18.029415Z","shell.execute_reply.started":"2022-08-10T13:13:18.023432Z","shell.execute_reply":"2022-08-10T13:13:18.028056Z"},"trusted":true},"outputs":[],"execution_count":87},{"cell_type":"code","source":"model = AutoSklearnClassifier(\n    time_left_for_this_task= 4500,\n    per_run_time_limit=450,\n    ensemble_size=1,\n    initial_configurations_via_metalearning=0,\n    n_jobs=-1,\n    \n)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:13:39.463763Z","iopub.execute_input":"2022-08-10T13:13:39.464174Z","iopub.status.idle":"2022-08-10T13:13:39.470318Z","shell.execute_reply.started":"2022-08-10T13:13:39.464138Z","shell.execute_reply":"2022-08-10T13:13:39.468829Z"},"trusted":true},"outputs":[],"execution_count":89},{"cell_type":"code","source":"model.fit(x1,y1)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:13:43.302846Z","iopub.execute_input":"2022-08-10T13:13:43.304168Z","iopub.status.idle":"2022-08-10T14:28:48.873299Z","shell.execute_reply.started":"2022-08-10T13:13:43.304109Z","shell.execute_reply":"2022-08-10T14:28:48.872079Z"},"trusted":true},"outputs":[{"execution_count":90,"output_type":"execute_result","data":{"text/plain":"AutoSklearnClassifier(ensemble_size=1,\n                      initial_configurations_via_metalearning=0, n_jobs=-1,\n                      per_run_time_limit=450, time_left_for_this_task=4500)"},"metadata":{}}],"execution_count":90},{"cell_type":"code","source":"print(model.sprint_statistics())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T14:29:17.529413Z","iopub.execute_input":"2022-08-10T14:29:17.529853Z","iopub.status.idle":"2022-08-10T14:29:17.568886Z","shell.execute_reply.started":"2022-08-10T14:29:17.529807Z","shell.execute_reply":"2022-08-10T14:29:17.567534Z"},"trusted":true},"outputs":[{"name":"stdout","text":"auto-sklearn results:\n  Dataset name: 423ea102-18ae-11ed-8011-0242ac130202\n  Metric: accuracy\n  Best validation score: 0.892889\n  Number of target algorithm runs: 168\n  Number of successful target algorithm runs: 130\n  Number of crashed target algorithm runs: 1\n  Number of target algorithms that exceeded the time limit: 18\n  Number of target algorithms that exceeded the memory limit: 19\n\n","output_type":"stream"}],"execution_count":91},{"cell_type":"code","source":"print(model.show_models())","metadata":{"execution":{"iopub.status.busy":"2022-08-10T14:29:38.449503Z","iopub.execute_input":"2022-08-10T14:29:38.449982Z","iopub.status.idle":"2022-08-10T14:29:38.462968Z","shell.execute_reply.started":"2022-08-10T14:29:38.449942Z","shell.execute_reply":"2022-08-10T14:29:38.461325Z"},"trusted":true},"outputs":[{"name":"stdout","text":"{132: {'model_id': 132, 'rank': 1, 'cost': 0.10711111111111116, 'ensemble_weight': 1.0, 'data_preprocessor': <autosklearn.pipeline.components.data_preprocessing.DataPreprocessorChoice object at 0x7fd790680c10>, 'balancing': Balancing(random_state=1), 'feature_preprocessor': <autosklearn.pipeline.components.feature_preprocessing.FeaturePreprocessorChoice object at 0x7fd788fd0650>, 'classifier': <autosklearn.pipeline.components.classification.ClassifierChoice object at 0x7fd788fd0390>, 'sklearn_classifier': HistGradientBoostingClassifier(early_stopping=True,\n                               l2_regularization=0.012865179750450133,\n                               learning_rate=0.06665575744691808, max_iter=512,\n                               max_leaf_nodes=205, min_samples_leaf=35,\n                               n_iter_no_change=14, random_state=1,\n                               validation_fraction=None, warm_start=True)}}\n","output_type":"stream"}],"execution_count":92},{"cell_type":"code","source":"y_pred = model.predict_proba(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T12:57:18.730067Z","iopub.execute_input":"2022-08-10T12:57:18.73051Z","iopub.status.idle":"2022-08-10T12:58:52.239474Z","shell.execute_reply.started":"2022-08-10T12:57:18.730469Z","shell.execute_reply":"2022-08-10T12:58:52.238073Z"},"trusted":true},"outputs":[],"execution_count":64},{"cell_type":"code","source":"y_predict_final=y_pred[:,1]","metadata":{"execution":{"iopub.status.busy":"2022-08-10T12:59:16.930272Z","iopub.execute_input":"2022-08-10T12:59:16.930745Z","iopub.status.idle":"2022-08-10T12:59:16.937848Z","shell.execute_reply.started":"2022-08-10T12:59:16.930699Z","shell.execute_reply":"2022-08-10T12:59:16.936374Z"},"trusted":true},"outputs":[],"execution_count":65},{"cell_type":"code","source":"sub = pd.DataFrame({\"customer_ID\": pred_df.customer_ID,\"prediction\":y_predict_final})","metadata":{"execution":{"iopub.status.busy":"2022-08-10T12:59:34.105892Z","iopub.execute_input":"2022-08-10T12:59:34.106367Z","iopub.status.idle":"2022-08-10T12:59:34.356684Z","shell.execute_reply.started":"2022-08-10T12:59:34.106327Z","shell.execute_reply":"2022-08-10T12:59:34.355177Z"},"trusted":true},"outputs":[],"execution_count":66},{"cell_type":"code","source":"sub.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-10T12:59:47.850095Z","iopub.execute_input":"2022-08-10T12:59:47.850518Z","iopub.status.idle":"2022-08-10T12:59:47.859376Z","shell.execute_reply.started":"2022-08-10T12:59:47.850481Z","shell.execute_reply":"2022-08-10T12:59:47.857948Z"},"trusted":true},"outputs":[{"execution_count":67,"output_type":"execute_result","data":{"text/plain":"(924621, 2)"},"metadata":{}}],"execution_count":67},{"cell_type":"code","source":"sub.sort_index()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:00:02.970888Z","iopub.execute_input":"2022-08-10T13:00:02.971361Z","iopub.status.idle":"2022-08-10T13:00:03.174436Z","shell.execute_reply.started":"2022-08-10T13:00:02.971321Z","shell.execute_reply":"2022-08-10T13:00:03.173146Z"},"trusted":true},"outputs":[{"execution_count":68,"output_type":"execute_result","data":{"text/plain":"                                             customer_ID    prediction\n0      afae257b34acdc2682fcf9073661758c1743da9c856400...  9.999321e-01\n0      2ca2879526a7c161c7da0c0ce8af6d00e3d99f7aee5c44...  1.228740e-08\n0      ab537b7577dcda3a9d04864d9664c1935d363b19d186e1...  1.337793e-07\n0      ac4a456b5fb5eb09a52327ef56069f1bf6f3b748ac721e...  1.000000e+00\n0      ad468caed24856124cdad84e4724c280ffe7772a32dc98...  9.984941e-01\n...                                                  ...           ...\n21554  1e9e0e1fda9978da8d0b34c1fa1230e191bb3a09a24c22...  1.497932e-08\n21556  d8390f2d7249c6eadc5b9a5310d161533ff183e60462fd...  6.212402e-07\n21556  45cfdcfc55e465c31d4c6f6874ba8774a9375d21773591...  1.000346e-05\n21557  0ab989c4c2b5d7fa870d66a48f457ab33fe6f7287dd99d...  4.979367e-06\n21565  e26665612bf187dd12db6949bc9e4a22835bc97cd66d82...  1.587884e-06\n\n[924621 rows x 2 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>prediction</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>afae257b34acdc2682fcf9073661758c1743da9c856400...</td>\n      <td>9.999321e-01</td>\n    </tr>\n    <tr>\n      <th>0</th>\n      <td>2ca2879526a7c161c7da0c0ce8af6d00e3d99f7aee5c44...</td>\n      <td>1.228740e-08</td>\n    </tr>\n    <tr>\n      <th>0</th>\n      <td>ab537b7577dcda3a9d04864d9664c1935d363b19d186e1...</td>\n      <td>1.337793e-07</td>\n    </tr>\n    <tr>\n      <th>0</th>\n      <td>ac4a456b5fb5eb09a52327ef56069f1bf6f3b748ac721e...</td>\n      <td>1.000000e+00</td>\n    </tr>\n    <tr>\n      <th>0</th>\n      <td>ad468caed24856124cdad84e4724c280ffe7772a32dc98...</td>\n      <td>9.984941e-01</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>21554</th>\n      <td>1e9e0e1fda9978da8d0b34c1fa1230e191bb3a09a24c22...</td>\n      <td>1.497932e-08</td>\n    </tr>\n    <tr>\n      <th>21556</th>\n      <td>d8390f2d7249c6eadc5b9a5310d161533ff183e60462fd...</td>\n      <td>6.212402e-07</td>\n    </tr>\n    <tr>\n      <th>21556</th>\n      <td>45cfdcfc55e465c31d4c6f6874ba8774a9375d21773591...</td>\n      <td>1.000346e-05</td>\n    </tr>\n    <tr>\n      <th>21557</th>\n      <td>0ab989c4c2b5d7fa870d66a48f457ab33fe6f7287dd99d...</td>\n      <td>4.979367e-06</td>\n    </tr>\n    <tr>\n      <th>21565</th>\n      <td>e26665612bf187dd12db6949bc9e4a22835bc97cd66d82...</td>\n      <td>1.587884e-06</td>\n    </tr>\n  </tbody>\n</table>\n<p>924621 rows × 2 columns</p>\n</div>"},"metadata":{}}],"execution_count":68},{"cell_type":"code","source":"sub.reset_index()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:00:19.050198Z","iopub.execute_input":"2022-08-10T13:00:19.050666Z","iopub.status.idle":"2022-08-10T13:00:19.089129Z","shell.execute_reply.started":"2022-08-10T13:00:19.050623Z","shell.execute_reply":"2022-08-10T13:00:19.087979Z"},"trusted":true},"outputs":[{"execution_count":69,"output_type":"execute_result","data":{"text/plain":"        index                                        customer_ID    prediction\n0           8  00000469ba478561f23a92a868bd366de6f6527a684c9a...  1.699341e-06\n1          21  00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...  1.691277e-09\n2          34  0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...  4.799687e-06\n3          47  00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...  3.434423e-02\n4          60  00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...  9.993012e-01\n...       ...                                                ...           ...\n924616  21473  ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...  1.953075e-05\n924617  21486  ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...  8.551885e-01\n924618  21499  ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...  8.912962e-01\n924619  21512  ffffddef1fc3643ea179c93245b68dca0f36941cd83977...  1.131058e-01\n924620  21520  fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...  1.898916e-04\n\n[924621 rows x 3 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>index</th>\n      <th>customer_ID</th>\n      <th>prediction</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>8</td>\n      <td>00000469ba478561f23a92a868bd366de6f6527a684c9a...</td>\n      <td>1.699341e-06</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>21</td>\n      <td>00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...</td>\n      <td>1.691277e-09</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>34</td>\n      <td>0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...</td>\n      <td>4.799687e-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>47</td>\n      <td>00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...</td>\n      <td>3.434423e-02</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>60</td>\n      <td>00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...</td>\n      <td>9.993012e-01</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>924616</th>\n      <td>21473</td>\n      <td>ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...</td>\n      <td>1.953075e-05</td>\n    </tr>\n    <tr>\n      <th>924617</th>\n      <td>21486</td>\n      <td>ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...</td>\n      <td>8.551885e-01</td>\n    </tr>\n    <tr>\n      <th>924618</th>\n      <td>21499</td>\n      <td>ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...</td>\n      <td>8.912962e-01</td>\n    </tr>\n    <tr>\n      <th>924619</th>\n      <td>21512</td>\n      <td>ffffddef1fc3643ea179c93245b68dca0f36941cd83977...</td>\n      <td>1.131058e-01</td>\n    </tr>\n    <tr>\n      <th>924620</th>\n      <td>21520</td>\n      <td>fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...</td>\n      <td>1.898916e-04</td>\n    </tr>\n  </tbody>\n</table>\n<p>924621 rows × 3 columns</p>\n</div>"},"metadata":{}}],"execution_count":69},{"cell_type":"code","source":"sub1 = sub.filter(['customer_ID','prediction'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:00:35.023403Z","iopub.execute_input":"2022-08-10T13:00:35.023846Z","iopub.status.idle":"2022-08-10T13:00:35.059664Z","shell.execute_reply.started":"2022-08-10T13:00:35.023808Z","shell.execute_reply":"2022-08-10T13:00:35.058551Z"},"trusted":true},"outputs":[],"execution_count":70},{"cell_type":"code","source":"sub1.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:00:48.982787Z","iopub.execute_input":"2022-08-10T13:00:48.983249Z","iopub.status.idle":"2022-08-10T13:00:48.997175Z","shell.execute_reply.started":"2022-08-10T13:00:48.983209Z","shell.execute_reply":"2022-08-10T13:00:48.995891Z"},"trusted":true},"outputs":[{"execution_count":71,"output_type":"execute_result","data":{"text/plain":"                                           customer_ID    prediction\n8    00000469ba478561f23a92a868bd366de6f6527a684c9a...  1.699341e-06\n21   00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...  1.691277e-09\n34   0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...  4.799687e-06\n47   00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...  3.434423e-02\n60   00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...  9.993012e-01\n73   00004ffe6e01e1b688170bbd108da8351bc4c316eacfef...  2.227487e-09\n86   00007cfcce97abfa0b4fa0647986157281d01d3ab90de9...  9.998905e-01\n99   000089cc2a30dad8e6ba39126f9d86df6088c9f975093a...  9.415289e-02\n112  00008f50a1dd76fa211ba36a2b0d5a1b201e4134a5fd53...  9.762077e-01\n125  0000b48a4f27dc1d61e78d081678e811620300b88eb3ab...  1.592235e-08","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>prediction</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>8</th>\n      <td>00000469ba478561f23a92a868bd366de6f6527a684c9a...</td>\n      <td>1.699341e-06</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...</td>\n      <td>1.691277e-09</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...</td>\n      <td>4.799687e-06</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...</td>\n      <td>3.434423e-02</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...</td>\n      <td>9.993012e-01</td>\n    </tr>\n    <tr>\n      <th>73</th>\n      <td>00004ffe6e01e1b688170bbd108da8351bc4c316eacfef...</td>\n      <td>2.227487e-09</td>\n    </tr>\n    <tr>\n      <th>86</th>\n      <td>00007cfcce97abfa0b4fa0647986157281d01d3ab90de9...</td>\n      <td>9.998905e-01</td>\n    </tr>\n    <tr>\n      <th>99</th>\n      <td>000089cc2a30dad8e6ba39126f9d86df6088c9f975093a...</td>\n      <td>9.415289e-02</td>\n    </tr>\n    <tr>\n      <th>112</th>\n      <td>00008f50a1dd76fa211ba36a2b0d5a1b201e4134a5fd53...</td>\n      <td>9.762077e-01</td>\n    </tr>\n    <tr>\n      <th>125</th>\n      <td>0000b48a4f27dc1d61e78d081678e811620300b88eb3ab...</td>\n      <td>1.592235e-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}],"execution_count":71},{"cell_type":"code","source":"sub1.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:01:02.06415Z","iopub.execute_input":"2022-08-10T13:01:02.064578Z","iopub.status.idle":"2022-08-10T13:01:02.642739Z","shell.execute_reply.started":"2022-08-10T13:01:02.064542Z","shell.execute_reply":"2022-08-10T13:01:02.641586Z"},"trusted":true},"outputs":[{"execution_count":72,"output_type":"execute_result","data":{"text/plain":"customer_ID    924621\nprediction     924620\ndtype: int64"},"metadata":{}}],"execution_count":72},{"cell_type":"code","source":"sub1.round({'prediction':5})","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:06:52.903353Z","iopub.execute_input":"2022-08-10T13:06:52.903957Z","iopub.status.idle":"2022-08-10T13:06:52.949834Z","shell.execute_reply.started":"2022-08-10T13:06:52.903898Z","shell.execute_reply":"2022-08-10T13:06:52.948751Z"},"trusted":true},"outputs":[{"execution_count":79,"output_type":"execute_result","data":{"text/plain":"                                             customer_ID  prediction\n8      00000469ba478561f23a92a868bd366de6f6527a684c9a...     0.00000\n21     00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...     0.00000\n34     0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...     0.00000\n47     00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...     0.03434\n60     00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...     0.99930\n...                                                  ...         ...\n21473  ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...     0.00002\n21486  ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...     0.85519\n21499  ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...     0.89130\n21512  ffffddef1fc3643ea179c93245b68dca0f36941cd83977...     0.11311\n21520  fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...     0.00019\n\n[924621 rows x 2 columns]","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>prediction</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>8</th>\n      <td>00000469ba478561f23a92a868bd366de6f6527a684c9a...</td>\n      <td>0.00000</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...</td>\n      <td>0.00000</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...</td>\n      <td>0.00000</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...</td>\n      <td>0.03434</td>\n    </tr>\n    <tr>\n      <th>60</th>\n      <td>00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...</td>\n      <td>0.99930</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>21473</th>\n      <td>ffff952c631f2c911b8a2a8ca56ea6e656309a83d2f64c...</td>\n      <td>0.00002</td>\n    </tr>\n    <tr>\n      <th>21486</th>\n      <td>ffffcf5df59e5e0bba2a5ac4578a34e2b5aa64a1546cd3...</td>\n      <td>0.85519</td>\n    </tr>\n    <tr>\n      <th>21499</th>\n      <td>ffffd61f098cc056dbd7d2a21380c4804bbfe60856f475...</td>\n      <td>0.89130</td>\n    </tr>\n    <tr>\n      <th>21512</th>\n      <td>ffffddef1fc3643ea179c93245b68dca0f36941cd83977...</td>\n      <td>0.11311</td>\n    </tr>\n    <tr>\n      <th>21520</th>\n      <td>fffffa7cf7e453e1acc6a1426475d5cb9400859f82ff61...</td>\n      <td>0.00019</td>\n    </tr>\n  </tbody>\n</table>\n<p>924621 rows × 2 columns</p>\n</div>"},"metadata":{}}],"execution_count":79},{"cell_type":"code","source":"sub1.to_csv('submission88.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:07:19.462816Z","iopub.execute_input":"2022-08-10T13:07:19.463279Z","iopub.status.idle":"2022-08-10T13:07:23.092363Z","shell.execute_reply.started":"2022-08-10T13:07:19.463237Z","shell.execute_reply":"2022-08-10T13:07:23.090769Z"},"trusted":true},"outputs":[],"execution_count":80},{"cell_type":"code","source":"fd = pd.read_csv('submission88.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:07:27.74287Z","iopub.execute_input":"2022-08-10T13:07:27.744111Z","iopub.status.idle":"2022-08-10T13:07:29.027444Z","shell.execute_reply.started":"2022-08-10T13:07:27.74406Z","shell.execute_reply":"2022-08-10T13:07:29.026405Z"},"trusted":true},"outputs":[],"execution_count":81},{"cell_type":"code","source":"fd.nunique()","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:07:32.06249Z","iopub.execute_input":"2022-08-10T13:07:32.062916Z","iopub.status.idle":"2022-08-10T13:07:32.57327Z","shell.execute_reply.started":"2022-08-10T13:07:32.062879Z","shell.execute_reply":"2022-08-10T13:07:32.571738Z"},"trusted":true},"outputs":[{"execution_count":82,"output_type":"execute_result","data":{"text/plain":"customer_ID    924621\nprediction     924620\ndtype: int64"},"metadata":{}}],"execution_count":82},{"cell_type":"code","source":"fd.head(15)","metadata":{"execution":{"iopub.status.busy":"2022-08-10T13:07:36.262614Z","iopub.execute_input":"2022-08-10T13:07:36.263083Z","iopub.status.idle":"2022-08-10T13:07:36.278697Z","shell.execute_reply.started":"2022-08-10T13:07:36.26304Z","shell.execute_reply":"2022-08-10T13:07:36.27675Z"},"trusted":true},"outputs":[{"execution_count":83,"output_type":"execute_result","data":{"text/plain":"                                          customer_ID    prediction\n0   00000469ba478561f23a92a868bd366de6f6527a684c9a...  1.699341e-06\n1   00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...  1.691277e-09\n2   0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...  4.799687e-06\n3   00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...  3.434423e-02\n4   00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...  9.993012e-01\n5   00004ffe6e01e1b688170bbd108da8351bc4c316eacfef...  2.227487e-09\n6   00007cfcce97abfa0b4fa0647986157281d01d3ab90de9...  9.998905e-01\n7   000089cc2a30dad8e6ba39126f9d86df6088c9f975093a...  9.415289e-02\n8   00008f50a1dd76fa211ba36a2b0d5a1b201e4134a5fd53...  9.762077e-01\n9   0000b48a4f27dc1d61e78d081678e811620300b88eb3ab...  1.592235e-08\n10  0000bccc55cf039a23d49832234f224085716d85bed7d2...  7.987277e-03\n11  0000c7144ae91777aeeb02a7e02bdbfe7edb127b69fa53...  3.682644e-05\n12  0000f63151bd00e2ebad53ff5fb207fed9139a89f50711...  1.520301e-06\n13  00010121860f74c1641baa1478a329eb81f2cf4608e32b...  3.138446e-08\n14  000115113b3bd18d3db243e9f5277c99fc6f9a6f20db04...  8.610286e-08","text/html":"<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>customer_ID</th>\n      <th>prediction</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>00000469ba478561f23a92a868bd366de6f6527a684c9a...</td>\n      <td>1.699341e-06</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>00001bf2e77ff879fab36aa4fac689b9ba411dae63ae39...</td>\n      <td>1.691277e-09</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>0000210045da4f81e5f122c6bde5c2a617d03eef67f82c...</td>\n      <td>4.799687e-06</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>00003b41e58ede33b8daf61ab56d9952f17c9ad1c3976c...</td>\n      <td>3.434423e-02</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>00004b22eaeeeb0ec976890c1d9bfc14fd9427e98c4ee9...</td>\n      <td>9.993012e-01</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>00004ffe6e01e1b688170bbd108da8351bc4c316eacfef...</td>\n      <td>2.227487e-09</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>00007cfcce97abfa0b4fa0647986157281d01d3ab90de9...</td>\n      <td>9.998905e-01</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>000089cc2a30dad8e6ba39126f9d86df6088c9f975093a...</td>\n      <td>9.415289e-02</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>00008f50a1dd76fa211ba36a2b0d5a1b201e4134a5fd53...</td>\n      <td>9.762077e-01</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>0000b48a4f27dc1d61e78d081678e811620300b88eb3ab...</td>\n      <td>1.592235e-08</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>0000bccc55cf039a23d49832234f224085716d85bed7d2...</td>\n      <td>7.987277e-03</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>0000c7144ae91777aeeb02a7e02bdbfe7edb127b69fa53...</td>\n      <td>3.682644e-05</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>0000f63151bd00e2ebad53ff5fb207fed9139a89f50711...</td>\n      <td>1.520301e-06</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>00010121860f74c1641baa1478a329eb81f2cf4608e32b...</td>\n      <td>3.138446e-08</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>000115113b3bd18d3db243e9f5277c99fc6f9a6f20db04...</td>\n      <td>8.610286e-08</td>\n    </tr>\n  </tbody>\n</table>\n</div>"},"metadata":{}}],"execution_count":83},{"cell_type":"code","source":"","metadata":{},"outputs":[],"execution_count":null}]}