{"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":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport gc\n\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-12-12T17:31:32.963293Z","iopub.execute_input":"2022-12-12T17:31:32.963867Z","iopub.status.idle":"2022-12-12T17:31:34.462893Z","shell.execute_reply.started":"2022-12-12T17:31:32.963722Z","shell.execute_reply":"2022-12-12T17:31:34.461916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset_ = pd.read_feather('../input/amexfeather/train_data.ftr')\n# Keep the latest statement features for each customer\ntrain_dataset = train_dataset_.groupby('customer_ID').tail(1).set_index('customer_ID', drop=True).sort_index()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:31:34.465702Z","iopub.execute_input":"2022-12-12T17:31:34.466386Z","iopub.status.idle":"2022-12-12T17:31:59.766887Z","shell.execute_reply.started":"2022-12-12T17:31:34.466331Z","shell.execute_reply":"2022-12-12T17:31:59.765911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del train_dataset_\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:31:59.768332Z","iopub.execute_input":"2022-12-12T17:31:59.768691Z","iopub.status.idle":"2022-12-12T17:31:59.892302Z","shell.execute_reply.started":"2022-12-12T17:31:59.768652Z","shell.execute_reply":"2022-12-12T17:31:59.891242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:31:59.895291Z","iopub.execute_input":"2022-12-12T17:31:59.895648Z","iopub.status.idle":"2022-12-12T17:31:59.928076Z","shell.execute_reply.started":"2022-12-12T17:31:59.895614Z","shell.execute_reply":"2022-12-12T17:31:59.927205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.info(max_cols=191,show_counts=True)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:31:59.930949Z","iopub.execute_input":"2022-12-12T17:31:59.931276Z","iopub.status.idle":"2022-12-12T17:32:00.287560Z","shell.execute_reply.started":"2022-12-12T17:31:59.931248Z","shell.execute_reply":"2022-12-12T17:32:00.285501Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.describe()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:00.289291Z","iopub.execute_input":"2022-12-12T17:32:00.289688Z","iopub.status.idle":"2022-12-12T17:32:11.921587Z","shell.execute_reply.started":"2022-12-12T17:32:00.289656Z","shell.execute_reply":"2022-12-12T17:32:11.920490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"categorical_cols = ['B_30', 'B_38', 'D_114', 'D_116', 'D_117', 'D_120', 'D_126', 'D_63', 'D_64', 'D_66', 'D_68']\n\nnum_cols = [col for col in train_dataset.columns if col not in categorical_cols + [\"target\"]]\n\nprint(f'Total number of features: {1}')\nprint(f'Total number of categorical features: {len(categorical_cols)}')\nprint(f'Total number of continuos features: {len(num_cols)}')","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:11.923375Z","iopub.execute_input":"2022-12-12T17:32:11.924013Z","iopub.status.idle":"2022-12-12T17:32:11.933437Z","shell.execute_reply.started":"2022-12-12T17:32:11.923974Z","shell.execute_reply":"2022-12-12T17:32:11.932143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(x = 'target', data = train_dataset)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:11.934827Z","iopub.execute_input":"2022-12-12T17:32:11.937272Z","iopub.status.idle":"2022-12-12T17:32:12.329610Z","shell.execute_reply.started":"2022-12-12T17:32:11.937194Z","shell.execute_reply":"2022-12-12T17:32:12.328674Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 30))\nfor i, k in enumerate(categorical_cols):\n    plt.subplot(6, 2, i+1)\n    temp_val = pd.DataFrame(train_dataset[k].value_counts(dropna=False, normalize=True).sort_index().rename('count'))\n    temp_val.index.name = 'value'\n    temp_val.reset_index(inplace=True)\n    plt.bar(temp_val.index, temp_val['count'], alpha=0.5)\n    plt.xlabel(k)\n    plt.ylabel('frequency')\n    plt.xticks(temp_val.index, temp_val.value)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:12.333623Z","iopub.execute_input":"2022-12-12T17:32:12.336435Z","iopub.status.idle":"2022-12-12T17:32:13.941643Z","shell.execute_reply.started":"2022-12-12T17:32:12.336398Z","shell.execute_reply":"2022-12-12T17:32:13.940622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(20, 30))\nfor i, f in enumerate(categorical_cols):\n    plt.subplot(6, 2, i+1)\n    temp = pd.DataFrame(train_dataset[f][train_dataset.target == 0].value_counts(dropna=False, normalize=True).sort_index().rename('count'))\n    temp.index.name = 'value'\n    temp.reset_index(inplace=True)\n    plt.bar(temp.index, temp['count'], alpha=0.5, label='target=0')\n    temp = pd.DataFrame(train_dataset[f][train_dataset.target == 1].value_counts(dropna=False, normalize=True).sort_index().rename('count'))\n    temp.index.name = 'value'\n    temp.reset_index(inplace=True)\n    plt.bar(temp.index, temp['count'], alpha=0.5, label='target=1')\n    plt.xlabel(f)\n    plt.ylabel('frequency')\n    plt.legend()\n    plt.xticks(temp.index, temp.value)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:13.946156Z","iopub.execute_input":"2022-12-12T17:32:13.946955Z","iopub.status.idle":"2022-12-12T17:32:15.867959Z","shell.execute_reply.started":"2022-12-12T17:32:13.946926Z","shell.execute_reply":"2022-12-12T17:32:15.866979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i, l in enumerate(num_cols):\n    if i % 4 == 0: \n        if i > 0: plt.show()\n        plt.figure(figsize=(20, 3))\n    plt.subplot(1, 4, i % 4 + 1)\n    plt.hist(train_dataset[l], bins=200, color='#C69C73')\n    plt.xlabel(l)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:32:15.869091Z","iopub.execute_input":"2022-12-12T17:32:15.870234Z","iopub.status.idle":"2022-12-12T17:33:42.688610Z","shell.execute_reply.started":"2022-12-12T17:32:15.870176Z","shell.execute_reply":"2022-12-12T17:33:42.687236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Delinquency = [d for d in train_dataset.columns if d.startswith('D_')]\nSpend = [s for s in train_dataset.columns if s.startswith('S_')]\nPayment = [p for p in train_dataset.columns if p.startswith('P_')]\nBalance = [b for b in train_dataset.columns if b.startswith('B_')]\nRisk = [r for r in train_dataset.columns if r.startswith('R_')]\nDict = {'Delinquency': len(Delinquency), 'Spend': len(Spend), 'Payment': len(Payment), 'Balance': len(Balance), 'Risk': len(Risk),}\n\nplt.figure(figsize=(10,5))\nsns.barplot(x=list(Dict.keys()), y=list(Dict.values()));","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:42.691902Z","iopub.execute_input":"2022-12-12T17:33:42.692176Z","iopub.status.idle":"2022-12-12T17:33:42.897146Z","shell.execute_reply.started":"2022-12-12T17:33:42.692149Z","shell.execute_reply":"2022-12-12T17:33:42.896240Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NaN_Val = np.array(train_dataset.isnull().sum())\nNaN_prec = np.array((train_dataset.isnull().sum() * 100 / len(train_dataset)).round(2))\nNaN_Col = pd.DataFrame([np.array(list(train_dataset.columns)).T,NaN_Val.T,NaN_prec.T,np.array(list(train_dataset.dtypes)).T], index=['Features','Num of Missing values','Percentage','DataType']\n).transpose()\npd.set_option('display.max_rows', None)\nNaN_Col","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:42.898645Z","iopub.execute_input":"2022-12-12T17:33:42.899003Z","iopub.status.idle":"2022-12-12T17:33:43.530940Z","shell.execute_reply.started":"2022-12-12T17:33:42.898968Z","shell.execute_reply":"2022-12-12T17:33:43.529764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset = train_dataset.drop(['S_2','D_66','D_42','D_49','D_73','D_76','R_9','B_29','D_87','D_88','D_106','R_26','D_108','D_110','D_111','B_39','B_42','D_132','D_134','D_135','D_136','D_137','D_138','D_142'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:43.532479Z","iopub.execute_input":"2022-12-12T17:33:43.532919Z","iopub.status.idle":"2022-12-12T17:33:43.780695Z","shell.execute_reply.started":"2022-12-12T17:33:43.532884Z","shell.execute_reply":"2022-12-12T17:33:43.779710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"selected_col = np.array(['P_2','S_3','B_2','D_41','D_43','B_3','D_44','D_45','D_46','D_48','D_50','D_53','S_7','D_56','S_9','B_6','B_8','D_52','P_3','D_54','D_55','B_13','D_59','D_61','B_15','D_62','B_16','B_17','D_77','B_19','B_20','D_69','B_22','D_70','D_72','D_74','R_7','B_25','B_26','D_78','D_79','D_80','B_27','D_81','R_12','D_82','D_105','S_27','D_83','R_14','D_84','D_86','R_20','B_33','D_89','D_91','S_22','S_23','S_24','S_25','S_26','D_102','D_103','D_104','D_107','B_37','R_27','D_109','D_112','B_40','D_113','D_115','D_118','D_119','D_121','D_122','D_123','D_124','D_125','D_128','D_129','B_41','D_130','D_131','D_133','D_139','D_140','D_141','D_143','D_144','D_145'])\n\nfor col in selected_col:\n    train_dataset[col] = train_dataset[col].fillna(train_dataset[col].median())","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:43.782119Z","iopub.execute_input":"2022-12-12T17:33:43.782607Z","iopub.status.idle":"2022-12-12T17:33:45.031263Z","shell.execute_reply.started":"2022-12-12T17:33:43.782570Z","shell.execute_reply":"2022-12-12T17:33:45.030107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"selcted_col2 = np.array(['D_68','B_30','B_38','D_64','D_114','D_116','D_117','D_120','D_126'])\n\nfor col2 in selcted_col2:\n    train_dataset[col2] =  train_dataset[col2].fillna(train_dataset[col2].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:45.035910Z","iopub.execute_input":"2022-12-12T17:33:45.038265Z","iopub.status.idle":"2022-12-12T17:33:45.103614Z","shell.execute_reply.started":"2022-12-12T17:33:45.038226Z","shell.execute_reply":"2022-12-12T17:33:45.102764Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(train_dataset.isnull().sum().to_string())","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:45.107569Z","iopub.execute_input":"2022-12-12T17:33:45.109840Z","iopub.status.idle":"2022-12-12T17:33:45.385445Z","shell.execute_reply.started":"2022-12-12T17:33:45.109805Z","shell.execute_reply":"2022-12-12T17:33:45.384355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:45.388545Z","iopub.execute_input":"2022-12-12T17:33:45.388866Z","iopub.status.idle":"2022-12-12T17:33:45.395132Z","shell.execute_reply.started":"2022-12-12T17:33:45.388839Z","shell.execute_reply":"2022-12-12T17:33:45.394225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:45.396590Z","iopub.execute_input":"2022-12-12T17:33:45.397192Z","iopub.status.idle":"2022-12-12T17:33:45.429046Z","shell.execute_reply.started":"2022-12-12T17:33:45.397139Z","shell.execute_reply":"2022-12-12T17:33:45.428103Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset_ = pd.read_feather('../input/amexfeather/test_data.ftr')\n# Keep the latest statement features for each customer\ntest_dataset = test_dataset_.groupby('customer_ID').tail(1).set_index('customer_ID', drop=True).sort_index()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:33:45.430243Z","iopub.execute_input":"2022-12-12T17:33:45.430564Z","iopub.status.idle":"2022-12-12T17:34:34.379912Z","shell.execute_reply.started":"2022-12-12T17:33:45.430529Z","shell.execute_reply":"2022-12-12T17:34:34.378507Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del test_dataset_\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:34.381821Z","iopub.execute_input":"2022-12-12T17:34:34.382526Z","iopub.status.idle":"2022-12-12T17:34:34.549253Z","shell.execute_reply.started":"2022-12-12T17:34:34.382490Z","shell.execute_reply":"2022-12-12T17:34:34.548236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:34.550982Z","iopub.execute_input":"2022-12-12T17:34:34.551461Z","iopub.status.idle":"2022-12-12T17:34:34.583172Z","shell.execute_reply.started":"2022-12-12T17:34:34.551420Z","shell.execute_reply":"2022-12-12T17:34:34.582101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:34.584525Z","iopub.execute_input":"2022-12-12T17:34:34.585348Z","iopub.status.idle":"2022-12-12T17:34:34.595706Z","shell.execute_reply.started":"2022-12-12T17:34:34.585313Z","shell.execute_reply":"2022-12-12T17:34:34.594744Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"NaN_Val2 = np.array(test_dataset.isnull().sum())\nNaN_prec2 = np.array((test_dataset.isnull().sum() * 100 / len(test_dataset)).round(2))\nNaN_Col2 = pd.DataFrame([np.array(list(test_dataset.columns)).T,NaN_Val2.T,NaN_prec2.T,np.array(list(test_dataset.dtypes)).T], index=['Features','Num of Missing values','Percentage','DataType']\n).transpose()\npd.set_option('display.max_rows', None)\n\nNaN_Col2","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:34.597041Z","iopub.execute_input":"2022-12-12T17:34:34.597678Z","iopub.status.idle":"2022-12-12T17:34:36.230240Z","shell.execute_reply.started":"2022-12-12T17:34:34.597637Z","shell.execute_reply":"2022-12-12T17:34:36.229144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset = test_dataset.drop(['S_2','D_42','D_49','D_66','D_73','D_76','R_9','B_29','D_87','D_88','D_106','R_26','D_108','D_110','D_111','B_39','B_42','D_132','D_134','D_135','D_136','D_137','D_138','D_142'], axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:36.232207Z","iopub.execute_input":"2022-12-12T17:34:36.232972Z","iopub.status.idle":"2022-12-12T17:34:36.763215Z","shell.execute_reply.started":"2022-12-12T17:34:36.232931Z","shell.execute_reply":"2022-12-12T17:34:36.762070Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"selected_column = np.array(['P_2','S_3','B_2','D_41','D_43','B_3','D_44','D_45','D_46','D_48','D_50','D_53','S_7','D_56','S_9','S_12','S_17','B_6','B_8','D_52','P_3','D_54','D_55','B_13','D_59','D_61','B_15','D_62','B_16','B_17','D_77','B_19','B_20','D_69','B_22','D_70','D_72','D_74','R_7','B_25','B_26','D_78','D_79','D_80','B_27','D_81','R_12','D_82','D_105','S_27','D_83','R_14','D_84','D_86','R_20','B_33','D_89','D_91','S_22','S_23','S_24','S_25','S_26','D_102','D_103','D_104','D_107','B_37','R_27','D_109','D_112','B_40','D_113','D_115','D_118','D_119','D_121','D_122','D_123','D_124','D_125','D_128','D_129','B_41','D_130','D_131','D_133','D_139','D_140','D_141','D_143','D_144','D_145'])\n\nfor column in selected_column:\n    test_dataset[column] = test_dataset[column].fillna(test_dataset[column].median())","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:36.764902Z","iopub.execute_input":"2022-12-12T17:34:36.765359Z","iopub.status.idle":"2022-12-12T17:34:39.038949Z","shell.execute_reply.started":"2022-12-12T17:34:36.765318Z","shell.execute_reply":"2022-12-12T17:34:39.037958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"selected_column = np.array(['P_2','S_3','B_2','D_41','D_43','B_3','D_44','D_45','D_46','D_48','D_50','D_53','S_7','D_56','S_9','S_12','S_17','B_6','B_8','D_52','P_3','D_54','D_55','B_13','D_59','D_61','B_15','D_62','B_16','B_17','D_77','B_19','B_20','D_69','B_22','D_70','D_72','D_74','R_7','B_25','B_26','D_78','D_79','D_80','B_27','D_81','R_12','D_82','D_105','S_27','D_83','R_14','D_84','D_86','R_20','B_33','D_89','D_91','S_22','S_23','S_24','S_25','S_26','D_102','D_103','D_104','D_107','B_37','R_27','D_109','D_112','B_40','D_113','D_115','D_118','D_119','D_121','D_122','D_123','D_124','D_125','D_128','D_129','B_41','D_130','D_131','D_133','D_139','D_140','D_141','D_143','D_144','D_145'])\n\nfor column in selected_column:\n    test_dataset[column] = test_dataset[column].fillna(test_dataset[column].median())\nselected_column2 = np.array(['D_68','B_30','B_38','D_114','D_116','D_117','D_120','D_126'])\n\nfor column2 in selected_column2:\n    test_dataset[column2] =  test_dataset[column2].fillna(test_dataset[column2].mode()[0])","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:39.040564Z","iopub.execute_input":"2022-12-12T17:34:39.040982Z","iopub.status.idle":"2022-12-12T17:34:41.229239Z","shell.execute_reply.started":"2022-12-12T17:34:39.040942Z","shell.execute_reply":"2022-12-12T17:34:41.228240Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(test_dataset.isnull().sum().to_string())","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:41.234960Z","iopub.execute_input":"2022-12-12T17:34:41.235276Z","iopub.status.idle":"2022-12-12T17:34:41.712467Z","shell.execute_reply.started":"2022-12-12T17:34:41.235248Z","shell.execute_reply":"2022-12-12T17:34:41.711333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:41.714064Z","iopub.execute_input":"2022-12-12T17:34:41.714457Z","iopub.status.idle":"2022-12-12T17:34:41.723333Z","shell.execute_reply.started":"2022-12-12T17:34:41.714420Z","shell.execute_reply":"2022-12-12T17:34:41.722092Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dataset.head()","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:41.724819Z","iopub.execute_input":"2022-12-12T17:34:41.725518Z","iopub.status.idle":"2022-12-12T17:34:41.752677Z","shell.execute_reply.started":"2022-12-12T17:34:41.725480Z","shell.execute_reply":"2022-12-12T17:34:41.751604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import OrdinalEncoder\n\nenc = OrdinalEncoder()\ncategorical_cols.remove('D_66')\n\ntrain_dataset[categorical_cols] = enc.fit_transform(train_dataset[categorical_cols])\ntest_dataset[categorical_cols] = enc.transform(test_dataset[categorical_cols])","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:41.754152Z","iopub.execute_input":"2022-12-12T17:34:41.754498Z","iopub.status.idle":"2022-12-12T17:34:43.517671Z","shell.execute_reply.started":"2022-12-12T17:34:41.754465Z","shell.execute_reply":"2022-12-12T17:34:43.516673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset_without_target = train_dataset.drop([\"target\"],axis=1)\n\ncor_matrix = train_dataset_without_target.corr()\ncol_core = set()\n\nfor i in range(len(cor_matrix.columns)):\n    for j in range(i):\n        if(cor_matrix.iloc[i, j] > 0.9):\n            col_name = cor_matrix.columns[i]\n            col_core.add(col_name)\ncol_core","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:34:43.519171Z","iopub.execute_input":"2022-12-12T17:34:43.519538Z","iopub.status.idle":"2022-12-12T17:35:14.989229Z","shell.execute_reply.started":"2022-12-12T17:34:43.519499Z","shell.execute_reply":"2022-12-12T17:35:14.988091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset = train_dataset.drop(col_core, axis=1)\ntest_dataset = test_dataset.drop(col_core, axis=1)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:35:14.990552Z","iopub.execute_input":"2022-12-12T17:35:14.991198Z","iopub.status.idle":"2022-12-12T17:35:15.734581Z","shell.execute_reply.started":"2022-12-12T17:35:14.991142Z","shell.execute_reply":"2022-12-12T17:35:15.733528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dataset.shape","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:35:15.736008Z","iopub.execute_input":"2022-12-12T17:35:15.736415Z","iopub.status.idle":"2022-12-12T17:35:15.743379Z","shell.execute_reply.started":"2022-12-12T17:35:15.736375Z","shell.execute_reply":"2022-12-12T17:35:15.742373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_columns = [col for col in train_dataset.columns if col not in [\"target\"]]\n\nX = train_dataset[num_columns]\ny = train_dataset['target']\n\nprint(f\"X shape is = {X.shape}\" )\nprint(f\"Y shape is = {y.shape}\" )","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:35:15.744737Z","iopub.execute_input":"2022-12-12T17:35:15.745667Z","iopub.status.idle":"2022-12-12T17:35:15.983760Z","shell.execute_reply.started":"2022-12-12T17:35:15.745630Z","shell.execute_reply":"2022-12-12T17:35:15.982525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nfrom sklearn.metrics import accuracy_score\n\nx_train,x_test,y_train,y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)\n\nprint(f\"X_train shape is = {x_train.shape}\" )\nprint(f\"Y_train shape is = {y_train.shape}\" )\nprint(f\"X_test shape is = {x_test.shape}\" )\nprint(f\"Y_test shape is = {y_test.shape}\" )","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:57:01.405283Z","iopub.execute_input":"2022-12-12T17:57:01.405630Z","iopub.status.idle":"2022-12-12T17:57:02.799742Z","shell.execute_reply.started":"2022-12-12T17:57:01.405598Z","shell.execute_reply":"2022-12-12T17:57:02.798712Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from xgboost import XGBClassifier\nmodel1 = XGBClassifier(\n    learning_rate=0.1,\n    n_estimators=30,\n    objective=\"binary:logistic\",\n    nthread=3,\n    tree_method=\"gpu_hist\"  # this enables GPU.\n)\n","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:51:33.212330Z","iopub.execute_input":"2022-12-12T17:51:33.212715Z","iopub.status.idle":"2022-12-12T17:51:33.218883Z","shell.execute_reply.started":"2022-12-12T17:51:33.212682Z","shell.execute_reply":"2022-12-12T17:51:33.217373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model1.fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:51:39.214131Z","iopub.execute_input":"2022-12-12T17:51:39.214614Z","iopub.status.idle":"2022-12-12T17:51:42.642449Z","shell.execute_reply.started":"2022-12-12T17:51:39.214575Z","shell.execute_reply":"2022-12-12T17:51:42.639572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = model1.predict(test_dataset[num_columns])\npredictions","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:51:47.501053Z","iopub.execute_input":"2022-12-12T17:51:47.502080Z","iopub.status.idle":"2022-12-12T17:51:50.774165Z","shell.execute_reply.started":"2022-12-12T17:51:47.502039Z","shell.execute_reply":"2022-12-12T17:51:50.773166Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_dataset = pd.read_csv('/kaggle/input/amex-default-prediction/sample_submission.csv')\noutput = pd.DataFrame({'customer_ID': sample_dataset.customer_ID, 'prediction': predictions})\noutput.to_csv('submission2.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2022-12-12T17:51:51.747025Z","iopub.execute_input":"2022-12-12T17:51:51.747700Z","iopub.status.idle":"2022-12-12T17:51:54.413990Z","shell.execute_reply.started":"2022-12-12T17:51:51.747664Z","shell.execute_reply":"2022-12-12T17:51:54.412941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}