{"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":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-04T13:20:46.753450Z","iopub.execute_input":"2023-01-04T13:20:46.753929Z","iopub.status.idle":"2023-01-04T13:20:46.789580Z","shell.execute_reply.started":"2023-01-04T13:20:46.753838Z","shell.execute_reply":"2023-01-04T13:20:46.788669Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nos.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\nimport os\n\n\nimport lightgbm\nfrom xgboost import XGBClassifier\n\nimport matplotlib.pyplot as plt\nimport seaborn as sbn\nimport numpy as np\nimport pandas as pd\nimport warnings\n\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.model_selection import cross_val_score\nfrom sklearn.metrics import confusion_matrix, classification_report, roc_curve, auc, RocCurveDisplay, accuracy_score\n\nimport shap\nimport itertools","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:20:53.718352Z","iopub.execute_input":"2023-01-04T13:20:53.718755Z","iopub.status.idle":"2023-01-04T13:20:58.941494Z","shell.execute_reply.started":"2023-01-04T13:20:53.718723Z","shell.execute_reply":"2023-01-04T13:20:58.940547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_parquet(\"/kaggle/input/amex-data-integer-dtypes-parquet-format/train.parquet\").groupby('customer_ID').tail(4)\ntest = pd.read_parquet(\"/kaggle/input/amex-data-integer-dtypes-parquet-format/test.parquet\").groupby('customer_ID').tail(4)\ntrain_labels = pd.read_csv(\"../input/amex-default-prediction/train_labels.csv\")\nsubmission = pd.read_csv(\"/kaggle/input/amex-default-prediction/sample_submission.csv\")\n","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:21:02.890934Z","iopub.execute_input":"2023-01-04T13:21:02.891843Z","iopub.status.idle":"2023-01-04T13:22:31.778138Z","shell.execute_reply.started":"2023-01-04T13:21:02.891790Z","shell.execute_reply":"2023-01-04T13:22:31.776769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:22:31.780363Z","iopub.execute_input":"2023-01-04T13:22:31.780804Z","iopub.status.idle":"2023-01-04T13:22:31.814876Z","shell.execute_reply.started":"2023-01-04T13:22:31.780757Z","shell.execute_reply":"2023-01-04T13:22:31.813647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Describe","metadata":{}},{"cell_type":"code","source":"train.shape, test.shape, train_labels.shape, submission.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.duplicated().sum()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in train.columns.values:\n  print(col,'-',train[col].isna().sum()/len(train[col]))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"non_numeric_cols = train.columns[train.dtypes == 'object'].values\nnon_numeric_cols","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"numeric_cols = train.columns[train.dtypes != 'object'].values\nnumeric_cols","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:40:27.969548Z","iopub.execute_input":"2023-01-04T13:40:27.969969Z","iopub.status.idle":"2023-01-04T13:40:27.978897Z","shell.execute_reply.started":"2023-01-04T13:40:27.969932Z","shell.execute_reply":"2023-01-04T13:40:27.977528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preprocessing","metadata":{}},{"cell_type":"code","source":"import matplotlib.style as style\nimport seaborn as sns\nstyle.use('seaborn-poster')\nsns.set_style('ticks')\nplt.subplots(figsize = (270,200))\n## Plotting heatmap. \n\n# Generate a mask for the upper triangle (taken from seaborn example gallery)\nmask = np.zeros_like(train.corr(), dtype=np.bool)\nmask[np.triu_indices_from(mask)] = True\n\n\nsns.heatmap(train.corr(), cmap=plt.get_cmap('Blues'), annot=True, mask=mask, center = 0, square=True, \n             );\n## Give title. \nplt.title(\"Heatmap of all the Features\", fontsize = 25);","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr_matrix = train.corr().abs()\n\n# Select upper triangle of correlation matrix\nupper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))\n\n# Find features with correlation greater than 0.95\nto_drop = [column for column in upper.columns if any(upper[column] >= 0.95)]\n\n# Drop features \n\nto_drop","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:33:04.665592Z","iopub.execute_input":"2023-01-04T13:33:04.665981Z","iopub.status.idle":"2023-01-04T13:35:51.282989Z","shell.execute_reply.started":"2023-01-04T13:33:04.665950Z","shell.execute_reply":"2023-01-04T13:35:51.281883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preprocessing Train","metadata":{}},{"cell_type":"code","source":"train['Date'] =  pd.to_datetime(train['S_2'], format=\"%Y/%m/%d\")\ntrain['weekday'] = train['Date'].dt.weekday\ntrain['day'] = train['Date'].dt.day\ntrain['month'] = train['Date'].dt.month\ntrain['year'] = train['Date'].dt.year","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:30:22.269939Z","iopub.execute_input":"2023-01-04T13:30:22.270728Z","iopub.status.idle":"2023-01-04T13:30:23.263388Z","shell.execute_reply.started":"2023-01-04T13:30:22.270671Z","shell.execute_reply":"2023-01-04T13:30:23.262089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train['S_2'] = pd.to_numeric(train['S_2'].str.replace('-',''))\ntrain['S_2']","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:30:23.264756Z","iopub.execute_input":"2023-01-04T13:30:23.265146Z","iopub.status.idle":"2023-01-04T13:30:25.377400Z","shell.execute_reply.started":"2023-01-04T13:30:23.265111Z","shell.execute_reply":"2023-01-04T13:30:25.376163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import MinMaxScaler,StandardScaler\n\na = StandardScaler()\nX = a.fit_transform(train['S_2'].to_numpy().reshape(-1,1))\ntrain['S_2'] = X\n","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:30:25.380589Z","iopub.execute_input":"2023-01-04T13:30:25.381796Z","iopub.status.idle":"2023-01-04T13:30:25.421641Z","shell.execute_reply.started":"2023-01-04T13:30:25.381735Z","shell.execute_reply":"2023-01-04T13:30:25.420242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy = train.groupby('customer_ID').tail(1)\ntrain_labels_copy = train_labels.groupby('customer_ID').tail(1)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:17:41.182713Z","iopub.execute_input":"2023-01-04T15:17:41.183226Z","iopub.status.idle":"2023-01-04T15:17:42.747039Z","shell.execute_reply.started":"2023-01-04T15:17:41.183165Z","shell.execute_reply":"2023-01-04T15:17:42.745580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy = train_copy.merge(train_labels_copy, how='inner', on=\"customer_ID\")","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:17:45.561212Z","iopub.execute_input":"2023-01-04T15:17:45.562026Z","iopub.status.idle":"2023-01-04T15:17:57.356983Z","shell.execute_reply.started":"2023-01-04T15:17:45.561988Z","shell.execute_reply":"2023-01-04T15:17:57.356066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy.shape, train.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:30:22.689559Z","iopub.execute_input":"2023-01-04T15:30:22.690526Z","iopub.status.idle":"2023-01-04T15:30:22.697083Z","shell.execute_reply.started":"2023-01-04T15:30:22.690482Z","shell.execute_reply":"2023-01-04T15:30:22.695962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy.drop(to_drop, axis=1, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:30:34.608941Z","iopub.execute_input":"2023-01-04T15:30:34.609957Z","iopub.status.idle":"2023-01-04T15:30:34.892979Z","shell.execute_reply.started":"2023-01-04T15:30:34.609914Z","shell.execute_reply":"2023-01-04T15:30:34.891618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy.shape, train.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:30:46.929704Z","iopub.execute_input":"2023-01-04T15:30:46.930810Z","iopub.status.idle":"2023-01-04T15:30:46.939164Z","shell.execute_reply.started":"2023-01-04T15:30:46.930753Z","shell.execute_reply":"2023-01-04T15:30:46.937550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#train_copy = train_copy.drop(['customer_ID'], axis=1)\ntrain_copy.shape, train.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T13:30:40.170138Z","iopub.execute_input":"2023-01-04T13:30:40.170646Z","iopub.status.idle":"2023-01-04T13:30:40.284279Z","shell.execute_reply.started":"2023-01-04T13:30:40.170590Z","shell.execute_reply":"2023-01-04T13:30:40.282852Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy = train_copy.drop(['Date'], axis=1)\ntrain_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:31:02.250637Z","iopub.execute_input":"2023-01-04T15:31:02.251242Z","iopub.status.idle":"2023-01-04T15:31:02.354418Z","shell.execute_reply.started":"2023-01-04T15:31:02.251208Z","shell.execute_reply":"2023-01-04T15:31:02.353182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"numeric_cols = train_copy.columns[train_copy.dtypes != 'object'].values\nnumeric_cols","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:32:35.849837Z","iopub.execute_input":"2023-01-04T15:32:35.850266Z","iopub.status.idle":"2023-01-04T15:32:35.857902Z","shell.execute_reply.started":"2023-01-04T15:32:35.850233Z","shell.execute_reply":"2023-01-04T15:32:35.856994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"skew_col = []\nfor i in numeric_cols:\n    if (train_copy[i].skew() > 100):\n        print(i,train_copy[i].skew())\n        skew_col.append(i)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:33:30.768561Z","iopub.execute_input":"2023-01-04T15:33:30.769059Z","iopub.status.idle":"2023-01-04T15:33:31.629172Z","shell.execute_reply.started":"2023-01-04T15:33:30.769019Z","shell.execute_reply":"2023-01-04T15:33:31.627820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IDs = []\nfor i in skew_col:\n    IDs.append(train_copy[abs(train_copy[i]) > (3*train_copy[i].std())][['customer_ID']])\n    \nlen(IDs)\n#plt.bar( train_copy['S_23'].value_counts().index, train_copy['S_23'].value_counts().values, color ='maroon')","metadata":{"execution":{"iopub.status.busy":"2023-01-04T15:39:02.967851Z","iopub.execute_input":"2023-01-04T15:39:02.968603Z","iopub.status.idle":"2023-01-04T15:39:03.073254Z","shell.execute_reply.started":"2023-01-04T15:39:02.968564Z","shell.execute_reply":"2023-01-04T15:39:03.072078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_copy_1 = train_copy\nfor i in skew_col:\n    train_copy_1 = train_copy_1[abs(train_copy_1[i]) < (3*train_copy_1[i].std())]\ntrain_copy_1.shape   ","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:11:06.976413Z","iopub.execute_input":"2023-01-04T16:11:06.976841Z","iopub.status.idle":"2023-01-04T16:11:11.048444Z","shell.execute_reply.started":"2023-01-04T16:11:06.976806Z","shell.execute_reply":"2023-01-04T16:11:11.047537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Preprocessing Test","metadata":{}},{"cell_type":"code","source":"test['Date'] =  pd.to_datetime(test['S_2'], format=\"%Y/%m/%d\")\ntest['weekday'] = test['Date'].dt.weekday\ntest['day'] = test['Date'].dt.day\ntest['month'] = test['Date'].dt.month\ntest['year'] = test['Date'].dt.year","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:11:52.990367Z","iopub.execute_input":"2023-01-04T16:11:52.991587Z","iopub.status.idle":"2023-01-04T16:11:55.026154Z","shell.execute_reply.started":"2023-01-04T16:11:52.991539Z","shell.execute_reply":"2023-01-04T16:11:55.025085Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test['S_2'] = pd.to_numeric(test['S_2'].str.replace('-',''))\ntest['S_2']","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:11:57.089426Z","iopub.execute_input":"2023-01-04T16:11:57.089812Z","iopub.status.idle":"2023-01-04T16:12:02.045612Z","shell.execute_reply.started":"2023-01-04T16:11:57.089773Z","shell.execute_reply":"2023-01-04T16:12:02.044649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import MinMaxScaler, StandardScaler\n\na = StandardScaler()\nX = a.fit_transform(test['S_2'].to_numpy().reshape(-1,1))\ntest['S_2'] = X\ntest['S_2']","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:12:07.970375Z","iopub.execute_input":"2023-01-04T16:12:07.970800Z","iopub.status.idle":"2023-01-04T16:12:08.034765Z","shell.execute_reply.started":"2023-01-04T16:12:07.970764Z","shell.execute_reply":"2023-01-04T16:12:08.033532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy = test.groupby('customer_ID').tail(1)\ntest_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:12:24.712118Z","iopub.execute_input":"2023-01-04T16:12:24.712616Z","iopub.status.idle":"2023-01-04T16:12:27.082938Z","shell.execute_reply.started":"2023-01-04T16:12:24.712570Z","shell.execute_reply":"2023-01-04T16:12:27.081597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy.drop(to_drop, axis=1, inplace=True)\ntest_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:12:32.171500Z","iopub.execute_input":"2023-01-04T16:12:32.172374Z","iopub.status.idle":"2023-01-04T16:12:32.393325Z","shell.execute_reply.started":"2023-01-04T16:12:32.172334Z","shell.execute_reply":"2023-01-04T16:12:32.392065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T02:36:32.529861Z","iopub.execute_input":"2023-01-04T02:36:32.530577Z","iopub.status.idle":"2023-01-04T02:36:32.537006Z","shell.execute_reply.started":"2023-01-04T02:36:32.530535Z","shell.execute_reply":"2023-01-04T02:36:32.536001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy = test_copy.drop(['Date'], axis=1)\ntest_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:02.372336Z","iopub.execute_input":"2023-01-04T16:14:02.372740Z","iopub.status.idle":"2023-01-04T16:14:02.610479Z","shell.execute_reply.started":"2023-01-04T16:14:02.372709Z","shell.execute_reply":"2023-01-04T16:14:02.609273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy = test_copy.drop(['customer_ID'], axis=1)\ntest_copy.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Training","metadata":{}},{"cell_type":"code","source":"Features=train_copy_1.loc[:, test_copy.columns]","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:29.170576Z","iopub.execute_input":"2023-01-04T16:14:29.171363Z","iopub.status.idle":"2023-01-04T16:14:29.275610Z","shell.execute_reply.started":"2023-01-04T16:14:29.171299Z","shell.execute_reply":"2023-01-04T16:14:29.274387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Features.shape, test_copy.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:31.690415Z","iopub.execute_input":"2023-01-04T16:14:31.691100Z","iopub.status.idle":"2023-01-04T16:14:31.699599Z","shell.execute_reply.started":"2023-01-04T16:14:31.691062Z","shell.execute_reply":"2023-01-04T16:14:31.698455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.compose import ColumnTransformer\n\nfrom sklearn.pipeline import Pipeline\n\nfrom sklearn.preprocessing import OneHotEncoder, LabelEncoder, OrdinalEncoder","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:38.690222Z","iopub.execute_input":"2023-01-04T16:14:38.690650Z","iopub.status.idle":"2023-01-04T16:14:38.711596Z","shell.execute_reply.started":"2023-01-04T16:14:38.690615Z","shell.execute_reply":"2023-01-04T16:14:38.709992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"numeric_cols = Features.columns[Features.dtypes != \"object\"].values\nnon_numeric_cols = Features.columns[Features.dtypes == 'object'].values\n\nnumeric_preprocessing_steps = Pipeline(steps=[\n    ('standard_scaler', StandardScaler()),\n    ('imputer', SimpleImputer(strategy='mean'))\n    ])\n\nnon_numeric_preprocessing_steps = Pipeline(steps=[\n    ('imputer', SimpleImputer(strategy='constant', fill_value='missing')),\n    #('onehot', OrdinalEncoder())\n    ('onehot', OneHotEncoder(handle_unknown='ignore'))\n    ])\n\n\npreprocessor = ColumnTransformer(\n    transformers = [\n        (\"numeric\", numeric_preprocessing_steps, numeric_cols),\n        #(\"non_numeric\",non_numeric_preprocessing_steps,non_numeric_cols)\n    ],\n    remainder = \"drop\"\n)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:48.014245Z","iopub.execute_input":"2023-01-04T16:14:48.015497Z","iopub.status.idle":"2023-01-04T16:14:48.026469Z","shell.execute_reply.started":"2023-01-04T16:14:48.015445Z","shell.execute_reply":"2023-01-04T16:14:48.025281Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"XGB = XGBClassifier(n_estimators=300, max_depth=6, learning_rate=0.1)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:14:54.788302Z","iopub.execute_input":"2023-01-04T16:14:54.788714Z","iopub.status.idle":"2023-01-04T16:14:54.794728Z","shell.execute_reply.started":"2023-01-04T16:14:54.788682Z","shell.execute_reply":"2023-01-04T16:14:54.793411Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_pipeline = Pipeline([\n    (\"preprocessor\", preprocessor),\n    (\"estimators\", XGB),\n])","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:15:00.486145Z","iopub.execute_input":"2023-01-04T16:15:00.486607Z","iopub.status.idle":"2023-01-04T16:15:00.492165Z","shell.execute_reply.started":"2023-01-04T16:15:00.486570Z","shell.execute_reply":"2023-01-04T16:15:00.490694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"full_pipeline.fit(Features,train_copy_1['target'])","metadata":{"execution":{"iopub.status.busy":"2023-01-04T16:15:25.328566Z","iopub.execute_input":"2023-01-04T16:15:25.329483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n#import numpy as np\n#np.mean(cross_val_score(full_pipeline, Features, train['target'], scoring='accuracy', cv=5))\n\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#full_pipeline[1].save_model('/kaggle/input')\n#full_pipeline[1].load_model('/kaggle/input')","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#test = pd.read_parquet(\"/kaggle/input/amex-data-integer-dtypes-parquet-format/test.parquet\").groupby('customer_ID').tail(4)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_copy.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_probas = full_pipeline.predict_proba(test_copy)","metadata":{"execution":{"iopub.status.busy":"2023-01-04T03:07:09.429580Z","iopub.execute_input":"2023-01-04T03:07:09.430524Z","iopub.status.idle":"2023-01-04T03:07:20.402242Z","shell.execute_reply.started":"2023-01-04T03:07:09.430471Z","shell.execute_reply":"2023-01-04T03:07:20.401182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tests = test.groupby('customer_ID').tail(1)\ntests.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T03:07:20.408565Z","iopub.execute_input":"2023-01-04T03:07:20.411654Z","iopub.status.idle":"2023-01-04T03:07:22.866758Z","shell.execute_reply.started":"2023-01-04T03:07:20.411603Z","shell.execute_reply":"2023-01-04T03:07:22.865181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tests['prediction']=test_probas[:,1]\ntests['prediction']","metadata":{"execution":{"iopub.status.busy":"2023-01-04T03:07:22.884745Z","iopub.execute_input":"2023-01-04T03:07:22.885111Z","iopub.status.idle":"2023-01-04T03:07:22.898965Z","shell.execute_reply.started":"2023-01-04T03:07:22.885079Z","shell.execute_reply":"2023-01-04T03:07:22.897726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub = tests[['customer_ID','prediction']]\nsub.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-04T03:07:22.900874Z","iopub.execute_input":"2023-01-04T03:07:22.901693Z","iopub.status.idle":"2023-01-04T03:07:23.214800Z","shell.execute_reply.started":"2023-01-04T03:07:22.901655Z","shell.execute_reply":"2023-01-04T03:07:23.213683Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.to_csv(\"my_submission.csv\", index=False)\nsub.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-04T03:12:42.087977Z","iopub.execute_input":"2023-01-04T03:12:42.088555Z","iopub.status.idle":"2023-01-04T03:12:45.102473Z","shell.execute_reply.started":"2023-01-04T03:12:42.088514Z","shell.execute_reply":"2023-01-04T03:12:45.101425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.duplicated().sum()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}