{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\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":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.052523,"end_time":"2023-02-06T05:48:25.614330","exception":false,"start_time":"2023-02-06T05:48:25.561807","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:30.960943Z","iopub.execute_input":"2023-08-20T07:27:30.961392Z","iopub.status.idle":"2023-08-20T07:27:30.973185Z","shell.execute_reply.started":"2023-08-20T07:27:30.961361Z","shell.execute_reply":"2023-08-20T07:27:30.971603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/amex-default-prediction/train_data.csv', nrows = 200000)\n#df_test = pd.read_csv('/kaggle/input/amex-default-prediction/test_data.csv', nrows = 200000)\ndf_train_labels = pd.read_csv('/kaggle/input/amex-default-prediction/train_labels.csv', nrows = 200000)\n#df_submission = pd.read_csv('/kaggle/input/amex-default-prediction/sample_submission.csv')","metadata":{"papermill":{"duration":17.553369,"end_time":"2023-02-06T05:48:43.194600","exception":false,"start_time":"2023-02-06T05:48:25.641231","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:30.975681Z","iopub.execute_input":"2023-08-20T07:27:30.976097Z","iopub.status.idle":"2023-08-20T07:27:40.785307Z","shell.execute_reply.started":"2023-08-20T07:27:30.976054Z","shell.execute_reply":"2023-08-20T07:27:40.784134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.merge(df_train, df_train_labels, how=\"inner\", on=[\"customer_ID\"])","metadata":{"papermill":{"duration":0.819413,"end_time":"2023-02-06T05:48:44.039659","exception":false,"start_time":"2023-02-06T05:48:43.220246","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:40.789021Z","iopub.execute_input":"2023-08-20T07:27:40.791260Z","iopub.status.idle":"2023-08-20T07:27:41.181963Z","shell.execute_reply.started":"2023-08-20T07:27:40.791208Z","shell.execute_reply":"2023-08-20T07:27:41.180851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head()","metadata":{"papermill":{"duration":0.063722,"end_time":"2023-02-06T05:48:44.128798","exception":false,"start_time":"2023-02-06T05:48:44.065076","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:41.184275Z","iopub.execute_input":"2023-08-20T07:27:41.185346Z","iopub.status.idle":"2023-08-20T07:27:41.212911Z","shell.execute_reply.started":"2023-08-20T07:27:41.185311Z","shell.execute_reply":"2023-08-20T07:27:41.212054Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.tail()","metadata":{"papermill":{"duration":0.056006,"end_time":"2023-02-06T05:48:44.210531","exception":false,"start_time":"2023-02-06T05:48:44.154525","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:41.214472Z","iopub.execute_input":"2023-08-20T07:27:41.215512Z","iopub.status.idle":"2023-08-20T07:27:41.243667Z","shell.execute_reply.started":"2023-08-20T07:27:41.215476Z","shell.execute_reply":"2023-08-20T07:27:41.242417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.shape","metadata":{"papermill":{"duration":0.036778,"end_time":"2023-02-06T05:48:44.273193","exception":false,"start_time":"2023-02-06T05:48:44.236415","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:41.245109Z","iopub.execute_input":"2023-08-20T07:27:41.245447Z","iopub.status.idle":"2023-08-20T07:27:41.259450Z","shell.execute_reply.started":"2023-08-20T07:27:41.245415Z","shell.execute_reply":"2023-08-20T07:27:41.258095Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.columns","metadata":{"papermill":{"duration":0.038031,"end_time":"2023-02-06T05:48:44.337436","exception":false,"start_time":"2023-02-06T05:48:44.299405","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:41.261777Z","iopub.execute_input":"2023-08-20T07:27:41.262321Z","iopub.status.idle":"2023-08-20T07:27:41.274315Z","shell.execute_reply.started":"2023-08-20T07:27:41.262271Z","shell.execute_reply":"2023-08-20T07:27:41.273015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.duplicated().sum()","metadata":{"papermill":{"duration":4.002595,"end_time":"2023-02-06T05:48:48.366145","exception":false,"start_time":"2023-02-06T05:48:44.363550","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:41.275812Z","iopub.execute_input":"2023-08-20T07:27:41.277175Z","iopub.status.idle":"2023-08-20T07:27:45.093316Z","shell.execute_reply.started":"2023-08-20T07:27:41.277125Z","shell.execute_reply":"2023-08-20T07:27:45.091996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isnull().sum()","metadata":{"papermill":{"duration":0.146381,"end_time":"2023-02-06T05:48:48.539866","exception":false,"start_time":"2023-02-06T05:48:48.393485","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:45.097905Z","iopub.execute_input":"2023-08-20T07:27:45.098348Z","iopub.status.idle":"2023-08-20T07:27:45.428674Z","shell.execute_reply.started":"2023-08-20T07:27:45.098311Z","shell.execute_reply":"2023-08-20T07:27:45.427227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nan_cols = [i for i in df_train.columns if df_train[i].isnull().any()]","metadata":{"papermill":{"duration":0.133314,"end_time":"2023-02-06T05:48:48.700583","exception":false,"start_time":"2023-02-06T05:48:48.567269","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:45.430396Z","iopub.execute_input":"2023-08-20T07:27:45.430781Z","iopub.status.idle":"2023-08-20T07:27:45.590109Z","shell.execute_reply.started":"2023-08-20T07:27:45.430747Z","shell.execute_reply":"2023-08-20T07:27:45.588850Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nan_cols","metadata":{"papermill":{"duration":0.039188,"end_time":"2023-02-06T05:48:48.766248","exception":false,"start_time":"2023-02-06T05:48:48.727060","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:45.592001Z","iopub.execute_input":"2023-08-20T07:27:45.592390Z","iopub.status.idle":"2023-08-20T07:27:45.604308Z","shell.execute_reply.started":"2023-08-20T07:27:45.592355Z","shell.execute_reply":"2023-08-20T07:27:45.602830Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"papermill":{"duration":0.047949,"end_time":"2023-02-06T05:48:48.840718","exception":false,"start_time":"2023-02-06T05:48:48.792769","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:45.606363Z","iopub.execute_input":"2023-08-20T07:27:45.606863Z","iopub.status.idle":"2023-08-20T07:27:45.627474Z","shell.execute_reply.started":"2023-08-20T07:27:45.606826Z","shell.execute_reply":"2023-08-20T07:27:45.626459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.describe()","metadata":{"papermill":{"duration":2.364775,"end_time":"2023-02-06T05:48:51.232944","exception":false,"start_time":"2023-02-06T05:48:48.868169","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:45.629284Z","iopub.execute_input":"2023-08-20T07:27:45.629730Z","iopub.status.idle":"2023-08-20T07:27:48.086149Z","shell.execute_reply.started":"2023-08-20T07:27:45.629694Z","shell.execute_reply":"2023-08-20T07:27:48.085262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.nunique()","metadata":{"papermill":{"duration":2.011342,"end_time":"2023-02-06T05:48:53.271703","exception":false,"start_time":"2023-02-06T05:48:51.260361","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:48.087271Z","iopub.execute_input":"2023-08-20T07:27:48.087646Z","iopub.status.idle":"2023-08-20T07:27:50.019821Z","shell.execute_reply.started":"2023-08-20T07:27:48.087615Z","shell.execute_reply":"2023-08-20T07:27:50.018591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols = ['B_30', 'B_38', 'D_114', 'D_116', 'D_117', 'D_120', 'D_126', 'D_63', 'D_64', 'D_66', 'D_68']","metadata":{"papermill":{"duration":0.03668,"end_time":"2023-02-06T05:48:53.335764","exception":false,"start_time":"2023-02-06T05:48:53.299084","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.021535Z","iopub.execute_input":"2023-08-20T07:27:50.022106Z","iopub.status.idle":"2023-08-20T07:27:50.027061Z","shell.execute_reply.started":"2023-08-20T07:27:50.022070Z","shell.execute_reply":"2023-08-20T07:27:50.026001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"papermill":{"duration":0.990574,"end_time":"2023-02-06T05:48:54.353647","exception":false,"start_time":"2023-02-06T05:48:53.363073","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.028417Z","iopub.execute_input":"2023-08-20T07:27:50.029049Z","iopub.status.idle":"2023-08-20T07:27:50.043871Z","shell.execute_reply.started":"2023-08-20T07:27:50.029016Z","shell.execute_reply":"2023-08-20T07:27:50.042298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_cat = df_train[['B_30', 'B_38', 'D_114', 'D_116', 'D_117', 'D_120', 'D_126', 'D_63', 'D_64', 'D_66', 'D_68']]","metadata":{"papermill":{"duration":0.04524,"end_time":"2023-02-06T05:48:54.426308","exception":false,"start_time":"2023-02-06T05:48:54.381068","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.046125Z","iopub.execute_input":"2023-08-20T07:27:50.046513Z","iopub.status.idle":"2023-08-20T07:27:50.282187Z","shell.execute_reply.started":"2023-08-20T07:27:50.046479Z","shell.execute_reply":"2023-08-20T07:27:50.280939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in df_train_cat.columns:\n    print(i)\n    print(df_train_cat[i].unique())\n    print(df_train_cat[i].value_counts())\n    print('\\n')","metadata":{"papermill":{"duration":0.136344,"end_time":"2023-02-06T05:48:54.590759","exception":false,"start_time":"2023-02-06T05:48:54.454415","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.286638Z","iopub.execute_input":"2023-08-20T07:27:50.287035Z","iopub.status.idle":"2023-08-20T07:27:50.442208Z","shell.execute_reply.started":"2023-08-20T07:27:50.287004Z","shell.execute_reply":"2023-08-20T07:27:50.440871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings(\"ignore\")","metadata":{"papermill":{"duration":0.037236,"end_time":"2023-02-06T05:48:54.656198","exception":false,"start_time":"2023-02-06T05:48:54.618962","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.443498Z","iopub.execute_input":"2023-08-20T07:27:50.443870Z","iopub.status.idle":"2023-08-20T07:27:50.448982Z","shell.execute_reply.started":"2023-08-20T07:27:50.443839Z","shell.execute_reply":"2023-08-20T07:27:50.447757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in df_train_cat.columns:\n    plt.figure(figsize=(15,6))\n    sns.countplot(x=i, data = df_train_cat, palette = 'hls')\n    plt.xticks(rotation = 90)\n    plt.show()","metadata":{"papermill":{"duration":3.455517,"end_time":"2023-02-06T05:48:58.139603","exception":false,"start_time":"2023-02-06T05:48:54.684086","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:50.450110Z","iopub.execute_input":"2023-08-20T07:27:50.450422Z","iopub.status.idle":"2023-08-20T07:27:53.487885Z","shell.execute_reply.started":"2023-08-20T07:27:50.450394Z","shell.execute_reply":"2023-08-20T07:27:53.486710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in df_train_cat.columns:\n    plt.figure(figsize=(20,8))\n    df_train_cat[i].value_counts().plot(kind = 'pie',autopct='%1.1f%%', startangle=90)\n    plt.xticks(rotation = 90)\n    plt.show()","metadata":{"papermill":{"duration":1.905775,"end_time":"2023-02-06T05:49:00.075556","exception":false,"start_time":"2023-02-06T05:48:58.169781","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:53.489606Z","iopub.execute_input":"2023-08-20T07:27:53.489988Z","iopub.status.idle":"2023-08-20T07:27:55.245219Z","shell.execute_reply.started":"2023-08-20T07:27:53.489956Z","shell.execute_reply":"2023-08-20T07:27:55.243981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sum(df_train.isna().sum())","metadata":{"papermill":{"duration":0.152158,"end_time":"2023-02-06T05:49:00.280669","exception":false,"start_time":"2023-02-06T05:49:00.128511","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:55.246959Z","iopub.execute_input":"2023-08-20T07:27:55.248394Z","iopub.status.idle":"2023-08-20T07:27:55.573817Z","shell.execute_reply.started":"2023-08-20T07:27:55.248338Z","shell.execute_reply":"2023-08-20T07:27:55.572628Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"custom_colors = [\"#ffd670\",\"#70d6ff\",\"#ff4d6d\",\"#8338ec\",\"#90cf8e\"]\ncustomPalette = sns.set_palette(sns.color_palette(custom_colors))\nsns.palplot(sns.color_palette(custom_colors),size=1.2)\nplt.tick_params(axis='both', labelsize=0, length = 0)","metadata":{"papermill":{"duration":0.1114,"end_time":"2023-02-06T05:49:00.426055","exception":false,"start_time":"2023-02-06T05:49:00.314655","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:55.575540Z","iopub.execute_input":"2023-08-20T07:27:55.576022Z","iopub.status.idle":"2023-08-20T07:27:55.671613Z","shell.execute_reply.started":"2023-08-20T07:27:55.575970Z","shell.execute_reply":"2023-08-20T07:27:55.670455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"background_color = 'white'\nmissing = pd.DataFrame(columns = ['% Missing values'],data = df_train.isnull().sum()/len(df_train))\nfig = plt.figure(figsize = (20, 60),facecolor=background_color)\ngs = fig.add_gridspec(1, 2)\ngs.update(wspace = 0.5, hspace = 0.5)\nax0 = fig.add_subplot(gs[0, 0])\nfor s in [\"right\", \"top\",\"bottom\",\"left\"]:\n    ax0.spines[s].set_visible(False)\nsns.heatmap(missing,cbar = False,annot = True,fmt =\".2%\", linewidths = 2,cmap = custom_colors,vmax = 1, ax = ax0)\nplt.show()","metadata":{"papermill":{"duration":3.360803,"end_time":"2023-02-06T05:49:03.843643","exception":false,"start_time":"2023-02-06T05:49:00.482840","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:55.682825Z","iopub.execute_input":"2023-08-20T07:27:55.683978Z","iopub.status.idle":"2023-08-20T07:27:58.454679Z","shell.execute_reply.started":"2023-08-20T07:27:55.683885Z","shell.execute_reply":"2023-08-20T07:27:58.453634Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.groupby('customer_ID').tail(1).set_index('customer_ID')","metadata":{"papermill":{"duration":0.13698,"end_time":"2023-02-06T05:49:04.019615","exception":false,"start_time":"2023-02-06T05:49:03.882635","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.455985Z","iopub.execute_input":"2023-08-20T07:27:58.456388Z","iopub.status.idle":"2023-08-20T07:27:58.574694Z","shell.execute_reply.started":"2023-08-20T07:27:58.456359Z","shell.execute_reply":"2023-08-20T07:27:58.573426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feat_Delinquency = [c for c in df_train.columns if c.startswith('D_')]\nfeat_Spend = [c for c in df_train.columns if c.startswith('S_')]\nfeat_Payment = [c for c in df_train.columns if c.startswith('P_')]\nfeat_Balance = [c for c in df_train.columns if c.startswith('B_')]\nfeat_Risk = [c for c in df_train.columns if c.startswith('R_')]","metadata":{"papermill":{"duration":0.051063,"end_time":"2023-02-06T05:49:04.109950","exception":false,"start_time":"2023-02-06T05:49:04.058887","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.576117Z","iopub.execute_input":"2023-08-20T07:27:58.577262Z","iopub.status.idle":"2023-08-20T07:27:58.585268Z","shell.execute_reply.started":"2023-08-20T07:27:58.577216Z","shell.execute_reply":"2023-08-20T07:27:58.583959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f'Total number of Delinquency variables: {len(feat_Delinquency)}')\nprint(f'Total number of Spend variables: {len(feat_Spend)}')\nprint(f'Total number of Payment variables: {len(feat_Payment)}')\nprint(f'Total number of Balance variables: {len(feat_Balance)}')\nprint(f'Total number of Risk variables: {len(feat_Risk)}')","metadata":{"papermill":{"duration":0.049634,"end_time":"2023-02-06T05:49:04.199220","exception":false,"start_time":"2023-02-06T05:49:04.149586","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.586732Z","iopub.execute_input":"2023-08-20T07:27:58.587229Z","iopub.status.idle":"2023-08-20T07:27:58.602571Z","shell.execute_reply.started":"2023-08-20T07:27:58.587194Z","shell.execute_reply":"2023-08-20T07:27:58.601193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels=['Delinquency', 'Spend','Payment','Balance','Risk']\nvalues= [len(feat_Delinquency), len(feat_Spend),len(feat_Payment), len(feat_Balance),len(feat_Risk)]","metadata":{"papermill":{"duration":0.048712,"end_time":"2023-02-06T05:49:04.287225","exception":false,"start_time":"2023-02-06T05:49:04.238513","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.604180Z","iopub.execute_input":"2023-08-20T07:27:58.604639Z","iopub.status.idle":"2023-08-20T07:27:58.618093Z","shell.execute_reply.started":"2023-08-20T07:27:58.604602Z","shell.execute_reply":"2023-08-20T07:27:58.616734Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.graph_objects as go\nimport plotly.express as px\nfrom itertools import cycle","metadata":{"papermill":{"duration":1.213971,"end_time":"2023-02-06T05:49:05.540624","exception":false,"start_time":"2023-02-06T05:49:04.326653","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.620031Z","iopub.execute_input":"2023-08-20T07:27:58.620463Z","iopub.status.idle":"2023-08-20T07:27:58.634453Z","shell.execute_reply.started":"2023-08-20T07:27:58.620416Z","shell.execute_reply":"2023-08-20T07:27:58.633176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig_1 = go.Figure()\nfig_1.add_trace(go.Pie(values = values,labels = labels,hole = 0.6, \n                     hoverinfo ='label+percent'))\nfig_1.update_traces(textfont_size = 12, hoverinfo ='label+percent',textinfo ='label', \n                  showlegend = False,marker = dict(colors =[\"#70d6ff\",\"#ff9770\"]),\n                  title = dict(text = 'Feature Distribution'))  \nfig_1.show()","metadata":{"papermill":{"duration":0.14244,"end_time":"2023-02-06T05:49:05.722550","exception":false,"start_time":"2023-02-06T05:49:05.580110","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.637119Z","iopub.execute_input":"2023-08-20T07:27:58.637901Z","iopub.status.idle":"2023-08-20T07:27:58.661297Z","shell.execute_reply.started":"2023-08-20T07:27:58.637853Z","shell.execute_reply":"2023-08-20T07:27:58.660116Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train['target'].unique()","metadata":{"papermill":{"duration":0.050367,"end_time":"2023-02-06T05:49:05.812768","exception":false,"start_time":"2023-02-06T05:49:05.762401","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.662899Z","iopub.execute_input":"2023-08-20T07:27:58.663331Z","iopub.status.idle":"2023-08-20T07:27:58.675499Z","shell.execute_reply.started":"2023-08-20T07:27:58.663297Z","shell.execute_reply":"2023-08-20T07:27:58.674085Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train['target'].value_counts()","metadata":{"papermill":{"duration":0.051335,"end_time":"2023-02-06T05:49:05.903751","exception":false,"start_time":"2023-02-06T05:49:05.852416","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.676848Z","iopub.execute_input":"2023-08-20T07:27:58.677213Z","iopub.status.idle":"2023-08-20T07:27:58.689351Z","shell.execute_reply.started":"2023-08-20T07:27:58.677184Z","shell.execute_reply":"2023-08-20T07:27:58.688189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,6))\nsns.countplot(x='target', data = df_train, palette = 'hls')\nplt.xticks(rotation = 90)\nplt.show()","metadata":{"papermill":{"duration":0.223712,"end_time":"2023-02-06T05:49:06.167221","exception":false,"start_time":"2023-02-06T05:49:05.943509","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.690741Z","iopub.execute_input":"2023-08-20T07:27:58.691172Z","iopub.status.idle":"2023-08-20T07:27:58.940041Z","shell.execute_reply.started":"2023-08-20T07:27:58.691138Z","shell.execute_reply":"2023-08-20T07:27:58.938751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20,8))\ndf_train['target'].value_counts().plot(kind = 'pie',autopct='%1.1f%%', startangle=90)\nplt.xticks(rotation = 90)\nplt.show()","metadata":{"papermill":{"duration":0.154739,"end_time":"2023-02-06T05:49:06.361358","exception":false,"start_time":"2023-02-06T05:49:06.206619","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:58.941544Z","iopub.execute_input":"2023-08-20T07:27:58.941896Z","iopub.status.idle":"2023-08-20T07:27:59.121448Z","shell.execute_reply.started":"2023-08-20T07:27:58.941866Z","shell.execute_reply":"2023-08-20T07:27:59.119892Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_class = pd.DataFrame({'count': df_train.target.value_counts(),\n                             'percentage': df_train['target'].value_counts() / df_train.shape[0] * 100\n})","metadata":{"papermill":{"duration":0.050981,"end_time":"2023-02-06T05:49:06.478247","exception":false,"start_time":"2023-02-06T05:49:06.427266","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.123247Z","iopub.execute_input":"2023-08-20T07:27:59.123729Z","iopub.status.idle":"2023-08-20T07:27:59.134272Z","shell.execute_reply.started":"2023-08-20T07:27:59.123669Z","shell.execute_reply":"2023-08-20T07:27:59.133012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_class ","metadata":{"papermill":{"duration":0.053394,"end_time":"2023-02-06T05:49:06.571687","exception":false,"start_time":"2023-02-06T05:49:06.518293","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.136416Z","iopub.execute_input":"2023-08-20T07:27:59.137439Z","iopub.status.idle":"2023-08-20T07:27:59.152834Z","shell.execute_reply.started":"2023-08-20T07:27:59.137391Z","shell.execute_reply":"2023-08-20T07:27:59.151454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = go.Figure()\nfig.add_trace(go.Pie(values = target_class['count'],labels = target_class.index,hole = 0.6, \n                     hoverinfo ='label+percent'))\nfig.update_traces(textfont_size = 12, hoverinfo ='label+percent',textinfo ='label', \n                  showlegend = False,marker = dict(colors =[\"#90cf8e\",\"#ff70a6\"]),\n                  title = dict(text = 'Target Distribution'))  \nfig.show()","metadata":{"papermill":{"duration":0.061272,"end_time":"2023-02-06T05:49:06.673305","exception":false,"start_time":"2023-02-06T05:49:06.612033","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.154428Z","iopub.execute_input":"2023-08-20T07:27:59.156427Z","iopub.status.idle":"2023-08-20T07:27:59.175855Z","shell.execute_reply.started":"2023-08-20T07:27:59.156378Z","shell.execute_reply":"2023-08-20T07:27:59.174746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"stat_plot = df_train.reset_index().groupby('S_2')['customer_ID'].nunique().reset_index()\nfig = go.Figure()\nfig.add_trace(go.Scatter(x = stat_plot['S_2'], y = stat_plot['customer_ID']))\nfig.update_layout(title=\"Customer Statements\", width = 800, height = 600,xaxis_title ='Statement Date',\n                  paper_bgcolor='rgb(0,0,0,0)',plot_bgcolor='rgb(0,0,0,0)') \nfig['data'][0]['line']['color']=\"#ff9770\"\nfig.show()","metadata":{"papermill":{"duration":0.1318,"end_time":"2023-02-06T05:49:06.845890","exception":false,"start_time":"2023-02-06T05:49:06.714090","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.177436Z","iopub.execute_input":"2023-08-20T07:27:59.179389Z","iopub.status.idle":"2023-08-20T07:27:59.235426Z","shell.execute_reply.started":"2023-08-20T07:27:59.179345Z","shell.execute_reply":"2023-08-20T07:27:59.234608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import gc","metadata":{"papermill":{"duration":0.048385,"end_time":"2023-02-06T05:49:06.934574","exception":false,"start_time":"2023-02-06T05:49:06.886189","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.236618Z","iopub.execute_input":"2023-08-20T07:27:59.237724Z","iopub.status.idle":"2023-08-20T07:27:59.241535Z","shell.execute_reply.started":"2023-08-20T07:27:59.237691Z","shell.execute_reply":"2023-08-20T07:27:59.240451Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gc.collect()","metadata":{"papermill":{"duration":0.189459,"end_time":"2023-02-06T05:49:07.164379","exception":false,"start_time":"2023-02-06T05:49:06.974920","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.243313Z","iopub.execute_input":"2023-08-20T07:27:59.244462Z","iopub.status.idle":"2023-08-20T07:27:59.795290Z","shell.execute_reply.started":"2023-08-20T07:27:59.244419Z","shell.execute_reply":"2023-08-20T07:27:59.794018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.drop('S_2', axis = 1)","metadata":{"papermill":{"duration":0.069567,"end_time":"2023-02-06T05:49:07.274860","exception":false,"start_time":"2023-02-06T05:49:07.205293","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.797071Z","iopub.execute_input":"2023-08-20T07:27:59.797411Z","iopub.status.idle":"2023-08-20T07:27:59.819244Z","shell.execute_reply.started":"2023-08-20T07:27:59.797383Z","shell.execute_reply":"2023-08-20T07:27:59.818015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del_cols = [c for c in df_train.columns if (c.startswith(('D','t'))) & (c not in cat_cols)]\ndf_del = df_train[del_cols]\nspd_cols = [c for c in df_train.columns if (c.startswith(('S','t'))) & (c not in cat_cols)]\ndf_spd = df_train[spd_cols]\npay_cols = [c for c in df_train.columns if (c.startswith(('P','t'))) & (c not in cat_cols)]\ndf_pay = df_train[pay_cols]\nbal_cols = [c for c in df_train.columns if (c.startswith(('B','t'))) & (c not in cat_cols)]\ndf_bal = df_train[bal_cols]\nris_cols = [c for c in df_train.columns if (c.startswith(('R','t'))) & (c not in cat_cols)]\ndf_ris = df_train[ris_cols]","metadata":{"papermill":{"duration":0.065405,"end_time":"2023-02-06T05:49:07.381219","exception":false,"start_time":"2023-02-06T05:49:07.315814","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.820427Z","iopub.execute_input":"2023-08-20T07:27:59.821196Z","iopub.status.idle":"2023-08-20T07:27:59.862962Z","shell.execute_reply.started":"2023-08-20T07:27:59.821162Z","shell.execute_reply":"2023-08-20T07:27:59.862041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(29, 3, figsize = (35,150))\nfor i, ax in enumerate(axes.reshape(-1)):\n    if i < len(del_cols) - 1:\n        sns.kdeplot(x = del_cols[i], hue='target', data = df_del, fill = True, ax = ax, palette =[\"#e63946\",\"#8338ec\"])\n        ax.tick_params()\n        ax.xaxis.get_label()\n        ax.set_ylabel('')\nfig.suptitle('Distribution of Delinquency Variables', fontsize = 35, x = 0.5, y = 1)\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":26.594602,"end_time":"2023-02-06T05:49:34.016839","exception":false,"start_time":"2023-02-06T05:49:07.422237","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:27:59.864184Z","iopub.execute_input":"2023-08-20T07:27:59.865220Z","iopub.status.idle":"2023-08-20T07:28:36.662615Z","shell.execute_reply.started":"2023-08-20T07:27:59.865183Z","shell.execute_reply":"2023-08-20T07:28:36.661146Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize =(11,11))\ncorr = df_del.corr()\nmask = np.triu(np.ones_like(corr, dtype = bool))\nsns.heatmap(corr, mask = mask, robust = True, center = 0,square = True, linewidths =.6, cmap = custom_colors)\nplt.title('Correlation of Delinquency Variables')\nplt.show()","metadata":{"papermill":{"duration":1.29579,"end_time":"2023-02-06T05:49:35.381503","exception":false,"start_time":"2023-02-06T05:49:34.085713","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:36.664394Z","iopub.execute_input":"2023-08-20T07:28:36.664807Z","iopub.status.idle":"2023-08-20T07:28:38.158011Z","shell.execute_reply.started":"2023-08-20T07:28:36.664770Z","shell.execute_reply":"2023-08-20T07:28:38.156712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(8, 3, figsize = (16,18))\nfig.suptitle('Distribution of Spend Variables', fontsize = 15, x = 0.5, y = 1)\nfor i, ax in enumerate(axes.reshape(-1)):\n    if i < len(spd_cols) - 1:\n        sns.kdeplot(x = spd_cols[i], hue ='target', data = df_spd, fill = True, ax = ax, palette =[\"#e63946\",\"#8338ec\"])\n        ax.tick_params()\n        ax.xaxis.get_label()\n        ax.set_ylabel('')\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":6.532749,"end_time":"2023-02-06T05:49:41.980892","exception":false,"start_time":"2023-02-06T05:49:35.448143","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:38.160009Z","iopub.execute_input":"2023-08-20T07:28:38.160499Z","iopub.status.idle":"2023-08-20T07:28:46.466365Z","shell.execute_reply.started":"2023-08-20T07:28:38.160450Z","shell.execute_reply":"2023-08-20T07:28:46.465202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"S_cols = [c for c in df_train.columns if (c.startswith(('S')))]\ndf_S = df_train[S_cols]","metadata":{"papermill":{"duration":0.080974,"end_time":"2023-02-06T05:49:42.134694","exception":false,"start_time":"2023-02-06T05:49:42.053720","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:46.467861Z","iopub.execute_input":"2023-08-20T07:28:46.469030Z","iopub.status.idle":"2023-08-20T07:28:46.477414Z","shell.execute_reply.started":"2023-08-20T07:28:46.468992Z","shell.execute_reply":"2023-08-20T07:28:46.475865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (11,11))\ncorr = df_S.corr()\nmask = np.triu(np.ones_like(corr, dtype=bool))\nsns.heatmap(corr, mask = mask, robust = True, center = 0,square = True, linewidths = .6, cmap = custom_colors)\nplt.title('Correlation of Spend Variables')\nplt.show()","metadata":{"papermill":{"duration":0.629853,"end_time":"2023-02-06T05:49:42.834532","exception":false,"start_time":"2023-02-06T05:49:42.204679","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:46.479391Z","iopub.execute_input":"2023-08-20T07:28:46.480036Z","iopub.status.idle":"2023-08-20T07:28:47.165515Z","shell.execute_reply.started":"2023-08-20T07:28:46.479993Z","shell.execute_reply":"2023-08-20T07:28:47.164475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(1, 3, figsize = (12,4))\nfig.suptitle('Distribution of Payment Variables',fontsize = 15)\nfor i, ax in enumerate(axes.reshape(-1)):\n    if i < len(pay_cols) - 1:\n        sns.kdeplot(x = pay_cols[i], hue ='target', data = df_pay, fill = True, ax = ax, palette =[\"#e63946\",\"#8338ec\"])\n        ax.tick_params()\n        ax.xaxis.get_label()\n        ax.set_ylabel('')\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":0.987782,"end_time":"2023-02-06T05:49:43.892326","exception":false,"start_time":"2023-02-06T05:49:42.904544","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:47.167244Z","iopub.execute_input":"2023-08-20T07:28:47.167829Z","iopub.status.idle":"2023-08-20T07:28:48.531784Z","shell.execute_reply.started":"2023-08-20T07:28:47.167794Z","shell.execute_reply":"2023-08-20T07:28:48.530388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"P_cols = [c for c in df_train.columns if (c.startswith(('P')))]\ndf_P = df_train[P_cols]","metadata":{"papermill":{"duration":0.080724,"end_time":"2023-02-06T05:49:44.042259","exception":false,"start_time":"2023-02-06T05:49:43.961535","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:48.533573Z","iopub.execute_input":"2023-08-20T07:28:48.534634Z","iopub.status.idle":"2023-08-20T07:28:48.543771Z","shell.execute_reply.started":"2023-08-20T07:28:48.534584Z","shell.execute_reply":"2023-08-20T07:28:48.542458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (6,6))\ncorr = df_P.corr()\nmask = np.triu(np.ones_like(corr, dtype = bool))\nsns.heatmap(corr, mask = mask, robust = True, center = 0,square = True, linewidths = .6, cmap = custom_colors)\nplt.title('Correlation of Payment Variables')\nplt.show()","metadata":{"papermill":{"duration":0.305519,"end_time":"2023-02-06T05:49:44.417295","exception":false,"start_time":"2023-02-06T05:49:44.111776","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:48.545230Z","iopub.execute_input":"2023-08-20T07:28:48.545648Z","iopub.status.idle":"2023-08-20T07:28:48.864043Z","shell.execute_reply.started":"2023-08-20T07:28:48.545613Z","shell.execute_reply":"2023-08-20T07:28:48.863209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(10, 4, figsize = (15,24))\nfig.suptitle('Distribution of Balance Variables',fontsize = 15, x = 0.5, y = 1)\nfor i, ax in enumerate(axes.reshape(-1)):\n    if i < len(bal_cols) - 1:\n        sns.kdeplot(x = bal_cols[i], hue ='target', data = df_bal, fill = True, ax = ax, palette =[\"#e63946\",\"#8338ec\"])\n        ax.tick_params()\n        ax.xaxis.get_label()\n        ax.set_ylabel('')\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":11.329377,"end_time":"2023-02-06T05:49:55.816718","exception":false,"start_time":"2023-02-06T05:49:44.487341","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:28:48.865342Z","iopub.execute_input":"2023-08-20T07:28:48.865888Z","iopub.status.idle":"2023-08-20T07:29:03.982301Z","shell.execute_reply.started":"2023-08-20T07:28:48.865857Z","shell.execute_reply":"2023-08-20T07:29:03.981040Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"B_cols = [c for c in df_train.columns if (c.startswith(('B')))]\ndf_B = df_train[B_cols]","metadata":{"papermill":{"duration":0.085499,"end_time":"2023-02-06T05:49:55.978072","exception":false,"start_time":"2023-02-06T05:49:55.892573","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:03.983999Z","iopub.execute_input":"2023-08-20T07:29:03.984371Z","iopub.status.idle":"2023-08-20T07:29:03.993601Z","shell.execute_reply.started":"2023-08-20T07:29:03.984337Z","shell.execute_reply":"2023-08-20T07:29:03.992532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (11,11))\ncorr = df_B.corr()\nmask = np.triu(np.ones_like(corr, dtype = bool))\nsns.heatmap(corr, mask = mask, robust=True, center = 0,square = True, linewidths =.6, cmap = custom_colors)\nplt.title('Correlation of Balance Variables')\nplt.show()","metadata":{"papermill":{"duration":0.936554,"end_time":"2023-02-06T05:49:56.989291","exception":false,"start_time":"2023-02-06T05:49:56.052737","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:03.994971Z","iopub.execute_input":"2023-08-20T07:29:03.995329Z","iopub.status.idle":"2023-08-20T07:29:05.043871Z","shell.execute_reply.started":"2023-08-20T07:29:03.995299Z","shell.execute_reply":"2023-08-20T07:29:05.042688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(10, 3, figsize = (18,23))\nfig.suptitle('Distribution of Risk Variables',fontsize=15, x = 0.5, y = 1)\nfor i, ax in enumerate(axes.reshape(-1)):\n    if i < len(ris_cols) - 1:\n        sns.kdeplot(x = ris_cols[i], hue ='target', data = df_ris, fill = True, ax = ax, palette =[\"#e63946\",\"#8338ec\"])\n        ax.tick_params()\n        ax.xaxis.get_label()\n        ax.set_ylabel('')\nplt.tight_layout()\nplt.show()","metadata":{"papermill":{"duration":8.564456,"end_time":"2023-02-06T05:50:05.635055","exception":false,"start_time":"2023-02-06T05:49:57.070599","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:05.045535Z","iopub.execute_input":"2023-08-20T07:29:05.046108Z","iopub.status.idle":"2023-08-20T07:29:16.081392Z","shell.execute_reply.started":"2023-08-20T07:29:05.046066Z","shell.execute_reply":"2023-08-20T07:29:16.079982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"R_cols = [c for c in df_train.columns if (c.startswith(('R')))]\ndf_R = df_train[R_cols]","metadata":{"papermill":{"duration":0.088398,"end_time":"2023-02-06T05:50:05.803322","exception":false,"start_time":"2023-02-06T05:50:05.714924","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:16.082897Z","iopub.execute_input":"2023-08-20T07:29:16.083326Z","iopub.status.idle":"2023-08-20T07:29:16.092098Z","shell.execute_reply.started":"2023-08-20T07:29:16.083291Z","shell.execute_reply":"2023-08-20T07:29:16.090726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(11,11))\ncorr = df_R.corr()\nmask = np.triu(np.ones_like(corr, dtype=bool))\nsns.heatmap(corr, mask = mask, robust = True, center = 0, square = True, linewidths =.6, cmap = custom_colors)\nplt.title('Correlation of Risk Variables')\nplt.show()","metadata":{"papermill":{"duration":0.72312,"end_time":"2023-02-06T05:50:06.604102","exception":false,"start_time":"2023-02-06T05:50:05.880982","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:16.093893Z","iopub.execute_input":"2023-08-20T07:29:16.094373Z","iopub.status.idle":"2023-08-20T07:29:16.915964Z","shell.execute_reply.started":"2023-08-20T07:29:16.094330Z","shell.execute_reply":"2023-08-20T07:29:16.914614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"palette = cycle([\"#ffd670\",\"#70d6ff\",\"#ff4d6d\",\"#8338ec\",\"#90cf8e\"])\ntarg = df_train.corrwith(df_train['target'], axis=0)\nval = [str(round(v ,1) *100) + '%' for v in targ.values]\nfig = go.Figure()\nfig.add_trace(go.Bar(y=targ.index, x= targ.values, orientation='h',text = val, marker_color = next(palette)))\nfig.update_layout(title = \"Correlation of variables with Target\",width = 750, height = 3500,\n                  paper_bgcolor='rgb(0,0,0,0)',plot_bgcolor='rgb(0,0,0,0)')","metadata":{"papermill":{"duration":0.214454,"end_time":"2023-02-06T05:50:06.895420","exception":false,"start_time":"2023-02-06T05:50:06.680966","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:16.917431Z","iopub.execute_input":"2023-08-20T07:29:16.917789Z","iopub.status.idle":"2023-08-20T07:29:17.052311Z","shell.execute_reply.started":"2023-08-20T07:29:16.917758Z","shell.execute_reply":"2023-08-20T07:29:17.051011Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gc.collect()","metadata":{"papermill":{"duration":0.359713,"end_time":"2023-02-06T05:50:07.332318","exception":false,"start_time":"2023-02-06T05:50:06.972605","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:17.053568Z","iopub.execute_input":"2023-08-20T07:29:17.054280Z","iopub.status.idle":"2023-08-20T07:29:18.400685Z","shell.execute_reply.started":"2023-08-20T07:29:17.054248Z","shell.execute_reply":"2023-08-20T07:29:18.399410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nlab_enc = LabelEncoder()\nfor cat_feat in cat_cols:\n    df_train[cat_feat] = lab_enc.fit_transform(df_train[cat_feat])","metadata":{"papermill":{"duration":0.286746,"end_time":"2023-02-06T05:50:07.696247","exception":false,"start_time":"2023-02-06T05:50:07.409501","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.402157Z","iopub.execute_input":"2023-08-20T07:29:18.402515Z","iopub.status.idle":"2023-08-20T07:29:18.483195Z","shell.execute_reply.started":"2023-08-20T07:29:18.402478Z","shell.execute_reply":"2023-08-20T07:29:18.482169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.drop('target', axis=1)\ny = df_train['target']","metadata":{"papermill":{"duration":0.095921,"end_time":"2023-02-06T05:50:07.870625","exception":false,"start_time":"2023-02-06T05:50:07.774704","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.484913Z","iopub.execute_input":"2023-08-20T07:29:18.485396Z","iopub.status.idle":"2023-08-20T07:29:18.500317Z","shell.execute_reply.started":"2023-08-20T07:29:18.485353Z","shell.execute_reply":"2023-08-20T07:29:18.498079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.info()","metadata":{"papermill":{"duration":0.106725,"end_time":"2023-02-06T05:50:08.055389","exception":false,"start_time":"2023-02-06T05:50:07.948664","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.501673Z","iopub.execute_input":"2023-08-20T07:29:18.502088Z","iopub.status.idle":"2023-08-20T07:29:18.525687Z","shell.execute_reply.started":"2023-08-20T07:29:18.502057Z","shell.execute_reply":"2023-08-20T07:29:18.524773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"papermill":{"duration":0.09027,"end_time":"2023-02-06T05:50:08.236157","exception":false,"start_time":"2023-02-06T05:50:08.145887","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.527297Z","iopub.execute_input":"2023-08-20T07:29:18.527647Z","iopub.status.idle":"2023-08-20T07:29:18.541243Z","shell.execute_reply.started":"2023-08-20T07:29:18.527619Z","shell.execute_reply":"2023-08-20T07:29:18.539800Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y.shape","metadata":{"papermill":{"duration":0.086973,"end_time":"2023-02-06T05:50:08.400151","exception":false,"start_time":"2023-02-06T05:50:08.313178","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.542641Z","iopub.execute_input":"2023-08-20T07:29:18.542997Z","iopub.status.idle":"2023-08-20T07:29:18.557371Z","shell.execute_reply.started":"2023-08-20T07:29:18.542952Z","shell.execute_reply":"2023-08-20T07:29:18.556154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n\n# creating dataset split for prediction\nX_train, X_test , y_train , y_test = train_test_split(X,y,test_size=0.2,random_state=42) # 80-20 split\n\n# Checking split \nprint('X_train:', X_train.shape)\nprint('y_train:', y_train.shape)\nprint('X_test:', X_test.shape)\nprint('y_test:', y_test.shape)","metadata":{"papermill":{"duration":0.164097,"end_time":"2023-02-06T05:50:08.641403","exception":false,"start_time":"2023-02-06T05:50:08.477306","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.558647Z","iopub.execute_input":"2023-08-20T07:29:18.559123Z","iopub.status.idle":"2023-08-20T07:29:18.586478Z","shell.execute_reply.started":"2023-08-20T07:29:18.559081Z","shell.execute_reply":"2023-08-20T07:29:18.585260Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from catboost import CatBoostClassifier\nclf = CatBoostClassifier(iterations = 3000, random_state = 42)\nclf.fit(X_train, y_train, eval_set = [(X_test, y_test)], cat_features=cat_cols,  verbose = 100)\npreds = clf.predict_proba(X_test)[:, 1]","metadata":{"papermill":{"duration":176.941325,"end_time":"2023-02-06T05:53:05.661942","exception":false,"start_time":"2023-02-06T05:50:08.720617","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:29:18.588081Z","iopub.execute_input":"2023-08-20T07:29:18.588441Z","iopub.status.idle":"2023-08-20T07:32:33.878732Z","shell.execute_reply.started":"2023-08-20T07:29:18.588411Z","shell.execute_reply":"2023-08-20T07:32:33.877335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = clf.predict(X_test)","metadata":{"papermill":{"duration":0.125112,"end_time":"2023-02-06T05:53:05.880099","exception":false,"start_time":"2023-02-06T05:53:05.754987","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.880361Z","iopub.execute_input":"2023-08-20T07:32:33.880775Z","iopub.status.idle":"2023-08-20T07:32:33.918625Z","shell.execute_reply.started":"2023-08-20T07:32:33.880739Z","shell.execute_reply":"2023-08-20T07:32:33.917151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score","metadata":{"papermill":{"duration":0.091023,"end_time":"2023-02-06T05:53:06.053694","exception":false,"start_time":"2023-02-06T05:53:05.962671","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.920947Z","iopub.execute_input":"2023-08-20T07:32:33.921328Z","iopub.status.idle":"2023-08-20T07:32:33.926188Z","shell.execute_reply.started":"2023-08-20T07:32:33.921295Z","shell.execute_reply":"2023-08-20T07:32:33.925230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, y_pred)","metadata":{"papermill":{"duration":0.096597,"end_time":"2023-02-06T05:53:06.232979","exception":false,"start_time":"2023-02-06T05:53:06.136382","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.927850Z","iopub.execute_input":"2023-08-20T07:32:33.928279Z","iopub.status.idle":"2023-08-20T07:32:33.944873Z","shell.execute_reply.started":"2023-08-20T07:32:33.928246Z","shell.execute_reply":"2023-08-20T07:32:33.943689Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import confusion_matrix  \ncm = confusion_matrix(y_test, y_pred)","metadata":{"papermill":{"duration":0.095331,"end_time":"2023-02-06T05:53:06.409424","exception":false,"start_time":"2023-02-06T05:53:06.314093","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.960562Z","iopub.execute_input":"2023-08-20T07:32:33.960995Z","iopub.status.idle":"2023-08-20T07:32:33.969100Z","shell.execute_reply.started":"2023-08-20T07:32:33.960953Z","shell.execute_reply":"2023-08-20T07:32:33.967774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm","metadata":{"papermill":{"duration":0.091668,"end_time":"2023-02-06T05:53:06.582069","exception":false,"start_time":"2023-02-06T05:53:06.490401","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.970572Z","iopub.execute_input":"2023-08-20T07:32:33.971274Z","iopub.status.idle":"2023-08-20T07:32:33.981463Z","shell.execute_reply.started":"2023-08-20T07:32:33.971223Z","shell.execute_reply":"2023-08-20T07:32:33.980294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=[10,7],)\nsns.heatmap(cm, annot = True)\nplt.show()","metadata":{"papermill":{"duration":0.279979,"end_time":"2023-02-06T05:53:06.942371","exception":false,"start_time":"2023-02-06T05:53:06.662392","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:33.983013Z","iopub.execute_input":"2023-08-20T07:32:33.983381Z","iopub.status.idle":"2023-08-20T07:32:34.321775Z","shell.execute_reply.started":"2023-08-20T07:32:33.983351Z","shell.execute_reply":"2023-08-20T07:32:34.320433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import classification_report\nprint(classification_report(y_test, y_pred))","metadata":{"papermill":{"duration":0.103717,"end_time":"2023-02-06T05:53:07.126309","exception":false,"start_time":"2023-02-06T05:53:07.022592","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.324129Z","iopub.execute_input":"2023-08-20T07:32:34.324642Z","iopub.status.idle":"2023-08-20T07:32:34.347444Z","shell.execute_reply.started":"2023-08-20T07:32:34.324596Z","shell.execute_reply":"2023-08-20T07:32:34.346227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"threshold = 0.8\ndf_train = df_train.drop(df_train.columns[df_train.isnull().mean() >= threshold], axis=1)","metadata":{"papermill":{"duration":0.104241,"end_time":"2023-02-06T05:53:07.311833","exception":false,"start_time":"2023-02-06T05:53:07.207592","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.348843Z","iopub.execute_input":"2023-08-20T07:32:34.349192Z","iopub.status.idle":"2023-08-20T07:32:34.378170Z","shell.execute_reply.started":"2023-08-20T07:32:34.349144Z","shell.execute_reply":"2023-08-20T07:32:34.377132Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head()","metadata":{"papermill":{"duration":0.114372,"end_time":"2023-02-06T05:53:07.506627","exception":false,"start_time":"2023-02-06T05:53:07.392255","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.379478Z","iopub.execute_input":"2023-08-20T07:32:34.379807Z","iopub.status.idle":"2023-08-20T07:32:34.411005Z","shell.execute_reply.started":"2023-08-20T07:32:34.379778Z","shell.execute_reply":"2023-08-20T07:32:34.409717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.shape","metadata":{"papermill":{"duration":0.091403,"end_time":"2023-02-06T05:53:07.678661","exception":false,"start_time":"2023-02-06T05:53:07.587258","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.412585Z","iopub.execute_input":"2023-08-20T07:32:34.412901Z","iopub.status.idle":"2023-08-20T07:32:34.420230Z","shell.execute_reply.started":"2023-08-20T07:32:34.412874Z","shell.execute_reply":"2023-08-20T07:32:34.418986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.columns","metadata":{"papermill":{"duration":0.093904,"end_time":"2023-02-06T05:53:07.854154","exception":false,"start_time":"2023-02-06T05:53:07.760250","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.421684Z","iopub.execute_input":"2023-08-20T07:32:34.422059Z","iopub.status.idle":"2023-08-20T07:32:34.432834Z","shell.execute_reply.started":"2023-08-20T07:32:34.422028Z","shell.execute_reply":"2023-08-20T07:32:34.431609Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.duplicated().sum()","metadata":{"papermill":{"duration":0.306175,"end_time":"2023-02-06T05:53:08.242117","exception":false,"start_time":"2023-02-06T05:53:07.935942","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.434494Z","iopub.execute_input":"2023-08-20T07:32:34.434951Z","iopub.status.idle":"2023-08-20T07:32:34.649646Z","shell.execute_reply.started":"2023-08-20T07:32:34.434889Z","shell.execute_reply":"2023-08-20T07:32:34.648431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.isnull().sum()","metadata":{"papermill":{"duration":0.100495,"end_time":"2023-02-06T05:53:08.424268","exception":false,"start_time":"2023-02-06T05:53:08.323773","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.651392Z","iopub.execute_input":"2023-08-20T07:32:34.651870Z","iopub.status.idle":"2023-08-20T07:32:34.669986Z","shell.execute_reply.started":"2023-08-20T07:32:34.651827Z","shell.execute_reply":"2023-08-20T07:32:34.668868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = df_train.fillna(0)","metadata":{"papermill":{"duration":0.101329,"end_time":"2023-02-06T05:53:08.607076","exception":false,"start_time":"2023-02-06T05:53:08.505747","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.671518Z","iopub.execute_input":"2023-08-20T07:32:34.672081Z","iopub.status.idle":"2023-08-20T07:32:34.690282Z","shell.execute_reply.started":"2023-08-20T07:32:34.672040Z","shell.execute_reply":"2023-08-20T07:32:34.689178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.drop('target', axis=1)\ny = df_train['target']","metadata":{"papermill":{"duration":0.100947,"end_time":"2023-02-06T05:53:08.791258","exception":false,"start_time":"2023-02-06T05:53:08.690311","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.691993Z","iopub.execute_input":"2023-08-20T07:32:34.692357Z","iopub.status.idle":"2023-08-20T07:32:34.705423Z","shell.execute_reply.started":"2023-08-20T07:32:34.692326Z","shell.execute_reply":"2023-08-20T07:32:34.704372Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"papermill":{"duration":0.092577,"end_time":"2023-02-06T05:53:08.965388","exception":false,"start_time":"2023-02-06T05:53:08.872811","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.707039Z","iopub.execute_input":"2023-08-20T07:32:34.707496Z","iopub.status.idle":"2023-08-20T07:32:34.729280Z","shell.execute_reply.started":"2023-08-20T07:32:34.707448Z","shell.execute_reply":"2023-08-20T07:32:34.727762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import ExtraTreesClassifier\nimport matplotlib.pyplot as plt\nmodel = ExtraTreesClassifier()\nmodel.fit(X,y)\nprint(model.feature_importances_)","metadata":{"papermill":{"duration":4.694099,"end_time":"2023-02-06T05:53:13.742432","exception":false,"start_time":"2023-02-06T05:53:09.048333","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:34.731064Z","iopub.execute_input":"2023-08-20T07:32:34.731800Z","iopub.status.idle":"2023-08-20T07:32:39.441692Z","shell.execute_reply.started":"2023-08-20T07:32:34.731764Z","shell.execute_reply":"2023-08-20T07:32:39.440550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = df_train.iloc[:,:-1]","metadata":{"papermill":{"duration":0.096092,"end_time":"2023-02-06T05:53:13.921482","exception":false,"start_time":"2023-02-06T05:53:13.825390","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:39.443627Z","iopub.execute_input":"2023-08-20T07:32:39.444136Z","iopub.status.idle":"2023-08-20T07:32:39.456117Z","shell.execute_reply.started":"2023-08-20T07:32:39.444092Z","shell.execute_reply":"2023-08-20T07:32:39.454862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"feat_importances = pd.Series(model.feature_importances_, index=X.columns)\nfeat_importances.nlargest(10).plot(kind='barh')\nplt.show()","metadata":{"papermill":{"duration":0.26167,"end_time":"2023-02-06T05:53:14.265314","exception":false,"start_time":"2023-02-06T05:53:14.003644","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:39.457466Z","iopub.execute_input":"2023-08-20T07:32:39.457865Z","iopub.status.idle":"2023-08-20T07:32:39.756533Z","shell.execute_reply.started":"2023-08-20T07:32:39.457834Z","shell.execute_reply":"2023-08-20T07:32:39.755333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test , y_train , y_test = train_test_split(X,y,test_size=0.2,random_state=42) # 80-20 split\nprint('X_train:', X_train.shape)\nprint('y_train:', y_train.shape)\nprint('X_test:', X_test.shape)\nprint('y_test:', y_test.shape)","metadata":{"papermill":{"duration":0.116819,"end_time":"2023-02-06T05:53:14.464557","exception":false,"start_time":"2023-02-06T05:53:14.347738","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:39.757794Z","iopub.execute_input":"2023-08-20T07:32:39.758167Z","iopub.status.idle":"2023-08-20T07:32:39.786476Z","shell.execute_reply.started":"2023-08-20T07:32:39.758137Z","shell.execute_reply":"2023-08-20T07:32:39.785326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression  \nlog_r= LogisticRegression(random_state=0)  \nlog_r.fit(X_train, y_train)","metadata":{"papermill":{"duration":0.443538,"end_time":"2023-02-06T05:53:14.990711","exception":false,"start_time":"2023-02-06T05:53:14.547173","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:39.787775Z","iopub.execute_input":"2023-08-20T07:32:39.788691Z","iopub.status.idle":"2023-08-20T07:32:40.217638Z","shell.execute_reply.started":"2023-08-20T07:32:39.788658Z","shell.execute_reply":"2023-08-20T07:32:40.216151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_lr= log_r.predict(X_test)","metadata":{"papermill":{"duration":0.107429,"end_time":"2023-02-06T05:53:15.252994","exception":false,"start_time":"2023-02-06T05:53:15.145565","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.219961Z","iopub.execute_input":"2023-08-20T07:32:40.220888Z","iopub.status.idle":"2023-08-20T07:32:40.239304Z","shell.execute_reply.started":"2023-08-20T07:32:40.220832Z","shell.execute_reply":"2023-08-20T07:32:40.237352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, y_pred_lr)","metadata":{"papermill":{"duration":0.096544,"end_time":"2023-02-06T05:53:15.481102","exception":false,"start_time":"2023-02-06T05:53:15.384558","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.242577Z","iopub.execute_input":"2023-08-20T07:32:40.243961Z","iopub.status.idle":"2023-08-20T07:32:40.259342Z","shell.execute_reply.started":"2023-08-20T07:32:40.243878Z","shell.execute_reply":"2023-08-20T07:32:40.257477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm = confusion_matrix(y_test, y_pred_lr)","metadata":{"papermill":{"duration":0.093422,"end_time":"2023-02-06T05:53:15.656116","exception":false,"start_time":"2023-02-06T05:53:15.562694","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.262601Z","iopub.execute_input":"2023-08-20T07:32:40.263890Z","iopub.status.idle":"2023-08-20T07:32:40.275911Z","shell.execute_reply.started":"2023-08-20T07:32:40.263827Z","shell.execute_reply":"2023-08-20T07:32:40.273983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm","metadata":{"papermill":{"duration":0.094304,"end_time":"2023-02-06T05:53:15.832311","exception":false,"start_time":"2023-02-06T05:53:15.738007","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.279367Z","iopub.execute_input":"2023-08-20T07:32:40.280766Z","iopub.status.idle":"2023-08-20T07:32:40.291775Z","shell.execute_reply.started":"2023-08-20T07:32:40.280693Z","shell.execute_reply":"2023-08-20T07:32:40.290161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=[10,7],)\nsns.heatmap(cm, annot = True)\nplt.show()","metadata":{"papermill":{"duration":0.282414,"end_time":"2023-02-06T05:53:16.196425","exception":false,"start_time":"2023-02-06T05:53:15.914011","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.294968Z","iopub.execute_input":"2023-08-20T07:32:40.296323Z","iopub.status.idle":"2023-08-20T07:32:40.642010Z","shell.execute_reply.started":"2023-08-20T07:32:40.296259Z","shell.execute_reply":"2023-08-20T07:32:40.641144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_test, y_pred_lr))","metadata":{"papermill":{"duration":0.104247,"end_time":"2023-02-06T05:53:16.383943","exception":false,"start_time":"2023-02-06T05:53:16.279696","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.643491Z","iopub.execute_input":"2023-08-20T07:32:40.644279Z","iopub.status.idle":"2023-08-20T07:32:40.662909Z","shell.execute_reply.started":"2023-08-20T07:32:40.644243Z","shell.execute_reply":"2023-08-20T07:32:40.662106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.tree import DecisionTreeClassifier\ndt = DecisionTreeClassifier()\ndt.fit(X_train, y_train)","metadata":{"papermill":{"duration":5.222103,"end_time":"2023-02-06T05:53:21.688705","exception":false,"start_time":"2023-02-06T05:53:16.466602","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:40.664249Z","iopub.execute_input":"2023-08-20T07:32:40.664761Z","iopub.status.idle":"2023-08-20T07:32:45.985221Z","shell.execute_reply.started":"2023-08-20T07:32:40.664731Z","shell.execute_reply":"2023-08-20T07:32:45.983983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred_dt= dt.predict(X_test)","metadata":{"papermill":{"duration":0.097251,"end_time":"2023-02-06T05:53:21.870623","exception":false,"start_time":"2023-02-06T05:53:21.773372","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:45.986953Z","iopub.execute_input":"2023-08-20T07:32:45.987806Z","iopub.status.idle":"2023-08-20T07:32:46.000402Z","shell.execute_reply.started":"2023-08-20T07:32:45.987762Z","shell.execute_reply":"2023-08-20T07:32:45.999075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, y_pred_dt)","metadata":{"papermill":{"duration":0.094613,"end_time":"2023-02-06T05:53:22.047789","exception":false,"start_time":"2023-02-06T05:53:21.953176","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.002279Z","iopub.execute_input":"2023-08-20T07:32:46.002865Z","iopub.status.idle":"2023-08-20T07:32:46.016152Z","shell.execute_reply.started":"2023-08-20T07:32:46.002823Z","shell.execute_reply":"2023-08-20T07:32:46.014901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm = confusion_matrix(y_test, y_pred_dt)","metadata":{"papermill":{"duration":0.09475,"end_time":"2023-02-06T05:53:22.225433","exception":false,"start_time":"2023-02-06T05:53:22.130683","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.017761Z","iopub.execute_input":"2023-08-20T07:32:46.018294Z","iopub.status.idle":"2023-08-20T07:32:46.025142Z","shell.execute_reply.started":"2023-08-20T07:32:46.018252Z","shell.execute_reply":"2023-08-20T07:32:46.024183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm","metadata":{"papermill":{"duration":0.093915,"end_time":"2023-02-06T05:53:22.402156","exception":false,"start_time":"2023-02-06T05:53:22.308241","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.026855Z","iopub.execute_input":"2023-08-20T07:32:46.027261Z","iopub.status.idle":"2023-08-20T07:32:46.036040Z","shell.execute_reply.started":"2023-08-20T07:32:46.027231Z","shell.execute_reply":"2023-08-20T07:32:46.035088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=[10,7],)\nsns.heatmap(cm, annot = True)\nplt.show()","metadata":{"papermill":{"duration":0.275811,"end_time":"2023-02-06T05:53:22.761698","exception":false,"start_time":"2023-02-06T05:53:22.485887","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.037456Z","iopub.execute_input":"2023-08-20T07:32:46.037846Z","iopub.status.idle":"2023-08-20T07:32:46.349288Z","shell.execute_reply.started":"2023-08-20T07:32:46.037814Z","shell.execute_reply":"2023-08-20T07:32:46.347901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_test, y_pred_dt))","metadata":{"papermill":{"duration":0.106613,"end_time":"2023-02-06T05:53:22.953697","exception":false,"start_time":"2023-02-06T05:53:22.847084","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.350689Z","iopub.execute_input":"2023-08-20T07:32:46.351092Z","iopub.status.idle":"2023-08-20T07:32:46.372265Z","shell.execute_reply.started":"2023-08-20T07:32:46.351060Z","shell.execute_reply":"2023-08-20T07:32:46.371139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier  \nrf_c = RandomForestClassifier(n_estimators= 10, criterion=\"entropy\")  \nrf_c.fit(X_train, y_train) ","metadata":{"papermill":{"duration":1.602007,"end_time":"2023-02-06T05:53:24.639686","exception":false,"start_time":"2023-02-06T05:53:23.037679","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:46.373825Z","iopub.execute_input":"2023-08-20T07:32:46.374206Z","iopub.status.idle":"2023-08-20T07:32:48.413758Z","shell.execute_reply.started":"2023-08-20T07:32:46.374176Z","shell.execute_reply":"2023-08-20T07:32:48.412533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{"papermill":{"duration":0.083715,"end_time":"2023-02-06T05:53:24.806894","exception":false,"start_time":"2023-02-06T05:53:24.723179","status":"completed"},"tags":[]}},{"cell_type":"code","source":"y_pred_rf_c= rf_c.predict(X_test)  ","metadata":{"papermill":{"duration":0.108154,"end_time":"2023-02-06T05:53:24.998588","exception":false,"start_time":"2023-02-06T05:53:24.890434","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.415695Z","iopub.execute_input":"2023-08-20T07:32:48.416194Z","iopub.status.idle":"2023-08-20T07:32:48.436386Z","shell.execute_reply.started":"2023-08-20T07:32:48.416162Z","shell.execute_reply":"2023-08-20T07:32:48.435375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_test, y_pred_rf_c)","metadata":{"papermill":{"duration":0.094333,"end_time":"2023-02-06T05:53:25.179602","exception":false,"start_time":"2023-02-06T05:53:25.085269","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.437863Z","iopub.execute_input":"2023-08-20T07:32:48.438430Z","iopub.status.idle":"2023-08-20T07:32:48.447722Z","shell.execute_reply.started":"2023-08-20T07:32:48.438387Z","shell.execute_reply":"2023-08-20T07:32:48.446548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm= confusion_matrix(y_test, y_pred_rf_c) ","metadata":{"papermill":{"duration":0.092536,"end_time":"2023-02-06T05:53:25.356084","exception":false,"start_time":"2023-02-06T05:53:25.263548","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.449445Z","iopub.execute_input":"2023-08-20T07:32:48.449809Z","iopub.status.idle":"2023-08-20T07:32:48.458797Z","shell.execute_reply.started":"2023-08-20T07:32:48.449779Z","shell.execute_reply":"2023-08-20T07:32:48.457495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cm","metadata":{"papermill":{"duration":0.093872,"end_time":"2023-02-06T05:53:25.533817","exception":false,"start_time":"2023-02-06T05:53:25.439945","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.460644Z","iopub.execute_input":"2023-08-20T07:32:48.461075Z","iopub.status.idle":"2023-08-20T07:32:48.471937Z","shell.execute_reply.started":"2023-08-20T07:32:48.461020Z","shell.execute_reply":"2023-08-20T07:32:48.470781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=[10,7],)\nsns.heatmap(cm, annot = True)\nplt.show()","metadata":{"papermill":{"duration":0.288081,"end_time":"2023-02-06T05:53:25.905803","exception":false,"start_time":"2023-02-06T05:53:25.617722","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.473774Z","iopub.execute_input":"2023-08-20T07:32:48.474482Z","iopub.status.idle":"2023-08-20T07:32:48.796996Z","shell.execute_reply.started":"2023-08-20T07:32:48.474437Z","shell.execute_reply":"2023-08-20T07:32:48.795775Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(classification_report(y_test, y_pred_rf_c))","metadata":{"papermill":{"duration":0.119284,"end_time":"2023-02-06T05:53:26.108342","exception":false,"start_time":"2023-02-06T05:53:25.989058","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.798132Z","iopub.execute_input":"2023-08-20T07:32:48.798781Z","iopub.status.idle":"2023-08-20T07:32:48.821015Z","shell.execute_reply.started":"2023-08-20T07:32:48.798747Z","shell.execute_reply":"2023-08-20T07:32:48.819756Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import StratifiedKFold\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn.model_selection import GridSearchCV","metadata":{"papermill":{"duration":0.092949,"end_time":"2023-02-06T05:53:26.297233","exception":false,"start_time":"2023-02-06T05:53:26.204284","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.824490Z","iopub.execute_input":"2023-08-20T07:32:48.824859Z","iopub.status.idle":"2023-08-20T07:32:48.830637Z","shell.execute_reply.started":"2023-08-20T07:32:48.824827Z","shell.execute_reply":"2023-08-20T07:32:48.829410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"folds = StratifiedKFold(n_splits = 5, shuffle = True, random_state = 40)","metadata":{"papermill":{"duration":0.095359,"end_time":"2023-02-06T05:53:26.477492","exception":false,"start_time":"2023-02-06T05:53:26.382133","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.832456Z","iopub.execute_input":"2023-08-20T07:32:48.832824Z","iopub.status.idle":"2023-08-20T07:32:48.843265Z","shell.execute_reply.started":"2023-08-20T07:32:48.832785Z","shell.execute_reply":"2023-08-20T07:32:48.842015Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def grid_search(model,folds,params,scoring):\n    grid_search = GridSearchCV(model,\n                                cv=folds, \n                                param_grid=params, \n                                scoring=scoring, \n                                n_jobs=-1, verbose=1)\n    return grid_search","metadata":{"papermill":{"duration":0.093927,"end_time":"2023-02-06T05:53:26.656045","exception":false,"start_time":"2023-02-06T05:53:26.562118","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.845234Z","iopub.execute_input":"2023-08-20T07:32:48.845581Z","iopub.status.idle":"2023-08-20T07:32:48.859480Z","shell.execute_reply.started":"2023-08-20T07:32:48.845550Z","shell.execute_reply":"2023-08-20T07:32:48.858560Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def print_best_score_params(model):\n    print(\"Best Score: \", model.best_score_)\n    print(\"Best Hyperparameters: \", model.best_params_)","metadata":{"papermill":{"duration":0.09803,"end_time":"2023-02-06T05:53:26.838336","exception":false,"start_time":"2023-02-06T05:53:26.740306","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.860692Z","iopub.execute_input":"2023-08-20T07:32:48.861086Z","iopub.status.idle":"2023-08-20T07:32:48.871897Z","shell.execute_reply.started":"2023-08-20T07:32:48.861054Z","shell.execute_reply":"2023-08-20T07:32:48.870996Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"log_reg = LogisticRegression()\nlog_params = {'C': [0.01, 1, 10], \n          'penalty': ['l1', 'l2'],\n          'solver': ['liblinear','newton-cg','saga']\n         }\ngrid_search_log = grid_search(log_reg, folds, log_params, scoring=None)\ngrid_search_log.fit(X_train, y_train)\nprint_best_score_params(grid_search_log)","metadata":{"papermill":{"duration":108.072581,"end_time":"2023-02-06T05:55:15.002178","exception":false,"start_time":"2023-02-06T05:53:26.929597","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:32:48.872851Z","iopub.execute_input":"2023-08-20T07:32:48.873205Z","iopub.status.idle":"2023-08-20T07:34:30.411234Z","shell.execute_reply.started":"2023-08-20T07:32:48.873176Z","shell.execute_reply":"2023-08-20T07:34:30.409657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dtc = DecisionTreeClassifier(random_state=40)\ndtc_params = {\n    'max_depth': [5,10,20,30],\n    'min_samples_leaf': [5,10,20,30]\n}\ngrid_search_dtc = grid_search(dtc, folds, dtc_params, scoring='roc_auc_ovr')\ngrid_search_dtc.fit(X_train, y_train)\nprint_best_score_params(grid_search_dtc)","metadata":{"papermill":{"duration":55.391534,"end_time":"2023-02-06T05:56:10.478174","exception":false,"start_time":"2023-02-06T05:55:15.086640","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:34:30.413300Z","iopub.execute_input":"2023-08-20T07:34:30.413793Z","iopub.status.idle":"2023-08-20T07:35:29.241132Z","shell.execute_reply.started":"2023-08-20T07:34:30.413744Z","shell.execute_reply":"2023-08-20T07:35:29.239733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Dense\n\nmodel = Sequential()\nmodel.add(Dense(64, input_dim=X_train.shape[1], activation='relu'))\nmodel.add(Dense(32, activation='relu'))\nmodel.add(Dense(1, activation='sigmoid'))\n\nmodel.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])","metadata":{"papermill":{"duration":6.081858,"end_time":"2023-02-06T05:56:16.648016","exception":false,"start_time":"2023-02-06T05:56:10.566158","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:35:29.242716Z","iopub.execute_input":"2023-08-20T07:35:29.243212Z","iopub.status.idle":"2023-08-20T07:35:29.313328Z","shell.execute_reply.started":"2023-08-20T07:35:29.243166Z","shell.execute_reply":"2023-08-20T07:35:29.312256Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(X_train, y_train, epochs=20, batch_size=32)","metadata":{"papermill":{"duration":18.373864,"end_time":"2023-02-06T05:56:35.119471","exception":false,"start_time":"2023-02-06T05:56:16.745607","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:35:29.315018Z","iopub.execute_input":"2023-08-20T07:35:29.315393Z","iopub.status.idle":"2023-08-20T07:35:47.056153Z","shell.execute_reply.started":"2023-08-20T07:35:29.315364Z","shell.execute_reply":"2023-08-20T07:35:47.054834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_loss, test_acc = model.evaluate(X_test, y_test)\nprint('Test accuracy:', test_acc)","metadata":{"papermill":{"duration":0.515797,"end_time":"2023-02-06T05:56:35.744364","exception":false,"start_time":"2023-02-06T05:56:35.228567","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-08-20T07:35:47.057796Z","iopub.execute_input":"2023-08-20T07:35:47.058373Z","iopub.status.idle":"2023-08-20T07:35:47.598100Z","shell.execute_reply.started":"2023-08-20T07:35:47.058330Z","shell.execute_reply":"2023-08-20T07:35:47.596695Z"},"trusted":true},"execution_count":null,"outputs":[]}]}