Skip to content
Tutorials Center
My learning

Topics

Lesson 29 of 36 ยท Analytics and Cloud

Forecasting and Analytics: Pipeline, Segments and Churn

Apply analytics to ERP and CRM data: weighted pipeline forecast, moving averages, demand forecasting, RFM customer segmentation and churn risk, with runnable Python models.

Reporting says what happened. Analytics goes further: it explains why, estimates what will happen and suggests what to do. ERP and CRM data is ideal material, because it holds a long, structured record of orders, payments, stock and customer interactions. Most vendors now offer built-in forecasting, scoring and recommendations; knowing how the basic models work helps you judge what they tell you.

This lesson explains four practical techniques with small, runnable Python models: weighted pipeline forecasting, time-series forecasting for demand, RFM segmentation and churn risk scoring. The models are simplified teaching tools, not any vendor's actual algorithm.

Levels of analytics

  • Descriptive: what happened (sales by month).
  • Diagnostic: why it happened (margin fell because a discount campaign changed the mix).
  • Predictive: what will probably happen (next quarter's demand).
  • Prescriptive: what should we do (reorder quantity, next best offer).

1. Weighted pipeline forecast (CRM)

Each open opportunity has a value and a stage. Each stage has a historical win probability, measured from past deals. The expected revenue is the sum of value times probability. Sales managers combine this with their own judgement ("commit", "best case").

Python Weighted pipeline

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.

The weighted figure is an expectation across many deals; one big deal either closes or does not. Quote a range, not a point, and keep stage probabilities updated from real history.

2. Demand forecasting (ERP)

Demand planning drives purchasing, production and stock. The simplest tools use history:

  • Moving average: the average of the last n periods; smooth but slow to react.
  • Exponential smoothing: each new forecast = alpha x latest actual + (1 - alpha) x previous forecast. A higher alpha reacts faster but is noisier.
  • Seasonality: repeat patterns by month or week, handled by seasonal indexes or models like Holt-Winters or ARIMA.
  • Causal factors: promotions, price changes, weather and holidays.

Measure accuracy with MAPE (mean absolute percentage error) or MAE, and compare against a naive baseline ("same as last period"). A fancy model that cannot beat the baseline is not worth running.

Python Moving average vs exponential smoothing

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.

This series has a clear upward trend. Notice that a method that averages old data lags behind a trend, and the more reactive version tends to do better here. With seasonal data the answer might differ, which is why you always test several methods on your own history.

3. Customer segmentation with RFM

RFM scores customers by Recency (days since last purchase), Frequency (number of orders) and Monetary value (total spend). Customers with a recent, frequent, high-value history are champions; those with old, rare purchases are at risk. Marketing and sales use segments to choose actions.

Python RFM scoring

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.

Segment actions: champions get early access and referral asks; at-risk customers get a personal call; lapsed ones a win-back offer. Always check the thresholds against your own distribution, for example using quantiles.

4. Churn risk scoring

For subscription or repeat-purchase businesses, churn is customers who stop buying. Predictive models learn from history which signals precede churn: fewer logins, falling order frequency, more complaints, unpaid invoices, a champion leaving the customer. Real models are trained with machine learning on labelled history; below is a transparent rule-based score that shows the idea and is easy to explain to account managers.

Python Transparent churn risk score

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.

A score is only useful if it triggers an action: a task for the account manager, an outreach campaign, an escalation. Review the model regularly against actual churn, and avoid using sensitive personal attributes in a way that could be unfair or unlawful.

Pitfalls

  • Garbage in, garbage out: forecasts depend on clean history (see data quality monitoring).
  • Overfitting: a complex model that memorizes the past and fails on new data.
  • Black boxes: if users cannot see why a lead or customer is scored high, they ignore it.
  • No feedback loop: record outcomes so models improve.
  • Mistaking correlation for cause when deciding actions.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a weighted pipeline forecast multiply?

    Each deal contributes its value times the historical probability for its stage; the sum is the expected revenue.
  2. 2. Which comparison should every forecasting model be measured against?

    If a model cannot beat the naive baseline, its extra complexity brings no value.
  3. 3. In RFM, what does the R stand for?

    Recency is how long ago the customer last bought.
  4. 4. Why is a transparent churn score often preferred by account managers?

    Explanations such as falling orders and overdue invoices point to concrete actions and build trust.

Summary

  • Analytics moves from describing to predicting and recommending.
  • Weighted pipeline gives an expected value; quote ranges.
  • Test smoothing and moving-average forecasts against a naive baseline.
  • RFM segments customers for targeted actions; churn scores need action triggers and a feedback loop.
  • Clean data and explainable models are the foundation.

Next: Cloud, SaaS and On-Premise Deployment