Blog · Machine learning

Machine learning for business analytics: start with the decision, then the model

Plan a useful machine learning project for business analytics: define a decision, compare a rule, choose data and evaluate errors with a worked example.

Machine learning for business analytics uses patterns in past data to support a business decision, such as planning stock, prioritising a review queue or estimating demand. A useful project specifies the decision and measures improvement over the current process. A prediction score by itself does not show that changing the process helps.

This guide is for a learner planning a first analytics project. It uses a fictional stationery shop, with invented quantities and costs so the arithmetic can be checked. It is not a case study or a promised return from a course.

Turn an analytics question into a prediction task

"Use AI to improve stock" is too broad to evaluate. A more useful brief is: predict next week's notebook demand for each shop, using only information known when its order is placed. The store manager uses that prediction to choose an order quantity.

Part of the brief A concrete choice Why you need it
Decision Weekly notebook order Defines what changes after prediction
Row One shop-week Sets the unit of observation
Target Units demanded in the following week Defines the numerical outcome
Inputs Earlier demand, known promotions and calendar information Makes prediction timing explicit
Baseline Repeat last week's quantity Represents a simple alternative
Evaluation Later weeks kept out of fitting Tests a future-facing use case
Review Shortage and surplus counts by shop Connects error to operations

Recorded sales can understate demand when a shop runs out. Before treating sales as the target, identify stockouts and decide what the available data can support. No model can recover unobserved demand simply because a column is named demand.

Work through a small decision example

Suppose true demand in a held-out teaching example is 30 notebooks. The old rule orders 20; a model recommends 35. Under our simplified assumptions, an unfilled unit has a penalty of 4 and an extra unit has a penalty of 1.

Approach Order Shortage Surplus Illustrative penalty
Existing rule 20 10 0 10 × 4 = 40
Model recommendation 35 0 5 5 × 1 = 5

The rule's absolute error is 10 units; the model's is 5. Here the model also has the lower illustrative penalty. But one week cannot establish a reliable improvement. Real ordering can involve carryover stock, delivery lead times, minimum order sizes and uncertain demand.

The example shows why you should record the consequences as well as error. If surplus were much more costly, the preferred order could change. The prediction is one input to the ordering policy, and a policy can apply buffers or limits before anyone acts.

Try it yourself: change the shortage penalty to 1 and the surplus penalty to 10. The old rule has penalty 10; the model recommendation has penalty 50. Explain why the same predictions lead to a different preference under these assumptions.

Choose an approach you can compare

Question Candidate approach First comparison
How many units next week? Regression or a forecasting method Last week or a seasonal rule
Which support requests need review? Classification or a ranking score Existing triage rule
Which shops behave similarly? Clustering A simple grouping by known attributes
Which transactions are unusual? Outlier detection Validation rules and fixed thresholds

These are different tasks. A clustering result does not automatically predict demand, and an unusual transaction is not automatically an error. Read predictive analytics, unlabeled data and outlier detection for worked examples of those distinctions.

For a first forecasting project, a simple model with a clear target and evaluation is easier to learn from than a complicated model with an ambiguous target. Add complexity only after inspecting the baseline's mistakes.

Build a data and evaluation checklist

First, write down when every column becomes available. A final weekly sales total cannot be an input to a prediction made before that week begins. Promotions are usable only if they were genuinely known at ordering time.

Next, check what rows are missing. A closed shop, a missing upload and a zero-demand week should not silently become the same value. The pandas project on daily trends shows why a missing date differs from a recorded zero.

Then separate fitting, model selection and final evaluation. Compare the model and baseline on the same dates, shop groups and outcome definition. Report errors by relevant subsets so a good average does not hide consistently poor results at a small shop.

Finally, define the review process before automated action. A manager should be able to identify unavailable inputs, implausible recommendations and changes in stock policy. Record overrides so you can examine whether a later evaluation still represents the process being used.

Common questions

Is machine learning required for business analytics?

No. Descriptive tables, queries, charts and explicit rules can answer many useful questions. ML becomes relevant when a prediction or pattern-finding task has suitable data and a way to evaluate its usefulness.

Which model should a beginner learn first?

For a numerical target, a mean baseline and a simple regression are a useful starting comparison. The linear regression tutorial gives a runnable arithmetic example before you attempt a business dataset.

Does a lower prediction error guarantee a better business outcome?

No. The action, constraints and consequences matter. The ordering example demonstrates this by changing only the penalties. An operational comparison also needs representative outcomes and enough observations to assess variation.

Learn the workflow in Python

Start with SchoolWhool's pandas module for cleaning and joining tables, and the Statistics track for variation, comparisons and uncertainty. The Python project articles are a practical first step if writing scripts is new.

Then use the Machine Learning track to plan model study.

Further reading

For evaluation designs, see scikit-learn's official time-series split example. The shop, predictions and penalty calculations above are original teaching examples.

First Principles, the SchoolWhool newsletter

One machine learning idea, explained properly, every week.

The intuition, the common mistake, and a five-minute way to try it yourself. Written by Gaurav.