{"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":"# !kaggle competitions download -c tabular-playground-series-aug-2022","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:47.933251Z","iopub.execute_input":"2022-08-08T19:16:47.934802Z","iopub.status.idle":"2022-08-08T19:16:47.963263Z","shell.execute_reply.started":"2022-08-08T19:16:47.934599Z","shell.execute_reply":"2022-08-08T19:16:47.962003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# from zipfile import ZipFile","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:47.968607Z","iopub.execute_input":"2022-08-08T19:16:47.969091Z","iopub.status.idle":"2022-08-08T19:16:47.975869Z","shell.execute_reply.started":"2022-08-08T19:16:47.969050Z","shell.execute_reply":"2022-08-08T19:16:47.974356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# with ZipFile('./tabular-playground-series-aug-2022.zip', 'r') as zipObj:\n#     zipObj.extractall()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:47.978037Z","iopub.execute_input":"2022-08-08T19:16:47.978672Z","iopub.status.idle":"2022-08-08T19:16:47.988645Z","shell.execute_reply.started":"2022-08-08T19:16:47.978626Z","shell.execute_reply":"2022-08-08T19:16:47.987205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:47.992159Z","iopub.execute_input":"2022-08-08T19:16:47.993004Z","iopub.status.idle":"2022-08-08T19:16:49.424630Z","shell.execute_reply.started":"2022-08-08T19:16:47.992945Z","shell.execute_reply":"2022-08-08T19:16:49.422933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_theme()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:49.426478Z","iopub.execute_input":"2022-08-08T19:16:49.426985Z","iopub.status.idle":"2022-08-08T19:16:49.436925Z","shell.execute_reply.started":"2022-08-08T19:16:49.426939Z","shell.execute_reply":"2022-08-08T19:16:49.435357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('../input/tabular-playground-series-aug-2022/train.csv')\ntrain_df.head()","metadata":{"tags":[],"execution":{"iopub.status.busy":"2022-08-08T19:16:49.439467Z","iopub.execute_input":"2022-08-08T19:16:49.440487Z","iopub.status.idle":"2022-08-08T19:16:49.730899Z","shell.execute_reply.started":"2022-08-08T19:16:49.440413Z","shell.execute_reply":"2022-08-08T19:16:49.729533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EDA","metadata":{}},{"cell_type":"code","source":"train_df.info()","metadata":{"scrolled":true,"tags":[],"execution":{"iopub.status.busy":"2022-08-08T19:16:49.734407Z","iopub.execute_input":"2022-08-08T19:16:49.735231Z","iopub.status.idle":"2022-08-08T19:16:49.771989Z","shell.execute_reply.started":"2022-08-08T19:16:49.735164Z","shell.execute_reply":"2022-08-08T19:16:49.770145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.describe(include=np.number)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:49.774367Z","iopub.execute_input":"2022-08-08T19:16:49.775359Z","iopub.status.idle":"2022-08-08T19:16:49.906395Z","shell.execute_reply.started":"2022-08-08T19:16:49.775308Z","shell.execute_reply":"2022-08-08T19:16:49.905138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.describe(include=object)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:49.908285Z","iopub.execute_input":"2022-08-08T19:16:49.908700Z","iopub.status.idle":"2022-08-08T19:16:49.940827Z","shell.execute_reply.started":"2022-08-08T19:16:49.908664Z","shell.execute_reply":"2022-08-08T19:16:49.939544Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.isna().sum()","metadata":{"scrolled":true,"tags":[],"execution":{"iopub.status.busy":"2022-08-08T19:16:49.942978Z","iopub.execute_input":"2022-08-08T19:16:49.943515Z","iopub.status.idle":"2022-08-08T19:16:49.962354Z","shell.execute_reply.started":"2022-08-08T19:16:49.943464Z","shell.execute_reply":"2022-08-08T19:16:49.960954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:49.964403Z","iopub.execute_input":"2022-08-08T19:16:49.965296Z","iopub.status.idle":"2022-08-08T19:16:49.973709Z","shell.execute_reply.started":"2022-08-08T19:16:49.965243Z","shell.execute_reply":"2022-08-08T19:16:49.972373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_csv('../input/tabular-playground-series-aug-2022/test.csv')\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:49.975590Z","iopub.execute_input":"2022-08-08T19:16:49.977031Z","iopub.status.idle":"2022-08-08T19:16:50.164229Z","shell.execute_reply.started":"2022-08-08T19:16:49.976977Z","shell.execute_reply":"2022-08-08T19:16:50.162401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_id = test_df['id']","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.166063Z","iopub.execute_input":"2022-08-08T19:16:50.166503Z","iopub.status.idle":"2022-08-08T19:16:50.175025Z","shell.execute_reply.started":"2022-08-08T19:16:50.166461Z","shell.execute_reply":"2022-08-08T19:16:50.172879Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.info()","metadata":{"scrolled":true,"tags":[],"execution":{"iopub.status.busy":"2022-08-08T19:16:50.177133Z","iopub.execute_input":"2022-08-08T19:16:50.178005Z","iopub.status.idle":"2022-08-08T19:16:50.214992Z","shell.execute_reply.started":"2022-08-08T19:16:50.177951Z","shell.execute_reply":"2022-08-08T19:16:50.213941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.describe(include=np.number)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.221999Z","iopub.execute_input":"2022-08-08T19:16:50.224646Z","iopub.status.idle":"2022-08-08T19:16:50.357329Z","shell.execute_reply.started":"2022-08-08T19:16:50.224592Z","shell.execute_reply":"2022-08-08T19:16:50.355894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.describe(include=object)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.359237Z","iopub.execute_input":"2022-08-08T19:16:50.359970Z","iopub.status.idle":"2022-08-08T19:16:50.388270Z","shell.execute_reply.started":"2022-08-08T19:16:50.359922Z","shell.execute_reply":"2022-08-08T19:16:50.386921Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.390174Z","iopub.execute_input":"2022-08-08T19:16:50.390778Z","iopub.status.idle":"2022-08-08T19:16:50.409043Z","shell.execute_reply.started":"2022-08-08T19:16:50.390726Z","shell.execute_reply":"2022-08-08T19:16:50.407651Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.411138Z","iopub.execute_input":"2022-08-08T19:16:50.411619Z","iopub.status.idle":"2022-08-08T19:16:50.420517Z","shell.execute_reply.started":"2022-08-08T19:16:50.411562Z","shell.execute_reply":"2022-08-08T19:16:50.419105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x='failure')","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.422464Z","iopub.execute_input":"2022-08-08T19:16:50.423495Z","iopub.status.idle":"2022-08-08T19:16:50.661917Z","shell.execute_reply.started":"2022-08-08T19:16:50.423420Z","shell.execute_reply":"2022-08-08T19:16:50.660793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x='product_code', hue='failure')","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:50.663525Z","iopub.execute_input":"2022-08-08T19:16:50.663993Z","iopub.status.idle":"2022-08-08T19:16:51.008001Z","shell.execute_reply.started":"2022-08-08T19:16:50.663953Z","shell.execute_reply":"2022-08-08T19:16:51.006698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x='attribute_0', hue='failure')","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:51.011548Z","iopub.execute_input":"2022-08-08T19:16:51.012725Z","iopub.status.idle":"2022-08-08T19:16:51.245879Z","shell.execute_reply.started":"2022-08-08T19:16:51.012678Z","shell.execute_reply":"2022-08-08T19:16:51.244499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data=train_df, x='attribute_1', hue='failure')","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:51.248161Z","iopub.execute_input":"2022-08-08T19:16:51.248620Z","iopub.status.idle":"2022-08-08T19:16:51.586699Z","shell.execute_reply.started":"2022-08-08T19:16:51.248583Z","shell.execute_reply":"2022-08-08T19:16:51.585106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data=train_df, x='loading')","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:51.588912Z","iopub.execute_input":"2022-08-08T19:16:51.589763Z","iopub.status.idle":"2022-08-08T19:16:52.127673Z","shell.execute_reply.started":"2022-08-08T19:16:51.589708Z","shell.execute_reply":"2022-08-08T19:16:52.125698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_feature_distribution(df, nrows=1, ncols=1):\n    fig, axes = plt.subplots(nrows, ncols, figsize=(20, 20))\n    fig.suptitle('Distribution of features')\n    fig.subplots_adjust(hspace=0.25, wspace=0.25)\n    cols = train_df.columns[4:-1]\n    k = 0\n    for i in range(nrows):\n        for j in range(ncols):\n            sns.histplot(ax=axes[i,j], data=train_df, x=cols[k], kde=True, hue='failure')\n            k += 1","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:52.129688Z","iopub.execute_input":"2022-08-08T19:16:52.130553Z","iopub.status.idle":"2022-08-08T19:16:52.142364Z","shell.execute_reply.started":"2022-08-08T19:16:52.130497Z","shell.execute_reply":"2022-08-08T19:16:52.140950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_feature_distribution(train_df, nrows=5, ncols=4)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:16:52.144219Z","iopub.execute_input":"2022-08-08T19:16:52.145205Z","iopub.status.idle":"2022-08-08T19:17:08.414369Z","shell.execute_reply.started":"2022-08-08T19:16:52.145137Z","shell.execute_reply":"2022-08-08T19:17:08.412631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.corr()['failure'].sort_values(ascending=False)","metadata":{"scrolled":true,"tags":[],"execution":{"iopub.status.busy":"2022-08-08T19:17:08.415840Z","iopub.execute_input":"2022-08-08T19:17:08.416283Z","iopub.status.idle":"2022-08-08T19:17:08.477295Z","shell.execute_reply.started":"2022-08-08T19:17:08.416248Z","shell.execute_reply":"2022-08-08T19:17:08.475790Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(train_df.corr())","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:08.479530Z","iopub.execute_input":"2022-08-08T19:17:08.480073Z","iopub.status.idle":"2022-08-08T19:17:09.099131Z","shell.execute_reply.started":"2022-08-08T19:17:08.480034Z","shell.execute_reply":"2022-08-08T19:17:09.097838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# EDA results\n- There are not high correlation between failure and other features\n- Most measurement distributions are similar to the normal distribution","metadata":{}},{"cell_type":"markdown","source":"# Data preprocessing","metadata":{}},{"cell_type":"code","source":"mean = {}\nfor col in train_df.columns:\n    if train_df[col].dtype == 'int64' or train_df[col].dtype == 'float64':\n        mean[col] = train_df[col].mean()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.101151Z","iopub.execute_input":"2022-08-08T19:17:09.101551Z","iopub.status.idle":"2022-08-08T19:17:09.115308Z","shell.execute_reply.started":"2022-08-08T19:17:09.101518Z","shell.execute_reply":"2022-08-08T19:17:09.113867Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def preprocess_data(df):\n    df.drop(columns=['product_code', 'id'], axis=1, inplace=True)\n    for col in df.columns:\n        if (df[col].dtype == 'int64' or df[col].dtype == 'float64') and df.isna().sum()[col] != 0:\n            df[col].fillna(mean[col], inplace=True)\n    df = pd.get_dummies(df)\n    return df","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.118148Z","iopub.execute_input":"2022-08-08T19:17:09.118897Z","iopub.status.idle":"2022-08-08T19:17:09.126898Z","shell.execute_reply.started":"2022-08-08T19:17:09.118847Z","shell.execute_reply":"2022-08-08T19:17:09.125901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = preprocess_data(train_df)\ntrain_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.127995Z","iopub.execute_input":"2022-08-08T19:17:09.128343Z","iopub.status.idle":"2022-08-08T19:17:09.312647Z","shell.execute_reply.started":"2022-08-08T19:17:09.128312Z","shell.execute_reply":"2022-08-08T19:17:09.311550Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df.isna().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.314989Z","iopub.execute_input":"2022-08-08T19:17:09.315536Z","iopub.status.idle":"2022-08-08T19:17:09.329598Z","shell.execute_reply.started":"2022-08-08T19:17:09.315484Z","shell.execute_reply":"2022-08-08T19:17:09.328167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = preprocess_data(test_df)\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.331905Z","iopub.execute_input":"2022-08-08T19:17:09.332657Z","iopub.status.idle":"2022-08-08T19:17:09.486404Z","shell.execute_reply.started":"2022-08-08T19:17:09.332604Z","shell.execute_reply":"2022-08-08T19:17:09.484978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.isna().sum().sum()","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.488789Z","iopub.execute_input":"2022-08-08T19:17:09.489315Z","iopub.status.idle":"2022-08-08T19:17:09.503380Z","shell.execute_reply.started":"2022-08-08T19:17:09.489263Z","shell.execute_reply":"2022-08-08T19:17:09.502012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model defining","metadata":{}},{"cell_type":"code","source":"X = train_df.drop(['failure'], axis=1)\nY = train_df['failure']","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.505524Z","iopub.execute_input":"2022-08-08T19:17:09.506047Z","iopub.status.idle":"2022-08-08T19:17:09.522910Z","shell.execute_reply.started":"2022-08-08T19:17:09.505998Z","shell.execute_reply":"2022-08-08T19:17:09.521189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape, Y.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.525175Z","iopub.execute_input":"2022-08-08T19:17:09.525633Z","iopub.status.idle":"2022-08-08T19:17:09.533577Z","shell.execute_reply.started":"2022-08-08T19:17:09.525593Z","shell.execute_reply":"2022-08-08T19:17:09.532261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test = test_df","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.535523Z","iopub.execute_input":"2022-08-08T19:17:09.536711Z","iopub.status.idle":"2022-08-08T19:17:09.545039Z","shell.execute_reply.started":"2022-08-08T19:17:09.536640Z","shell.execute_reply":"2022-08-08T19:17:09.543646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.547166Z","iopub.execute_input":"2022-08-08T19:17:09.547979Z","iopub.status.idle":"2022-08-08T19:17:09.561215Z","shell.execute_reply.started":"2022-08-08T19:17:09.547937Z","shell.execute_reply":"2022-08-08T19:17:09.559898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LogisticRegression\nfrom sklearn.ensemble import AdaBoostClassifier, GradientBoostingClassifier, RandomForestClassifier\nfrom sklearn.metrics import confusion_matrix, roc_auc_score, classification_report\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import MinMaxScaler, StandardScaler\nfrom xgboost import XGBClassifier, XGBRFClassifier","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:09.563369Z","iopub.execute_input":"2022-08-08T19:17:09.564170Z","iopub.status.idle":"2022-08-08T19:17:10.172146Z","shell.execute_reply.started":"2022-08-08T19:17:09.564114Z","shell.execute_reply":"2022-08-08T19:17:10.170548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# The best public score\nmodel_lr = make_pipeline(StandardScaler(), LogisticRegression(max_iter=10000))\nmodel_lr.fit(X, Y)\nprint(classification_report(Y, model_lr.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_lr.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:10.180563Z","iopub.execute_input":"2022-08-08T19:17:10.181034Z","iopub.status.idle":"2022-08-08T19:17:10.467669Z","shell.execute_reply.started":"2022-08-08T19:17:10.180997Z","shell.execute_reply":"2022-08-08T19:17:10.466336Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_abc = AdaBoostClassifier(n_estimators=300)\nmodel_abc.fit(X, Y)\nprint(classification_report(Y, model_abc.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_abc.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:10.469672Z","iopub.execute_input":"2022-08-08T19:17:10.470477Z","iopub.status.idle":"2022-08-08T19:17:33.611967Z","shell.execute_reply.started":"2022-08-08T19:17:10.470410Z","shell.execute_reply":"2022-08-08T19:17:33.610639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_gbc = GradientBoostingClassifier(n_estimators=300, max_depth=5)\nmodel_gbc.fit(X, Y)\nprint(classification_report(Y, model_gbc.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_gbc.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:17:33.613700Z","iopub.execute_input":"2022-08-08T19:17:33.614423Z","iopub.status.idle":"2022-08-08T19:18:48.129890Z","shell.execute_reply.started":"2022-08-08T19:17:33.614373Z","shell.execute_reply":"2022-08-08T19:18:48.128518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_rfc = RandomForestClassifier(n_estimators=300, max_depth=5)\nmodel_rfc.fit(X, Y)\nprint(classification_report(Y, model_rfc.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_rfc.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:18:48.131693Z","iopub.execute_input":"2022-08-08T19:18:48.132105Z","iopub.status.idle":"2022-08-08T19:19:02.046594Z","shell.execute_reply.started":"2022-08-08T19:18:48.132071Z","shell.execute_reply":"2022-08-08T19:19:02.045269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_xgbc = XGBClassifier(n_estimators=300, max_depth=5)\nmodel_xgbc.fit(X, Y)\nprint(classification_report(Y, model_xgbc.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_xgbc.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:19:02.048356Z","iopub.execute_input":"2022-08-08T19:19:02.048865Z","iopub.status.idle":"2022-08-08T19:19:12.235093Z","shell.execute_reply.started":"2022-08-08T19:19:02.048815Z","shell.execute_reply":"2022-08-08T19:19:12.233221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_xgbrfc = XGBRFClassifier(n_estimators=300, max_depth=5)\nmodel_xgbrfc.fit(X, Y)\nprint(classification_report(Y, model_xgbrfc.predict(X)))\nprint('AUC: ', roc_auc_score(Y, model_xgbrfc.predict_proba(X)[:,1]))","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:19:12.237463Z","iopub.execute_input":"2022-08-08T19:19:12.238291Z","iopub.status.idle":"2022-08-08T19:19:20.893365Z","shell.execute_reply.started":"2022-08-08T19:19:12.238232Z","shell.execute_reply":"2022-08-08T19:19:20.892290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_test = model_lr.predict_proba(X_test)[:,1]\nY_test","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:19:20.896115Z","iopub.execute_input":"2022-08-08T19:19:20.897091Z","iopub.status.idle":"2022-08-08T19:19:20.926734Z","shell.execute_reply.started":"2022-08-08T19:19:20.897044Z","shell.execute_reply":"2022-08-08T19:19:20.925476Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_test.shape","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:19:20.928342Z","iopub.execute_input":"2022-08-08T19:19:20.929205Z","iopub.status.idle":"2022-08-08T19:19:20.942746Z","shell.execute_reply.started":"2022-08-08T19:19:20.929155Z","shell.execute_reply":"2022-08-08T19:19:20.940980Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"solution = pd.DataFrame({\"id\": test_id, \"failure\": Y_test})\nsolution.to_csv(\"submission.csv\", sep=\",\", index=False)","metadata":{"execution":{"iopub.status.busy":"2022-08-08T19:19:20.946130Z","iopub.execute_input":"2022-08-08T19:19:20.947422Z","iopub.status.idle":"2022-08-08T19:19:21.063709Z","shell.execute_reply.started":"2022-08-08T19:19:20.947348Z","shell.execute_reply":"2022-08-08T19:19:21.062498Z"},"trusted":true},"execution_count":null,"outputs":[]}]}