Icon

01 Analyze Data by Training a Decision Tree

<p><strong>Analyze Data: 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 <em>Learner-Predictor</em> construct is common to all supervised algorithms.</p>

URL: KNIME Learning Center https://www.knime.com/learning
URL: KNIME Cheat Sheet: Building a KNIME workflow for beginners https://www.knime.com/cheat-sheets/building-knime-workflow-beginners
URL: KNIME Cheat Sheet: Machine learning with KNIME Analytics Platform https://www.knime.com/files/machine-learning-with-knime.pdf
URL: YouTube: Training and Applying Decision Trees in KNIME https://youtu.be/UeQAHusmwbI?si=bZ2v5rS350D1iJyJ
URL: YouTube: Behind the Scenes of the Decision Tree with KNIME https://youtu.be/8dxH_Arc4QM?si=9uw5T4BxyfzDg8GY
URL: KNIME Blog: Predict Customer Churn with a Low-Code ML Solution https://www.knime.com/blog/predict-customer-churn-low-code-ml-example
URL: Webinar: KNIME101: Machine Learning for Beginners with KNIME https://www.knime.com/events/knime101-machine-learning-beginners-knime

Annotations and comments
  • Read data from different files CallsData.xls: Customer activity ContractData.csv: Information about customers
  • Pre-processing (data preparation)
  • 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.
  • Conversions Convert "Churn" and "Area Code" to String
  • Color Churn Assign color coding to data: 0 -> Blue 1 -> Red
  • 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 to the workflow and select it to open the configuration window. Step 2: Set the "Class column" to "Churn" and "Quality measure" to "Gini index". Step 3: Click "Apply and Execute" to train the model. Investigate the view of the Decision Tree (click magnifier in the node action bar).
  • How to evaluate a Decision Tree model? Step 1: Add the "Decision Tree Predictor" node to the workflow. Step 2: Connect the output of "Decision Tree Learner" node to Port 0 and the test set to Port 1. Execute the node. Step 3: Connect the output containing the predictions to the "ROC Curve" and "Scorer" node to evaluate the model on various evaluation measures.
  • 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.
  • Read ContractData.csv
  • Color data by "Churn" values
  • Class column: Churn
  • Apply trained Decision Tree
  • Read CallsData.xls
  • Join input data on "Area Code" and "Phone"
  • Convert "Churn" and "Area Code" to String
  • Write trained model workflow data area
  • Top: Training set Bottom: Test set
  • Area under the Curve
  • Performance scoring: Evaluate accuracy

Nodes

Extensions

Links