...
/Visualizing Classification Model Outputs
Visualizing Classification Model Outputs
Learn how Plotly can assist in plotting the outputs of (classification) machine learning models in Python.
We'll cover the following...
The data
The data that we will use for the following plots is a customer churn dataset that details many important people attributes such as their Age
, CreditScore
, gender
(1
if male and 0
otherwise), etc. We also notice some one-hot encoded columns Geography_France
, Geography_Germany
, and Geography_Spain
. These values are either 1 or zero, so if a person is from France, Geography_France=1
, Geography_Germany=0
, and Geography_Spain=0
. We then use these variables to predict whether someone has Exited
(churned).
# Import librariesimport pandas as pdimport numpy as np# Import datasetschurn = pd.read_csv('/usr/local/csvfiles/churn_preprocessed.csv')print(churn.head())
We will now build a model (in this case, a GradientBoostingClassifier
) in which Exited
is the dependent variable and all the remaining variables are the predictor (independent) variables.
We split the data into training and testing sets so that we can fit the model to the training data and evaluate the model on unseen ...