सामग्री पर जाएँ

लेसन 25 · Projects and Reference

KNIME Project: Customer Churn Classifier

Build a KNIME churn prediction workflow with a safe data split, a baseline, a decision tree and random forest, threshold choice by cost, and a scoring pipeline.

In this project you predict which subscribers are likely to cancel, so a team can contact them. It is a practice problem with made-up data. The goal is not a high score but a trustworthy process that you can defend.

The brief

Data columns (invent a few hundred rows, or generate them with the stand-in logic):

Column Type Note
customer_id text Identifier, not a feature
tenure_months number Months as a customer
monthly_fee number Current price
support_tickets number Last 90 days
cancel_reason text Filled only after cancelling
churned text yes or no, the target

Spot the trap: cancel_reason exists only after the customer has left, so it must be removed. The identifier should also be excluded from training.

Business rule: contacting a customer costs little, but losing one costs much more. Recall matters, but the team can only call 30 people per week.

Generate practice data

This stand-in creates repeatable synthetic rows. The churn pattern is invented, so nothing here says anything about real customers.

Python Stand-in: generate synthetic churn rows

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

To use data in KNIME, you could write similar rows into a CSV file and read it with CSV Reader.

The workflow

flowchart LR
  A["Read"] --> B["Remove ID and leaky columns"]
  B --> C["Table Partitioner"]
  C -->|train| D["Learner"]
  C -->|test| E["Predictor"]
  D --> E
  E --> F["Scorer and ROC Curve"]

The test rows are only used to judge the model.

  1. Profile the data: class balance, missing values, ranges.
  2. Remove customer_id from the features (keep it aside for the contact list) and delete cancel_reason.
  3. Split with Table Partitioner, 80/20, stratified on churned, with a fixed seed. Keep a validation portion by splitting the training part again, so you can choose a threshold without touching the test set.
  4. Fill missing values using statistics learned from training data, and apply the same to other parts.
  5. Baseline: predict "no" for everyone. Record its accuracy and recall.
  6. Train a Decision Tree Learner and a Random Forest Learner.
  7. Predict with class probabilities enabled.
  8. Evaluate with Scorer and ROC Curve on validation data.

Choose a threshold with capacity

Because the team can call only 30 people, ranking matters more than one fixed threshold. Sort by predicted churn probability and take the top 30. Then ask: how many of those really churned? That is precision at 30.

Python Stand-in: precision and recall for the top K

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Compare precision at 30 with the overall churn share. If random calling would do as well, the model adds nothing. The scores here are fabricated to show the calculation.

Check for trouble

  • Is the training score far above the validation score? Suspect overfitting.
  • Is one feature almost perfect? Suspect leakage.
  • Does the model work for new and long-term customers alike?
  • Are results stable across different random seeds or cross-validation folds?

When satisfied, evaluate once on the test set and report that number.

Score new customers

Save the model and the preparation steps, or capture them together with Integrated Deployment, as described in reusing models. The scoring workflow should:

  1. read current customers,
  2. apply the same preparation,
  3. predict probabilities,
  4. sort and select the top 30,
  5. write a contact list with only the fields the team needs.

Write a short model note

Record the purpose, data period, features, split method, baseline, final metrics, known limits, who owns it, and when to review it. Add what the model must not be used for, for example raising prices for people it thinks are unlikely to leave.

A churn score is a hint for a human, not a verdict about a person. Check that your use of customer data is allowed, avoid sensitive attributes unless you have a legitimate and legal reason, and measure whether contacting people actually helps. A model that predicts who leaves does not prove that calling them keeps them.

Reading your results honestly

Suppose your random forest scores a little higher than the tree on validation data. Before you declare a winner, repeat the split with several seeds or run cross-validation. If the difference changes sign between runs, the models perform about the same on this data, and the simpler, explainable tree may be the better choice. Report the range of scores, not only the best one.

Look at the mistakes too. Take ten false negatives, meaning churners the model missed, and compare them with ten true positives. Do they share something your features do not capture? With real data, that might be a recent price change or a complaint recorded elsewhere. That insight is often more useful than another round of tuning, because it points to better data.

What the project does not prove

Even a well tested model only describes patterns in the data you gave it. Your synthetic data was created by a rule you can see, so the model can only rediscover that rule. With real data, you would also have to ask whether past behavior still holds, whether the labels are correct, and whether the contact campaign changes the very behavior you are predicting. To learn whether calls help, teams usually compare a contacted group with a similar group that was not contacted, with proper approval and fair treatment of customers.

Deliverables

Hand in the workflow with annotations, the golden test inputs, a model note, a table of validation results with the baseline, and the contact list format. A reviewer should be able to rerun your work and reach the same numbers.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Why must cancel_reason be removed before training?

    Features must be available at prediction time.
  2. 2. The team can call 30 people. Which measure fits that decision?

    It shows how useful the actual call list is.
  3. 3. Where should you choose the threshold or tune settings?

    Tuning on the test set makes its score optimistic.

Summary

  • Remove identifiers and leaky columns before training.
  • Split with stratification, and keep validation and test data separate.
  • Compare models against a baseline and the business capacity.
  • Score new data with the same preparation.
  • Document limits and keep humans responsible.

Next: KNIME Glossary and Cheat Sheet

आपकी प्रगति इसी ब्राउज़र में सेव होती है। खाते की ज़रूरत नहीं है।