4. Applying the forecasts model
Stefan Musch
2025-10-17
Source:vignettes/appraise_forecasts_model.Rmd
appraise_forecasts_model.RmdPreparing your data
The forecast analysis is optional, but clients very often care more about the forecasts we’re making than the customer lifetime analysis itself. The forecast model requires three pieces of input;
- The expected transactions and sales current customers will make in the future
- The number of new customers the company is expected to acquire
- The average sales of any arbitrary
new customer
In short, this is what the model inputs end up looking like in the automated workflow.
scenario_predictions_automated <-
fit_forecast_model(forecasts,
n_scenarios = 1,
cpa_scenarios,
spend_scenarios,
config)Expected transactions of current customers
This comes from the fit_customer_model() and can be
accessed with forecasts$forecasted_tx or
forecasts$forecasted_spend. Both of these elements are
vectors of the same length as your config$N_FORECAST, with
a single forecast per period.
customer_level_predictions$forecasts$forecasted_tx[1] 1008.69 1539.79 1221.44 1034.99 907.74
Number of new customers
This needs to be obtained from the client and is typically derived by
dividing the expected total spend by
the cost per acquisition (CPA). The client will often
provide multiple scenarios (e.g., low vs high CPA) as inputs to test the
forecasts by different assumptions.
In this case, we’ll need to get the cpa_scenarios and
spend_scenarios as a matrix, where the rows are time
periods and the columns are the scenarios. E.g., in this case, we only
have 1 scenario with 5 time periods to predict.
forecasts <- customer_level_predictions$forecasts
cpa_scenarios <-
sample(c(25, 50, 75, 100, 125, 150, 200),
size = nrow(forecasts),
replace = TRUE) %>%
as.matrix()
cpa_scenarios [,1]
[1,] 125
[2,] 200
[3,] 100
[4,] 200
[5,] 125
Average sales of a new customer
This comes from the fit_customer_model() and an be
accessed with forecasts$forecasted_tx_series and
forecasts$forecasted_clv_series. The values represent the
expected value per order (clv) and the expected transaction the average
new customer will make per forecast period.
Outputs of the forecast model
After running your model with the automated flow;
#### Automated flow ----
## TODO uncomment
# scenario_predictions_automated <-
# fit_forecast_model(forecasts,
# n_scenarios = 1,
# cpa_scenarios,
# spend_scenarios,
# config)You can access the expected number of total transactions and total
sales per time period with
scenario_predictions_automated$forecasts. For a more
granular view of the forecasts, you can access the waterfall tables for
each of the scenarios with
scenario_predictions_automated$forecasts_waterfalls.