Backtest a forecast
POST /v1/forecast/backtest
apiKeyX-Spavik-Api-Key<token>Spavik integration API key (sk-spv-api-...), sent in X-Spavik-Api-Key.
User-Agent?stringInformation about the agent originating the request, when known. Browsers supply their own value. Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 1024X-Spavik-Client-Name?stringHTTP caller: SDK, MCP server or direct application (for example spavik-sdk-python, spavik-sdk-javascript or spavik-mcp). Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 128X-Spavik-Client-Version?stringVersion of that SDK, MCP server or direct application. Optional diagnostic metadata, declared by the caller and never used for authorization. Omit unknown values. Values are trimmed and truncated to the documented length.
length <= 64- body
engine_family?stringEngine family for this call. Omitted: the family marked is_default in GET /v1/engine-families. No persisted model is used. engine_version must belong to this family, including when the family is omitted.
"flair""presage""prophecy"engine_version?stringFull engine identifier within the selected family, e.g. presage-2 or presage-latest. Omitted or -latest: latest active version of that family. A different family is refused. Responses identify the exact version used.
^(flair|presage|prophecy)-(latest|[1-9][0-9]*(\.[0-9]+)?)$length <= 64backtest?booleanEvaluate historical windows on POST /v1/forecast. The dedicated backtest route always evaluates.
falseinclude_backtest_predictions?booleanReturn the historical observations already evaluated by the backtest, without additional inference or credits. On POST /v1/forecast, also set backtest=true. Does not force a skipped or disabled backtest to run. Detail is always JSON.
falsetarget*stringhorizon?integerNumber of future steps (alias: prediction_length).
1 <= value <= 1000data*array<>Data rows, one object per row.
timestamp?stringTimestamp column (inferred when omitted).
quantiles?array<number>item_id?stringColumn identifying several series. Each series is forecast on its own history only.
point_estimate?stringStatistic served in _prediction (defaults to mean).
"mean""median"Success
application/json- response
target?stringtimestamp?stringitem_id?stringhorizon?integer1 <= value <= 1000point_estimate?string"mean""median"n_rows?integercolumns?array<string>validation?assessment*The single API conclusion, always present and non-null in HTTP 200 responses, including when the trial cannot run. Forward status, metric and message without recomputing them from scores. An absent or null assessment is a contract violation, not an inconclusive result. This is a descriptive comparison on the evaluated observations: better means strictly better than every required reference; equality is not better. No fixed gain or sample-size threshold implies significance. Inconclusive means missing or invalid evidence, or a skipped backtest; not_evaluated means validation prevented the trial. No status establishes reliability, future performance or absence of predictive signal.
hint?stringbacktest?import requestsurl = "https://api.spavik.co/v1/forecast/backtest"body = """{ "engine_family": "presage", "target": "ventes", "horizon": 7, "data": [ { "date": "2026-07-01", "ventes": 100 }, { "date": "2026-07-02", "ventes": 112 }, { "date": "2026-07-03", "ventes": 118 }, { "date": "2026-07-04", "ventes": 121 }, { "date": "2026-07-05", "ventes": 130 }, { "date": "2026-07-06", "ventes": 84 }, { "date": "2026-07-07", "ventes": 72 }, { "date": "2026-07-08", "ventes": 105 }, { "date": "2026-07-09", "ventes": 117 }, { "date": "2026-07-10", "ventes": 123 }, { "date": "2026-07-11", "ventes": 126 }, { "date": "2026-07-12", "ventes": 135 }, { "date": "2026-07-13", "ventes": 89 }, { "date": "2026-07-14", "ventes": 77 }, { "date": "2026-07-15", "ventes": 110 }, { "date": "2026-07-16", "ventes": 122 }, { "date": "2026-07-17", "ventes": 128 }, { "date": "2026-07-18", "ventes": 131 }, { "date": "2026-07-19", "ventes": 140 }, { "date": "2026-07-20", "ventes": 94 }, { "date": "2026-07-21", "ventes": 82 }, { "date": "2026-07-22", "ventes": 115 }, { "date": "2026-07-23", "ventes": 127 }, { "date": "2026-07-24", "ventes": 133 }, { "date": "2026-07-25", "ventes": 136 }, { "date": "2026-07-26", "ventes": 145 }, { "date": "2026-07-27", "ventes": 99 }, { "date": "2026-07-28", "ventes": 87 } ]}"""response = requests.request("POST", url, data = body, headers = { "Content-Type": "application/json"})print(response.text){ "target": "string", "timestamp": "string", "item_id": "string", "horizon": 1, "point_estimate": "mean", "n_rows": 0, "columns": [ "string" ], "validation": {}, "assessment": { "status": "better_than_baseline", "metric": "AUC", "message": "string" }, "hint": "string", "backtest": { "engine": "string", "metrics": { "AUC": 0, "Accuracy": 0, "AveragePrecision": 0, "LogLoss": 0, "MacroF1": 0, "MAE": 0, "RMSE": 0, "R²": 0, "MASE": 0, "Bias": 0, "BiasRatio": 0, "Pinball": 0, "property1": 0, "property2": 0 }, "baselines": { "property1": { "floor": 0, "class_order": [ "string" ], "probabilities": [ 0 ], "undefined_reason": "string", "relative_error_reduction": 0, "reduction_undefined_reason": "string", "label": "string", "higher_better": true, "fit_on": "train", "prediction": 0, "constant_floor": 0, "constant_label": "string" }, "property2": { "floor": 0, "class_order": [ "string" ], "probabilities": [ 0 ], "undefined_reason": "string", "relative_error_reduction": 0, "reduction_undefined_reason": "string", "label": "string", "higher_better": true, "fit_on": "train", "prediction": 0, "constant_floor": 0, "constant_label": "string" } }, "evaluation": { "metric_context": { "undefined_reasons": { "property1": "string", "property2": "string" }, "class_order": [ "string" ], "positive_class": "string", "auc_average": "binary", "average_precision_method": "non_interpolated", "macro_f1_average": "unweighted_defined_classes", "log_loss_epsilon": 0 }, "protocol_version": 0, "interpretation": "descriptive_only", "kind": "rolling_origin", "requested": true, "n_input": 0, "n_missing_target": 0, "sampling": "none", "horizon": 0, "max_windows": 0, "min_context": 0, "window_order": "oldest_to_newest", "mase_weighting": "equal_series_then_equal_points_within_series", "other_metrics_weighting": "equal_evaluated_points", "mase_n_series": 0, "mase_n_eval": 0, "series": [ { "series": "string", "n_points": 0, "seasonal_period": 1, "mase_scale": 0, "n_windows": 0, "n_eval": 0, "scale_context_start": "string", "scale_context_end": "string", "scale_n_context": 0, "backtest_excluded_reason": "string", "mase_excluded_reason": "string" } ], "windows": [ { "series": "string", "window": 0, "n_context": 0, "n_eval": 0, "context_end": "string", "test_start": "string", "test_end": "string" } ] }, "intervals": { "nominal": 0, "observed": 0, "lower": 0, "upper": 0, "evaluated_count": 0, "average_width": 0, "width_unit": "target", "undefined_reason": "string" }, "predictions": [ { "series": "string", "window": 0, "timestamp": "string", "actual": 0, "prediction": 0, "naive_prediction": 0, "constant_prediction": 0, "quantiles": { "property1": 0, "property2": 0 } } ], "by_window": [ 0 ], "naive_by_window": [ 0 ], "constant_by_window": [ 0 ], "n_series": 1, "n_windows": 1, "n_eval": 1, "n_context": 1, "seasonal_period": 1, "skipped": "string", "warnings": [ "string" ] }}How is this guide?
Last updated on