{"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":"markdown","source":"# Prediction of the Churn of clients","metadata":{}},{"cell_type":"markdown","source":"#### 1. Import all necessary libraries \n\n","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns \nfrom matplotlib import pyplot as plt\n\nfrom sklearn.linear_model import LogisticRegression, LogisticRegressionCV\nfrom sklearn.preprocessing import StandardScaler, OneHotEncoder, MinMaxScaler\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.model_selection import train_test_split, GridSearchCV\nfrom sklearn.metrics import roc_curve, roc_auc_score\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.ensemble import RandomForestClassifier\n\nfrom catboost import CatBoostClassifier\n\nimport optuna","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.418498Z","iopub.execute_input":"2022-08-13T17:38:27.419024Z","iopub.status.idle":"2022-08-13T17:38:27.427731Z","shell.execute_reply.started":"2022-08-13T17:38:27.418984Z","shell.execute_reply":"2022-08-13T17:38:27.426330Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 2. Read and prepare csv ","metadata":{}},{"cell_type":"code","source":"#read data\ntrain_ = pd.read_csv(\"../input/advanced-dls-spring-2021/train.csv\")\ntest_ = pd.read_csv(\"../input/advanced-dls-spring-2021/test.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.429783Z","iopub.execute_input":"2022-08-13T17:38:27.430600Z","iopub.status.idle":"2022-08-13T17:38:27.474082Z","shell.execute_reply.started":"2022-08-13T17:38:27.430547Z","shell.execute_reply":"2022-08-13T17:38:27.472738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#show how does data look like\ntrain_.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.476435Z","iopub.execute_input":"2022-08-13T17:38:27.476869Z","iopub.status.idle":"2022-08-13T17:38:27.508953Z","shell.execute_reply.started":"2022-08-13T17:38:27.476807Z","shell.execute_reply":"2022-08-13T17:38:27.507592Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Numerical columns \nnum_cols = [\n    'ClientPeriod',\n    'MonthlySpending',\n    'TotalSpent'\n]\n\n#Categorial columns\ncat_cols = [\n    'Sex',\n    'IsSeniorCitizen',\n    'HasPartner',\n    'HasChild',\n    'HasPhoneService',\n    'HasMultiplePhoneNumbers',\n    'HasInternetService',\n    'HasOnlineSecurityService',\n    'HasOnlineBackup',\n    'HasDeviceProtection',\n    'HasTechSupportAccess',\n    'HasOnlineTV',\n    'HasMovieSubscription',\n    'HasContractPhone',\n    'IsBillingPaperless',\n    'PaymentMethod'\n]\n\nfeature_cols = num_cols + cat_cols\ntarget_col = 'Churn'","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.510681Z","iopub.execute_input":"2022-08-13T17:38:27.511540Z","iopub.status.idle":"2022-08-13T17:38:27.521873Z","shell.execute_reply.started":"2022-08-13T17:38:27.511490Z","shell.execute_reply":"2022-08-13T17:38:27.520813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_.info()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.525008Z","iopub.execute_input":"2022-08-13T17:38:27.526408Z","iopub.status.idle":"2022-08-13T17:38:27.556902Z","shell.execute_reply.started":"2022-08-13T17:38:27.526219Z","shell.execute_reply":"2022-08-13T17:38:27.555535Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_[num_cols].describe()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.559152Z","iopub.execute_input":"2022-08-13T17:38:27.559700Z","iopub.status.idle":"2022-08-13T17:38:27.583950Z","shell.execute_reply.started":"2022-08-13T17:38:27.559664Z","shell.execute_reply":"2022-08-13T17:38:27.582540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#as i see, TotalSpent isnt numeric, so i will need to convert it\ndef Preprocess(data_):\n    data_[\"TotalSpent\"] = pd.to_numeric(data_[\"TotalSpent\"], errors='coerce').fillna(0)\n    return data_\nPreprocess(train_)\nPreprocess(test_)\nNone","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.585663Z","iopub.execute_input":"2022-08-13T17:38:27.586080Z","iopub.status.idle":"2022-08-13T17:38:27.601298Z","shell.execute_reply.started":"2022-08-13T17:38:27.586043Z","shell.execute_reply":"2022-08-13T17:38:27.599685Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visualization of Sex feature (in dependence with Churn)\nax = sns.countplot(x = \"Sex\", data = train_, hue = \"Churn\")\nfor p in ax.patches:\n    ax.annotate(\"{:.1f}\".format(p.get_height()), (p.get_x() + 0.1, p.get_height() + 15))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.603247Z","iopub.execute_input":"2022-08-13T17:38:27.604911Z","iopub.status.idle":"2022-08-13T17:38:27.857839Z","shell.execute_reply.started":"2022-08-13T17:38:27.604850Z","shell.execute_reply":"2022-08-13T17:38:27.856322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visualization of HasInternetService feature (in dependence with Churn)\nax = sns.countplot(x = \"HasInternetService\", data = train_, hue = \"Churn\")\nfor p in ax.patches:\n    ax.annotate(\"{:.1f}\".format(p.get_height()), (p.get_x() + 0.05, p.get_height() + 15))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:27.859423Z","iopub.execute_input":"2022-08-13T17:38:27.860502Z","iopub.status.idle":"2022-08-13T17:38:28.143381Z","shell.execute_reply.started":"2022-08-13T17:38:27.860454Z","shell.execute_reply":"2022-08-13T17:38:28.141739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"At least there's some correlation between *Fiber optics* and desire to quit company's service","metadata":{}},{"cell_type":"code","source":"#vizualization of HasMultiplePhoneNumbers (in dependence with Churn)\nax = sns.countplot(x = \"HasMultiplePhoneNumbers\", data = train_, hue = \"Churn\")\nfor p in ax.patches:\n    ax.annotate(\"{:.1f}\".format(p.get_height()), (p.get_x() + 0.05, p.get_height() + 15))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:28.145955Z","iopub.execute_input":"2022-08-13T17:38:28.146468Z","iopub.status.idle":"2022-08-13T17:38:28.429907Z","shell.execute_reply.started":"2022-08-13T17:38:28.146414Z","shell.execute_reply":"2022-08-13T17:38:28.428391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#vizualization of HasMovieSubscription (in dependence with Churn)\nax = sns.countplot(x = \"HasMovieSubscription\", data = train_, hue = \"Churn\")\nfor p in ax.patches:\n    ax.annotate(\"{:.1f}\".format(p.get_height()), (p.get_x() + 0.05, p.get_height() + 15))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:28.435917Z","iopub.execute_input":"2022-08-13T17:38:28.437434Z","iopub.status.idle":"2022-08-13T17:38:28.720900Z","shell.execute_reply.started":"2022-08-13T17:38:28.437358Z","shell.execute_reply":"2022-08-13T17:38:28.719109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# The distribution of numerical features\ntrain_[num_cols].hist(bins = 50, figsize = (20, 17))\nNone","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:28.723094Z","iopub.execute_input":"2022-08-13T17:38:28.724991Z","iopub.status.idle":"2022-08-13T17:38:29.648135Z","shell.execute_reply.started":"2022-08-13T17:38:28.724938Z","shell.execute_reply":"2022-08-13T17:38:29.646539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visualization of categorical data \n#colors = ['wheat', 'cyan', 'springgreen', 'lightpink']\nplt.figure(figsize = (30, 30))\nfor id, col in enumerate(cat_cols):\n    ax = plt.subplot(4, 4, id + 1)\n    plot_data = train_[col].value_counts().to_numpy()\n    plot_labels = (train_[col].value_counts().index).astype(str) + ': ' + plot_data.astype(str)\n    plt.pie(plot_data, labels = plot_labels, shadow = True)\n    plt.title(col)\n    plt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:29.650281Z","iopub.execute_input":"2022-08-13T17:38:29.650853Z","iopub.status.idle":"2022-08-13T17:38:34.023558Z","shell.execute_reply.started":"2022-08-13T17:38:29.650797Z","shell.execute_reply":"2022-08-13T17:38:34.022217Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_.Churn.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:34.025267Z","iopub.execute_input":"2022-08-13T17:38:34.025693Z","iopub.status.idle":"2022-08-13T17:38:34.036195Z","shell.execute_reply.started":"2022-08-13T17:38:34.025658Z","shell.execute_reply":"2022-08-13T17:38:34.034754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Data is really imbalanced ;(","metadata":{}},{"cell_type":"markdown","source":"#### 3. Learning \nIn Learning i will use three different approachs:\n1. Gradient Boosting via `CatBoost` library\n2. Logistic Regression via `Sklearn` library\n3. Random Forest via `Sklearn` library\n\nAfter i will estimate their ROC-AUC and find best algorithm. Or implement stacking","metadata":{}},{"cell_type":"code","source":"X, y = train_[feature_cols], train_[target_col]\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:34.038232Z","iopub.execute_input":"2022-08-13T17:38:34.038723Z","iopub.status.idle":"2022-08-13T17:38:34.056308Z","shell.execute_reply.started":"2022-08-13T17:38:34.038676Z","shell.execute_reply":"2022-08-13T17:38:34.054726Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 3.1 Catboost:","metadata":{}},{"cell_type":"code","source":"classifier = CatBoostClassifier(verbose = False, cat_features = cat_cols)\nclassifier.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:34.058559Z","iopub.execute_input":"2022-08-13T17:38:34.059073Z","iopub.status.idle":"2022-08-13T17:38:46.544601Z","shell.execute_reply.started":"2022-08-13T17:38:34.059030Z","shell.execute_reply":"2022-08-13T17:38:46.543045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = classifier.predict_proba(X_test)\nprint(prediction)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:46.546029Z","iopub.execute_input":"2022-08-13T17:38:46.546492Z","iopub.status.idle":"2022-08-13T17:38:46.565490Z","shell.execute_reply.started":"2022-08-13T17:38:46.546455Z","shell.execute_reply":"2022-08-13T17:38:46.563882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Best ROC-AUC is {0}\".format(roc_auc_score(y_test, prediction[:, 1])))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:46.567926Z","iopub.execute_input":"2022-08-13T17:38:46.568492Z","iopub.status.idle":"2022-08-13T17:38:46.579961Z","shell.execute_reply.started":"2022-08-13T17:38:46.568441Z","shell.execute_reply":"2022-08-13T17:38:46.578269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Obviously that's less than we would expect from `CatBoost`. Probably the reason is refitting ","metadata":{}},{"cell_type":"code","source":"''' uncoment this section on your personal computer. Kaggle inst capable of processing such big amounts of computations in normal period of time \nparams = {\n    'num_trees' : [],\n    'lr' : [],\n    'score_test' : []\n}\n\nnum_trees = np.arange(50, 350, 50)\nlr = np.arange(0.01, 0.51, 0.01)\n\nfor trees in num_trees:\n    for rate in lr: \n        catboost_classifier = CatBoostClassifier(cat_features = cat_cols, \n                                                verbose = False, \n                                                n_estimators = trees, \n                                                learning_rate = rate)\n            \n        catboost_classifier.fit(X_train, y_train)\n        prediction = classifier.predict_proba(X_test)\n\n        params['num_trees'].append(trees)\n        params['lr'].append(rate)\n        params['score_test'].append(roc_auc_score(y_test, prediction[:, 1]))\n\ndisplay(pd.DataFrame(params).sort_values('score_test').head(10))\n'''","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:46.582608Z","iopub.execute_input":"2022-08-13T17:38:46.583406Z","iopub.status.idle":"2022-08-13T17:38:46.593356Z","shell.execute_reply.started":"2022-08-13T17:38:46.583357Z","shell.execute_reply":"2022-08-13T17:38:46.591759Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Still not the score that expected to get","metadata":{}},{"cell_type":"code","source":"catboost_estimator = CatBoostClassifier(learning_rate = 0.01, n_estimators = 200, cat_features = cat_cols, verbose = False)\ncatboost_estimator .fit(X_train, y_train)\nprediction = catboost_estimator.predict_proba(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:46.595304Z","iopub.execute_input":"2022-08-13T17:38:46.595713Z","iopub.status.idle":"2022-08-13T17:38:48.913870Z","shell.execute_reply.started":"2022-08-13T17:38:46.595679Z","shell.execute_reply":"2022-08-13T17:38:48.912424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fpr_catboost, tpr_catboost, thresholds  = roc_curve(y_test, prediction[:, 1])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:48.919176Z","iopub.execute_input":"2022-08-13T17:38:48.919643Z","iopub.status.idle":"2022-08-13T17:38:48.928084Z","shell.execute_reply.started":"2022-08-13T17:38:48.919606Z","shell.execute_reply":"2022-08-13T17:38:48.926538Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 3.2 Logistic Regression:\nLet's create pipeline consisted of scaleres and regression in the end ","metadata":{}},{"cell_type":"code","source":"ct = ColumnTransformer(\n    [(\"num\", make_pipeline(StandardScaler(), MinMaxScaler()), num_cols),\n    (\"col\", OneHotEncoder(), cat_cols)]\n)\n\npipeline__ = make_pipeline(ct, LogisticRegression(max_iter = 500))\n","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:48.930521Z","iopub.execute_input":"2022-08-13T17:38:48.932181Z","iopub.status.idle":"2022-08-13T17:38:48.941209Z","shell.execute_reply.started":"2022-08-13T17:38:48.932100Z","shell.execute_reply":"2022-08-13T17:38:48.939677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gs = GridSearchCV(pipeline__, param_grid = {\"logisticregression__C\": [100, 10, 1, 0.1, 0.01, 0.001]}, scoring = 'roc_auc', refit = True)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:48.943141Z","iopub.execute_input":"2022-08-13T17:38:48.944148Z","iopub.status.idle":"2022-08-13T17:38:48.956137Z","shell.execute_reply.started":"2022-08-13T17:38:48.944104Z","shell.execute_reply":"2022-08-13T17:38:48.954681Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gs.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:48.958359Z","iopub.execute_input":"2022-08-13T17:38:48.959028Z","iopub.status.idle":"2022-08-13T17:38:55.055842Z","shell.execute_reply.started":"2022-08-13T17:38:48.958976Z","shell.execute_reply":"2022-08-13T17:38:55.053843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame(gs.cv_results_)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.058399Z","iopub.execute_input":"2022-08-13T17:38:55.060200Z","iopub.status.idle":"2022-08-13T17:38:55.097529Z","shell.execute_reply.started":"2022-08-13T17:38:55.060114Z","shell.execute_reply":"2022-08-13T17:38:55.096150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Best ROC-AUC is {0} with C equals {1}\".format(round(gs.best_score_, 3), gs.best_params_['logisticregression__C']))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.099286Z","iopub.execute_input":"2022-08-13T17:38:55.099700Z","iopub.status.idle":"2022-08-13T17:38:55.107522Z","shell.execute_reply.started":"2022-08-13T17:38:55.099663Z","shell.execute_reply":"2022-08-13T17:38:55.105926Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = gs.best_estimator_.predict_proba(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.109888Z","iopub.execute_input":"2022-08-13T17:38:55.110537Z","iopub.status.idle":"2022-08-13T17:38:55.137076Z","shell.execute_reply.started":"2022-08-13T17:38:55.110493Z","shell.execute_reply":"2022-08-13T17:38:55.134511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fpr_logistic, tpr_logistic, thresholds  = roc_curve(y_test, prediction[:, 1])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.155535Z","iopub.execute_input":"2022-08-13T17:38:55.161027Z","iopub.status.idle":"2022-08-13T17:38:55.177161Z","shell.execute_reply.started":"2022-08-13T17:38:55.160915Z","shell.execute_reply":"2022-08-13T17:38:55.175264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### 3.3 Random Forest Classifier","metadata":{}},{"cell_type":"code","source":"ct = ColumnTransformer(\n    [(\"num\", make_pipeline(StandardScaler(), MinMaxScaler()), num_cols),\n    (\"col\", OneHotEncoder(), cat_cols)]\n)\n\npipeline__ = make_pipeline(ct, RandomForestClassifier())\n\npipeline__.fit(X_train, y_train)\nprediction = pipeline__.predict_proba(X_test)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.188707Z","iopub.execute_input":"2022-08-13T17:38:55.194430Z","iopub.status.idle":"2022-08-13T17:38:55.965110Z","shell.execute_reply.started":"2022-08-13T17:38:55.194320Z","shell.execute_reply":"2022-08-13T17:38:55.963601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fpr_forest, tpr_forest, thresholds  = roc_curve(y_test, prediction[:, 1])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.966961Z","iopub.execute_input":"2022-08-13T17:38:55.967440Z","iopub.status.idle":"2022-08-13T17:38:55.975272Z","shell.execute_reply.started":"2022-08-13T17:38:55.967401Z","shell.execute_reply":"2022-08-13T17:38:55.974195Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"##### 3.4 ROC-AUC","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize = (10, 7))\nplt.title(\"ROC-AUC\")\nplt.plot(fpr_catboost, tpr_catboost, c = 'orange', label = 'CatBoost')\nplt.plot(fpr_logistic, tpr_logistic, c = 'red', label = 'Logistic Regression')\nplt.plot(fpr_forest, tpr_forest, c = 'green', label = 'Random Forest')\nplt.plot([0,1], [0, 1], linestyle = ':')\nplt.xlabel(\"FPR\")\nplt.ylabel(\"TNR\")\nplt.legend()\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:55.976921Z","iopub.execute_input":"2022-08-13T17:38:55.977884Z","iopub.status.idle":"2022-08-13T17:38:56.257743Z","shell.execute_reply.started":"2022-08-13T17:38:55.977809Z","shell.execute_reply":"2022-08-13T17:38:56.256215Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"It seems like the best algorithm is `Logistic Regression.` But `CatBoost` is so near, that i rather prefer to make a stack of `CatBoost` and `Logistic Regression` if it needed ","metadata":{}},{"cell_type":"markdown","source":"#### 4. Creating the submit csv","metadata":{}},{"cell_type":"code","source":"final_pred = gs.best_estimator_.predict_proba(test_)[:, 1]","metadata":{"execution":{"iopub.status.busy":"2022-08-13T18:04:46.792385Z","iopub.execute_input":"2022-08-13T18:04:46.792916Z","iopub.status.idle":"2022-08-13T18:04:46.823692Z","shell.execute_reply.started":"2022-08-13T18:04:46.792878Z","shell.execute_reply":"2022-08-13T18:04:46.821842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_ = pd.read_csv('../input/advanced-dls-spring-2021/submission.csv')","metadata":{"execution":{"iopub.status.busy":"2022-08-13T18:04:49.935785Z","iopub.execute_input":"2022-08-13T18:04:49.936256Z","iopub.status.idle":"2022-08-13T18:04:49.946619Z","shell.execute_reply.started":"2022-08-13T18:04:49.936222Z","shell.execute_reply":"2022-08-13T18:04:49.945135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_['Churn'] = final_pred","metadata":{"execution":{"iopub.status.busy":"2022-08-13T18:04:51.128620Z","iopub.execute_input":"2022-08-13T18:04:51.129112Z","iopub.status.idle":"2022-08-13T18:04:51.136028Z","shell.execute_reply.started":"2022-08-13T18:04:51.129075Z","shell.execute_reply":"2022-08-13T18:04:51.134747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_.head(25)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T18:04:53.250715Z","iopub.execute_input":"2022-08-13T18:04:53.251241Z","iopub.status.idle":"2022-08-13T18:04:53.266316Z","shell.execute_reply.started":"2022-08-13T18:04:53.251202Z","shell.execute_reply":"2022-08-13T18:04:53.264851Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_.to_csv(\"/kaggle/working/submission.csv\", index = False)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:38:56.329283Z","iopub.execute_input":"2022-08-13T17:38:56.330910Z","iopub.status.idle":"2022-08-13T17:38:56.345016Z","shell.execute_reply.started":"2022-08-13T17:38:56.330846Z","shell.execute_reply":"2022-08-13T17:38:56.343436Z"},"trusted":true},"execution_count":null,"outputs":[]}]}