{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Predictive Analytics: Choosing the model with highest ROI for Term Deposit Campaigns\n", "\n", "* In this analysis I am trying to fit a predictive model to predict whether a bank customer will subscribe to a term deposit and then try to report the results in a clear and concise manner using the package 'modelplotpy'.\n", "* We will also look at how the predictive model is doing locally using the package 'lime'.\n", "* The dataset has various kinds of features associated with 1 row ( = 1 customer). Lets explore.\n", "\n", "\n", "\n", "\n", "* Importing required libraries" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\cgokh\\Anaconda3\\lib\\site-packages\\sklearn\\ensemble\\weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.\n", " from numpy.core.umath_tests import inner1d\n" ] } ], "source": [ "# Importing libraries\n", "import pandas as pd\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.ensemble import GradientBoostingClassifier\n", "from sklearn.metrics import recall_score, accuracy_score, precision_score, confusion_matrix\n", "import seaborn as sns\n", "import modelplotpy as mp\n", "import numpy as np\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | age | \n", "job | \n", "marital | \n", "education | \n", "default | \n", "housing | \n", "loan | \n", "contact | \n", "month | \n", "day_of_week | \n", "... | \n", "campaign | \n", "pdays | \n", "previous | \n", "poutcome | \n", "emp.var.rate | \n", "cons.price.idx | \n", "cons.conf.idx | \n", "euribor3m | \n", "nr.employed | \n", "y | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "56 | \n", "housemaid | \n", "married | \n", "basic.4y | \n", "no | \n", "no | \n", "no | \n", "telephone | \n", "may | \n", "mon | \n", "... | \n", "1 | \n", "999 | \n", "0 | \n", "nonexistent | \n", "1.1 | \n", "93.994 | \n", "-36.4 | \n", "4.857 | \n", "5191.0 | \n", "no | \n", "
1 | \n", "57 | \n", "services | \n", "married | \n", "high.school | \n", "unknown | \n", "no | \n", "no | \n", "telephone | \n", "may | \n", "mon | \n", "... | \n", "1 | \n", "999 | \n", "0 | \n", "nonexistent | \n", "1.1 | \n", "93.994 | \n", "-36.4 | \n", "4.857 | \n", "5191.0 | \n", "no | \n", "
2 | \n", "37 | \n", "services | \n", "married | \n", "high.school | \n", "no | \n", "yes | \n", "no | \n", "telephone | \n", "may | \n", "mon | \n", "... | \n", "1 | \n", "999 | \n", "0 | \n", "nonexistent | \n", "1.1 | \n", "93.994 | \n", "-36.4 | \n", "4.857 | \n", "5191.0 | \n", "no | \n", "
3 | \n", "40 | \n", "admin. | \n", "married | \n", "basic.6y | \n", "no | \n", "no | \n", "no | \n", "telephone | \n", "may | \n", "mon | \n", "... | \n", "1 | \n", "999 | \n", "0 | \n", "nonexistent | \n", "1.1 | \n", "93.994 | \n", "-36.4 | \n", "4.857 | \n", "5191.0 | \n", "no | \n", "
4 | \n", "56 | \n", "services | \n", "married | \n", "high.school | \n", "no | \n", "no | \n", "yes | \n", "telephone | \n", "may | \n", "mon | \n", "... | \n", "1 | \n", "999 | \n", "0 | \n", "nonexistent | \n", "1.1 | \n", "93.994 | \n", "-36.4 | \n", "4.857 | \n", "5191.0 | \n", "no | \n", "
5 rows × 21 columns
\n", "