James Young

Machine Learning and Artificial Intelligence Expert

From Forecasting to How-Casting: Optimizing Multi-Territory Marketing with Machine Learning and Analytics

Imagine you’re in charge of a company that owns multiple retail franchises across different territories. Each franchise caters to local customers, and you need to decide how many “touchpoints” (such as email campaigns, in-store promotions, or direct mailers) to allocate to each customer segment. Too few, and you won’t see a lift in sales. Too many, and you burn through budget without a meaningful incremental return.

In this blog, we’ll walk through how a machine learning approach—combined with a simple optimization step—helps you make data-driven decisions. By the end, you’ll see how we translate a typical business problem into:

  1. Data Generation (what does a realistic dataset look like?)
  2. Model Training (how do we use machine learning to forecast profit?)
  3. Explainability (how do we show which factors matter most?)
  4. Optimization (how do we pick the best scenario for each territory to maximize total profit?)

The best part? These techniques are generic enough to be adapted to many industries—retail, healthcare, manufacturing, and more.


1. Data Generation: Imagining Our Franchise Scenario

Think of each territory as one region under your management. Within each territory, there are multiple customer groups (like different demographic segments). Each group responds to a certain number of marketing touchpoints with some level of “sales lift.” However, you pay a cost for these touchpoints. The sweet spot is where the benefit outweighs the cost, leading to profit.

This dataset represents simulated sales data for a company selling car parts across multiple territories. Each Territory_ID contains several Customer_Group_IDs, representing different customer demographics within that region. For each customer group, the data includes key attributes like Baseline_Sales (initial expected sales without additional touchpoints), Max_Sales (maximum achievable sales), and logistic curve parameters like Inflection_Point and Slope, which describe how sales respond to increasing touchpoints (e.g., marketing efforts). These types of variables are often estimated by additional modeling, but we provide them here for simplicity and conceptual understanding. Additional demographic factors, such as Income_Level and Urban_Rural_Split, provide context for customer behavior, with urban groups potentially responding differently to promotions than rural groups. Downstream, this data powers our machine learning model, predicting the impact of different touchpoint allocations (1–10) on sales and profit. These predictions enable scenario generation and optimization to determine the most cost-effective marketing strategies for each customer group, maximizing ROI while adapting to local customer dynamics.

In practice, you’d replace this “fake” data generation with real corporate data—maybe historical campaigns or sales logs. The principle remains the same: each territory–customer pair has a range of possible marketing intensities and an associated outcome.


2. Training a Predictive Model

Why Model Profit?

Rather than just forecasting sales, we directly model profit since that’s the real driver of business decisions. In this data, each row describes a specific scenario (like “6 touchpoints for territory #2, group #4”), with a resulting profit. By training a model on these scenarios, we learn how changing touchpoints interacts with each group’s unique traits (like baseline sales or region demographics) to affect the bottom line.

Many machine learning models can be used at this step, I often prefer, XGBoost, a popular and powerful gradient boosting library, to learn this mapping.

Interpretation

  • Train R² tells you how well the model explains variations in profit on the data it saw during training.
  • Test R² is more important: it indicates how well the model generalizes to unseen data.

If the test score is high (R2 ~ 0.97 in this case), it suggests we can confidently predict profit for any combination of territory features (income, etc.) and marketing touchpoints.


3. Explaining the Model with SHAP

Some stakeholders might worry: “How do we trust these predictions? Is this just a black box?” One way to alleviate those concerns is by using SHAP plots. SHAP stands for “SHapley Additive exPlanations,” a method from cooperative game theory that tells us, for each feature and each scenario, how much that feature increases or decreases the predicted value.

SHAP Summary Plot

What does it show? Each dot represents a single scenario from the dataset. The spread in the “x-axis” indicates how strongly that feature impacted the model’s predicted profit. The higher the spread, the more influential that feature can be—touchpoints might top the list, but you might also see a strong effect from “Income_Level” or “Max_Sales.”

SHAP Dependence Plot

We can also look at how a single feature (like Touchpoints) influences the model across different scenarios. This is extremely valuable to highlight how, for one group, 5 touchpoints might yield a bigger jump in profit, while for another group, that same level might barely move the needle. You can think of this as sensitivity to touchpoints and can vary from territory to territory, which is all captured by the model.


4. Optimization: Picking the Best Allocation

Once our model can predict profit for any number of touchpoints for any group in any territory, the obvious question is: How do we choose which scenario to use?

Goal:

We want to maximize total profit across all groups, subject to the constraint that each group receives exactly one allocation of touchpoints (1–10).

We handle this with a Linear Programming approach:

  1. Binary Decision Variables: For each scenario, we have a variable that says “Yes, we pick this scenario” or “No, we don’t.”
  2. Constraints: Each group can only pick one scenario.
  3. Objective: Maximize the sum of predicted profits for all chosen scenarios.

The result? A table that lists, for each territory and each customer group, the number of touchpoints that collectively maximizes overall profit. Maybe you’ll find that territory #1 can push more promotions to group #2 (they respond strongly), but territory #3’s best bet is fewer promotions for group #7 due to cost constraints.

The example below is when each territory has no cap on the number touchpoints they can run in the coming time period. That doesn’t mean it is most profitable to use all touchpoints (10) per customer group in every case, but they don’t have to worry about staying under cap or budget.

Now let’s imagine that each territory has to stay under 35 touchpoints. Here is where the optimization algorithm makes life much easier for humans. We still want to maximize predicted_profit while staying under the cap of 35 touchpoints but making sure each customer group gets at least 1 touchpoint. It turns out some customer groups are much more sensitive to touchpoints, as pointed out in the SHAP plots above, and it is more profitable to focus additional toucpoints to them. Also notice that in some cases the predicted profit for a given customer group is negative, which was necessary to to achieve the highest profit in aggregate by putting extra touchpoints where they had the most impact.


What Have We Learned?

  • Analytics-Driven Insights: We turned a tough “guesswork” question—how many marketing touchpoints to allocate—into a systematic approach based on data, modeling, and optimization.
  • Model Transparency: Tools like SHAP help us see why the model picks the allocations it does, giving us confidence in our results.
  • Easy Adaptation: This entire methodology can be adapted to other industries or different resources. Whether you’re dealing with medical representatives calling on HCPs, or sales teams interacting with key accounts, the principle is the same: you have limited resources (touchpoints) and a measurable return (profit or revenue).

NEXT STEP

Next we will evaluate the lift!


That’s it!

With this demonstration, I hope to show how analytics can transform a typical marketing resource puzzle into a transparent, data-driven solution. Whether you’re a small business owner or an executive at a large enterprise, the ability to model outcomes, understand drivers, and optimize decisions is a huge competitive edge in today’s market.

By combining machine learning and optimization, you can harness data to make informed decisions, ensuring both cost-effectiveness and higher returns.

2 responses to “From Forecasting to How-Casting: Optimizing Multi-Territory Marketing with Machine Learning and Analytics”

  1. […] this local desktop app potential, I’ll tie in an interest of mine which I have written about, moving from forecasting to “how-casting” (how can you change future outcomes rather than just let it happen to […]

  2. […] our previous blog post, we discussed how to move from simple forecasting to “how-casting” by using machine learning […]

Leave a Reply to Beyond the Browser: Why an Executable Analytics App Can Offer a Unique AdvantageCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from James Young

Subscribe now to keep reading and get access to the full archive.

Continue reading