{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"raw","source":"","metadata":{}},{"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-10-09T18:01:45.420519Z","iopub.execute_input":"2022-10-09T18:01:45.421208Z","iopub.status.idle":"2022-10-09T18:01:45.437305Z","shell.execute_reply.started":"2022-10-09T18:01:45.421172Z","shell.execute_reply":"2022-10-09T18:01:45.435857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv('../input/amex-default-prediction/train_data.csv',nrows=200000)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:45.938361Z","iopub.execute_input":"2022-10-09T18:01:45.938804Z","iopub.status.idle":"2022-10-09T18:01:56.784513Z","shell.execute_reply.started":"2022-10-09T18:01:45.938747Z","shell.execute_reply":"2022-10-09T18:01:56.783131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.head()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:56.786957Z","iopub.execute_input":"2022-10-09T18:01:56.788023Z","iopub.status.idle":"2022-10-09T18:01:56.816420Z","shell.execute_reply.started":"2022-10-09T18:01:56.787981Z","shell.execute_reply":"2022-10-09T18:01:56.814852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.tail()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:56.817743Z","iopub.execute_input":"2022-10-09T18:01:56.818155Z","iopub.status.idle":"2022-10-09T18:01:56.846571Z","shell.execute_reply.started":"2022-10-09T18:01:56.818087Z","shell.execute_reply":"2022-10-09T18:01:56.845412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.info()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:56.849706Z","iopub.execute_input":"2022-10-09T18:01:56.851131Z","iopub.status.idle":"2022-10-09T18:01:56.871366Z","shell.execute_reply.started":"2022-10-09T18:01:56.851082Z","shell.execute_reply":"2022-10-09T18:01:56.870540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.describe().T","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:56.872702Z","iopub.execute_input":"2022-10-09T18:01:56.873295Z","iopub.status.idle":"2022-10-09T18:01:59.032589Z","shell.execute_reply.started":"2022-10-09T18:01:56.873260Z","shell.execute_reply":"2022-10-09T18:01:59.031504Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:59.033961Z","iopub.execute_input":"2022-10-09T18:01:59.034294Z","iopub.status.idle":"2022-10-09T18:01:59.147204Z","shell.execute_reply.started":"2022-10-09T18:01:59.034263Z","shell.execute_reply":"2022-10-09T18:01:59.145953Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data.shape","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:59.148741Z","iopub.execute_input":"2022-10-09T18:01:59.149692Z","iopub.status.idle":"2022-10-09T18:01:59.157749Z","shell.execute_reply.started":"2022-10-09T18:01:59.149647Z","shell.execute_reply":"2022-10-09T18:01:59.156533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Target = pd.read_csv('../input/amex-default-prediction/train_labels.csv',nrows=200000)","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:59.159405Z","iopub.execute_input":"2022-10-09T18:01:59.159830Z","iopub.status.idle":"2022-10-09T18:01:59.395856Z","shell.execute_reply.started":"2022-10-09T18:01:59.159765Z","shell.execute_reply":"2022-10-09T18:01:59.394688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Target","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:59.397673Z","iopub.execute_input":"2022-10-09T18:01:59.398088Z","iopub.status.idle":"2022-10-09T18:01:59.411635Z","shell.execute_reply.started":"2022-10-09T18:01:59.398054Z","shell.execute_reply":"2022-10-09T18:01:59.410415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data1 = pd.merge(data,Target)\ndata1","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:01:59.415167Z","iopub.execute_input":"2022-10-09T18:01:59.415560Z","iopub.status.idle":"2022-10-09T18:02:00.270892Z","shell.execute_reply.started":"2022-10-09T18:01:59.415524Z","shell.execute_reply":"2022-10-09T18:02:00.270019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data1.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:02:00.272425Z","iopub.execute_input":"2022-10-09T18:02:00.272866Z","iopub.status.idle":"2022-10-09T18:02:00.281924Z","shell.execute_reply.started":"2022-10-09T18:02:00.272829Z","shell.execute_reply":"2022-10-09T18:02:00.280728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data1.isnull().mean().round(2) * 100","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:13:40.296267Z","iopub.execute_input":"2022-10-09T18:13:40.296923Z","iopub.status.idle":"2022-10-09T18:13:40.417689Z","shell.execute_reply.started":"2022-10-09T18:13:40.296865Z","shell.execute_reply":"2022-10-09T18:13:40.416461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data2 = data1.drop(data1.columns[data1.isnull().mean()>0.80],axis=1)\ndata2","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:14:39.542597Z","iopub.execute_input":"2022-10-09T18:14:39.543047Z","iopub.status.idle":"2022-10-09T18:14:39.784803Z","shell.execute_reply.started":"2022-10-09T18:14:39.543011Z","shell.execute_reply":"2022-10-09T18:14:39.783593Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categorical = ['customer_ID', 'S_2', 'D_63', 'D_64','B_30', 'B_38', 'D_114', 'D_116', 'D_117', 'D_120', 'D_126', 'D_63', 'D_64', 'D_68']\n\nnumerical = [col for col in data2.columns if col not in categorical]","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:16:18.430630Z","iopub.execute_input":"2022-10-09T18:16:18.431049Z","iopub.status.idle":"2022-10-09T18:16:18.439477Z","shell.execute_reply.started":"2022-10-09T18:16:18.431016Z","shell.execute_reply":"2022-10-09T18:16:18.438138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# imputation of null values\n\nfor i in categorical:\n    data2[i]=data2[i].fillna(data2[i].mode()[0])\n    \nfor i in numerical:\n    data2[i]=data2[i].fillna(data2[i].mean())","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:17:27.663059Z","iopub.execute_input":"2022-10-09T18:17:27.663587Z","iopub.status.idle":"2022-10-09T18:17:28.029024Z","shell.execute_reply.started":"2022-10-09T18:17:27.663547Z","shell.execute_reply":"2022-10-09T18:17:28.027795Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data2.isnull().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:17:49.753428Z","iopub.execute_input":"2022-10-09T18:17:49.754204Z","iopub.status.idle":"2022-10-09T18:17:49.842600Z","shell.execute_reply.started":"2022-10-09T18:17:49.754164Z","shell.execute_reply":"2022-10-09T18:17:49.841208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# distribution count of target variable\ndata2['target'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-10-09T18:18:22.082438Z","iopub.execute_input":"2022-10-09T18:18:22.082967Z","iopub.status.idle":"2022-10-09T18:18:22.094084Z","shell.execute_reply.started":"2022-10-09T18:18:22.082927Z","shell.execute_reply":"2022-10-09T18:18:22.092847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}