Improve Model Performance
Use a historical backtest to improve a Kumo Relational workflow without changing the basis of comparison. A backtest asks the model to predict from an earlier point in time, then compares those predictions with outcomes that are already known. Change one factor at a time while keeping the entities, labels, and historical cutoff fixed so that changes in the score reflect the configuration you tested.
Before you begin, load the H&M transactions table into a pandas DataFrame, build its relational graph, and configure access to a Kumo Relational endpoint.
The examples reuse those objects throughout the workflow.
1. Define the task and ground truth
This example predicts total sales for each article_id during the seven days after an anchor time.
The anchor time is the historical cutoff that separates the data available to the model from the future period being predicted.
The evaluation includes only articles with sales during the preceding seven days.
The resulting labels DataFrame contains one known outcome, actual_value, for each eligible article_id.
Verify that the interval boundaries match your business definition before comparing model configurations.
2. Align PQL with the evaluation population
Store the Predictive Query Language (PQL) query in query so the same prediction task is used for every configuration:
The WHERE clause applies the same eligibility rule used to construct labels, so the query and ground truth cover the same population.
3. Run a key-aligned backtest
This backtest uses mean absolute error (MAE), the average absolute difference between each prediction and its known value. Lower MAE indicates better predictions for this task.
The merge joins predictions to labels by entity key instead of row position. This prevents a silent scoring error if the service returns predictions in a different order from the labels.
4. Tune one factor at a time
Compare configurations in the following order while keeping the evaluation set fixed. The order starts with the task definition, which often matters more than inference settings:
- Align the PQL target and filters with the production population.
- Compare the
fast,normal, andbestrun modes, which are presets for the amount of prediction context and the default relational neighborhood size. - Test task-relevant neighborhood settings as direct
predict()arguments to control how many related rows Kumo Relational samples through table relationships. - Test
use_prediction_timeonly when the calendar timestamp itself could provide a useful signal, such as seasonality. - Remove noisy columns or add well-justified relational signals.
Do not assume that a larger run mode or neighborhood will always improve accuracy. Measure latency, request size, and the selected task metric on representative data.
Control the context examples
Use predict_task() when you need direct control over the labeled examples supplied to Kumo Relational.
These examples provide context that the model uses to make a prediction.
Controlling them lets you test how context selection affects prediction quality without changing the graph or prediction task.
When comparing configurations:
- Keep the context and prediction entities fixed.
- Use labels that would have been available at prediction time.
- Compare the custom-context result with the standard PQL-based workflow.
- Do not assume manually selected context will perform better. Evaluate it using the same metric and historical anchor times.
5. Report reproducible results
Record the information needed to reproduce and compare each result:
- Dataset and code revisions
- Entity set and anchor times
- Label construction
- SDK and NVIDIA Inference Microservice (NIM) versions
- Query and prediction settings
- Evaluation metric
The exact H&M measurements previously shown on this page did not have a primary experiment artifact in this repository, so they have been removed rather than presented as reproducible benchmarks.