weltby Ergodic Sign inGet started
All use cases

Will This Customer Churn?

Which of your customers are about to cancel, and how likely is each one to go? A retention team can only call so many people a week, so it needs the list ranked by risk, with a probability next to each name.

Use caseCustomersPredictionModel evaluation

The table

The IBM Telco churn table has 7,043 customers and 19 columns about each one: how long they've been a customer, their contract, what they pay, which services they use. The last column, Churn, says whether they left. Some cells are text and a few are blank, and Welt takes both as they are.

Walkthrough

  1. Load the table

    Read the public CSV and drop the ID column, which tells a model nothing about churn.

    import pandas as pd
    from welt import Client
    
    url = "https://raw.githubusercontent.com/IBM/telco-customer-churn-on-icp4d/master/data/Telco-Customer-Churn.csv"
    customers = pd.read_csv(url).drop(columns="customerID")
    customers["TotalCharges"] = pd.to_numeric(customers["TotalCharges"], errors="coerce")
    print(customers.shape, customers["Churn"].value_counts().to_dict())
  2. Pick the customers

    Set aside 20 customers to score at the end, and keep the rest for the models to learn from.

    new_rows = customers.sample(20, random_state=1)
    table = customers.drop(new_rows.index)
  3. Compare the models and score

    TabICLv2 and Kumo Tabular Medium compete on the same folds against a simple guess, then the top-ranked one is fitted on the whole table. ROC AUC runs from 0.5, a coin toss, to 1, a perfect ranking, and a lower Brier score means the probabilities can be trusted more. The last table puts each customer's chance of leaving next to what they did.

    with Client() as client:
        evaluation = client.evaluate(table, "Churn", task="classification", seed=7,
                                     models=["tabicl-v2", "kumo-medium"])
        model = evaluation.fit()
    
    print(evaluation.summary()[["name", "rank", "roc_auc_mean", "brier_mean"]])
    features = new_rows.drop(columns="Churn")
    print(pd.DataFrame({"actual": new_rows["Churn"].values,
                        "chance of leaving": model.predict_proba(features)[:, 1]}))

What you get

A ranked call listEvery customer has a probability of leaving, highest first.
The right model for this tableThe leaderboard shows which model won and whether it beat the runner-up by more than chance.
A report to shareevaluation.report_link() gives a link your manager can open without an account.

Try it

Use Open with to run the evaluation notebook in Colab, Kaggle or Jupyter, or paste the code above into your own notebook after pip install "welt-client[parquet]".