Icon

01 Analyze Training a Churn Predictor

<p><strong>Analyze Data by Training a Decision Tree</strong></p><p>This workflow is an example of how to <strong>train and evaluate a basic machine learning model</strong> for a churn prediction task.</p><p>In this case, we train and apply a <strong>Decision Tree</strong> algorithm, however, the Learner-Predictor construct is common to all supervised algorithms.</p>

URL: Predict customer churn: A low-code machine learning example - KNIME Blog https://www.knime.com/blog/predict-customer-churn-low-code-ml-example
URL: KNIME Self Paced Course https://www.knime.com/knime-self-paced-courses
URL: KNIME Cheat Sheet : Building a KNIME Workflow for Beginners https://www.knime.com/sites/default/files/2021-07/CheatSheet_Beginner_A3.pdf

Pre-processing (data preparation)
Read data from different files
  • CallsData.xls: Customer activity

  • ContractData.csv: Information about customers

Color Churn

Assign color coding to data:

  • 0 -> Blue

  • 1 -> Red

Conversions

Convert "Churn" and "Area Code" to String

Partitioning

Split data into training set (80%) and test set (20%)

How to train a Decision Tree model?

Step 1:Add the "Decision Tree Learner" node and select it to open the dialog on the right.

Step 2: Set the "Class column" as "Churn" and "Quality measure" to "Gini Index".

Step 3:Click "Execute" to train the model. Investigate the view of the Decision Tree (magnifier button in the node action bar).

How to evaluate a Decision Tree model?


Step 1:Add the Decision Tree Predictor node.

Step 2: Connect the output of "Decision Tree Learner" node to Port 0 andthe test set to Port 1. Execute the node.

Step 3: Connect the Predictor Output to "ROC Curve" and "Scorer" node to evaluate the model on various evaluation measures.

Analyze Data by Training a Decision Tree


This workflow is an example of how to train and evaluate a basic machine learning model for a churn prediction task.

In this case, we train and apply a Decision Tree algorithm, however, the Learner-Predictor construct is common to all supervised algorithms.

Model training

Train the Decision Tree with the Decision Tree Learner node. Write the trained model to a .pmml file with the Model Writer node.

Model evaluation

Apply the trained Decision Tree to the test set with the Decision Tree Predictor node. Evaluate the prediction using the ROC Curve and Scorer nodes.

Workflow complete!

Keep the momentum going by exploring Just KNIME It!on the Hub to challenge yourself and see how these nodes can be integrated into more complex workflows and use cases.

Join input dataon "Area Code"and "Phone"
Joiner
Top: Training setBottom: Test set
Table Partitioner
Apply trainedDecision Tree
Decision Tree Predictor
Area under the Curve
ROC Curve
Class column:Churn
Decision Tree Learner
Convert "Churn" and"Area Code" to String
Number to String
Color databy "Churn" values
Color Manager
Write trained modelworkflow data area
PMML Writer
ReadCallsData.xls
Excel Reader
Performance scoring:Evaluate accuracy
Scorer
ReadContractData.csv
CSV Reader

Nodes

Extensions

Links