Budget vs actual variance is something Finance reviews every month. The calculation itself is straightforward. The difficult part is explaining why the actual amount is different from the budget.
For example, IT Software expenses may exceed budget because of additional licenses, Travel expenses may increase during a particular quarter, or Contractor expenses may fall because some planned positions remain unfilled.
A normal variance report shows where the difference exists. It does not always explain which combinations of account, department, region and period are associated with that difference.
I am testing whether a small decision tree can help identify these patterns and convert them into simple rules that Finance can review.
The experiment uses synthetic budget and actual data structured like an Oracle EPM Planning extract. The analysis runs in Python, not inside Oracle EPM Cloud.
Starting with the variance data
I generate 576 records across four departments: Sales, Technology, Operations and Finance.
The data also includes four expense accounts — Travel, IT Software, Facilities and Contractors — along with three regions and four quarters.
Each department, account, region and quarter combination contains three generated observations.
The notebook calculates a budget amount for each record and then generates the actual amount using a variance percentage.
For the calculation, I use:
Variance % = (Actual / Budget − 1) × 100
A positive result means actual expense exceeds budget. A negative result means actual expense is below budget.
I deliberately introduce a few spending patterns into the generated data.
Sales travel expenses receive an additional 22 percentage points of variance in Q3 and Q4. IT Software expenses receive an additional 18 percentage points in Q4 to represent a possible licensing adjustment. Contractor expenses in the South region receive a negative adjustment of 12 percentage points to represent a hiring freeze.
The remaining records contain random variation.
These are assumptions used to create the experiment. They are not observed financial events.
The question is whether the decision tree can identify these patterns from the data without being given the underlying generation rules.
What appears in the actual versus budget comparison

The first chart compares actual expenses against budget by account.
| Account | Actual vs Budget |
|---|---|
| IT Software | +4.6% |
| Travel | +2.5% |
| Facilities | +0.3% |
| Contractors | −3.5% |
IT Software has the highest overall overspend, followed by Travel.
Contractors show an underspend of approximately 3.5%.
These percentages are calculated using total actual divided by total budget for each account. They are not simple averages of the individual record percentages.
The results are consistent with the patterns introduced in the data.
For example, IT Software has additional variance in Q4. Contractor expenses have a negative adjustment in the South region, reducing the overall account variance.
However, the account-level chart does not show where those differences are concentrated.
That becomes clearer when looking at departments and quarters.
Sales looks different in Q4
The second chart shows average variance percentages by department and quarter.
Most departments have relatively small differences during Q1, Q2 and Q3.
Q4 is different.
| Department | Q3 | Q4 |
|---|---|---|
| Sales | +4.2% | +9.1% |
| Technology | −0.8% | +4.1% |
| Operations | −1.3% | +3.9% |
| Finance | −1.5% | +2.9% |
Sales has the largest Q4 variance at approximately 9.1%.
Technology, Operations and Finance also show positive Q4 variances, although they are smaller.
The heatmap uses an average of the line-level variance percentages, rather than calculating a percentage from aggregated budget and actual amounts. This is why its results are not directly interchangeable with the account totals in the first chart.
The pattern raises a useful question.
Is Q4 overspending common across all accounts, or is it concentrated in particular combinations of accounts and departments?
That is where the decision tree becomes useful.
Building a decision tree that stays readable
I use DecisionTreeRegressor from scikit-learn.
The model takes four categorical fields as inputs: Department, Account, Region and Quarter.
I convert these fields into numeric indicator columns using one-hot encoding.
The target is the calculated variance percentage for each record.
I configure the tree with a maximum depth of four and a minimum of 20 records per leaf.
The depth limit is intentional.
A very deep tree may capture more individual differences, but the resulting rules can become difficult to review.
Here, the objective is to find a manageable set of patterns that can be explained in ordinary business terms.
After fitting the tree, I export its rules as text.
The model produces an R² score of 0.560, or approximately 56%.
This means the tree accounts for about 56% of the statistical variation in the line-level variance percentages across the same 576 records used to train it.
It does not mean the tree explains 56% of the total monetary budget variance. It is also not a measured prediction score on unseen data.
The notebook does not use a separate test dataset for this experiment.
What the tree identifies
The third chart shows which account, region, quarter and department indicators the tree uses most.
IT Software has the highest feature importance at approximately 28%.
The South region contributes around 21%, followed by Q4 at approximately 20% and Contractors at 19%.
These values describe how much the fitted decision tree uses each variable to reduce prediction error.
They are not independent measures of financial impact or proof of business causes.
The rules in the fourth panel are more interesting because they show the combinations behind the model’s predictions.
For example, one branch identifies IT Software in Q4 and produces an estimated average variance of approximately +17.5%.
Another identifies Contractors in the South region and produces approximately −11.1%.
The tree also identifies Sales Travel outside Q4 with an estimated average variance of approximately +7.8%.
These rules are consistent with the patterns I use to generate the synthetic data.
The Q4 IT Software rule reflects the additional licensing-related variance. The South Contractor rule reflects the negative adjustment for the simulated hiring freeze.
The model does not know those business explanations. It only identifies combinations of fields that have different average variance percentages.
That distinction matters.
A decision tree can show that IT Software expenses in Q4 have a high variance. It cannot confirm that the actual reason is a license renewal without supporting transaction or planning information.
Turning the rules into finance commentary
This is where the result starts to become useful for FP&A.
Instead of reviewing hundreds of variance records individually, Finance can begin with the combinations showing the largest consistent differences.
For example, the analysis might identify an account and quarter with unusually high spending.
The next step is to examine the underlying expense records, planning assumptions and business activity for that intersection.
If the data shows additional software licenses purchased during Q4, the commentary can explain the variance using that supporting information.
The decision tree helps locate the pattern. The explanation still needs to be confirmed.
Oracle EPM Planning already supports actual versus plan comparisons through forms, dashboards and reports. Oracle Narrative Reporting also supports preparing financial commentary and management reporting packages.
A Python model like this can be an additional analytical step when Finance wants to examine many account, department, region and period combinations.
The process starts with an authorized export of budget and actual values from the planning application.
The extract needs consistent accounts, entity or cost center members, periods, currencies, scenarios and versions.
Python can then calculate the variance percentages, fit the tree and produce a review report showing the important combinations and their average differences.
That output can support variance commentary preparation.
It does not automatically explain the accounting transactions or replace the commentary already prepared by Finance.
The notebook does not connect to Oracle EPM, extract live planning data or publish comments into Narrative Reporting.
Why the 56% needs another test
The tree identifies several patterns that I deliberately introduce into the generated data.
That is encouraging, but it also makes the result easier to interpret than a real planning dataset.
Actual financial variances can contain many overlapping factors, including pricing changes, timing differences, cost allocations, project expenses and incorrect mappings.
A decision tree may identify the combinations associated with those differences without finding the underlying causes.
There is also a validation limitation.
The 56% R² is calculated on the training data. A model can fit the available records reasonably well and still perform poorly on new periods.
The next test needs a separate dataset or historical periods that are not used during training.
The tree should also be compared with simpler methods, such as ranking material variances by account and department or applying existing business thresholds.
Another important change is including the financial amount of each variance.
A 15% variance on a small expense may be less important than a 3% variance on a large account.
For management reporting, both percentage and absolute variance need attention.
The useful part of this experiment
The decision tree identifies several combinations that match the patterns built into the data.
IT Software in Q4, Contractor expenses in the South region and Sales Travel all appear in the extracted rules.
The tree captures approximately 56% of the line-level percentage variation using a relatively small set of conditions.
That makes the results readable, which is the main reason I use a shallow tree for this experiment.
But the output is still a statistical description of the data, not verified root-cause analysis.
The practical value is in narrowing down where Finance needs to investigate.
If a variance review starts with hundreds of records, a short list of relevant account, department, region and quarter combinations can help organize the analysis.
The commentary becomes reliable only after those patterns are checked against the underlying business activity.
All budget and actual values are synthetic. This experiment does not contain real Oracle EPM Cloud or client financial data.