Zero Labs
Industry News / AI

When not Modeling is the Pragmatic Decision

Source · Towards AI By Juan Luis German Saura

From the publisher’s feed, collected in the ZeroLabs newsroom.

An anonymized forecasting case reconstructed with synthetic data: regime shifts, pretrained models and production judgmentPhoto by Nicholas Cappelo on UnsplashA few months ago I was involved in a business forecasting MLOps project. There were several time series and most of them were successfully modeled using tree-based models, except for one, which was constantly producing negative R² values. To put it into perspective, when R² is briefly covered in courses, it is presented as ranging from 0 to 1, so how could it be negative?Something was clearly off, and the first instinct was to keep pushing for other alternatives such as changing models, variables, and hyperparameters. All of them were failures, but where was the underlying issue?This article is based on an anonymized business forecasting case. Since I cannot share proprietary data, I reproduce the failure mode with synthetic monthly data and use it to discuss the diagnostic path. The full example is available on GitHub.Why a negative R² mattersR² is a regression performance metric that measures the proportion of variance in a dependent variable (target) that can be explained by the independent variables (predictors) in a model. Therefore, this metric can measure how well the prediction fits the target data [1, 2]. The formula is shown below:where SSE is the sum of squared errors (residuals) of the model and SST is the total sum of squares around the mean. [1]An R² of 1 shows that the fit is perfect. Meanwhile, a negative R² means that, under that evaluation window, the model performs worse than a constant baseline that simply predicts the mean of the observed target values. [1, 2]Recreating the failure: the synthetic time seriesTo recreate the scenario as closely as possible without breaking the privacy constraints, I created a monthly time series spanning roughly a decade.Approximately 70% of the series belonged to the stable regime, while the remaining 30% belonged to the crisis regime. The synthetic series includes an extreme spike around the transition point, followed by a persistent higher-volatility regime. As the case comes from the energy sector, it also preserves volatility even in the so-called “stable” regime.The goal of the notebook example is to recreate the complex conditions that led to the failure pattern, not to create a faithful business reproduction.Source: author-generated from the notebook synthetic data. No proprietary data shown.Source: author-generated from the notebook synthetic data. No proprietary data shown.Going back to the basic assumptionsAt the beginning of the profiling phase, the most useful decision was to return to the basics. I revisited the EDA: outliers, autocorrelation, stationarity, distribution shape, tail behavior, and white-noise diagnostics. Taken in isolation, none of them made the series look impossible to model. The signal was complex, but not hopeless at first glance.Stationarity is especially important because many time-series methods implicitly assume that the statistical properties of the process remain stable over time: roughly speaking, a stable mean, a stable variance and an autocorrelation structure that depends on lag rather than on calendar time. [3]Thus, the first warning came from the stationarity tests. ADF and KPSS are useful together because they approach that question from opposite null hypotheses. ADF tests the null hypothesis that the series has a unit root, which is usually interpreted as evidence of non-stationarity, while KPSS does the opposite with its null hypothesis, testing if the series is stationary around a constant or deterministic trend.from statsmodels.tsa.stattools import adfuller, kpssadf_stat, adf_pvalue, *_ = adfuller(y, autolag="AIC")kpss_stat, kpss_pvalue, *_ = kpss(y, regression="c", nlags="auto")print(f"ADF p-value: {adf_pvalue:.3f}")print(f"KPSS p-value: {kpss_pvalue:.3f}")ADF p-value: 0.070KPSS p-value: 0.010The ADF result also needed caution. With a p-value of 0.07, it failed to reject the unit root hypothesis, although being close to the 0.05 threshold discouraged any categorical interpretation. Combined with the KPSS result and the visual behavior of the series, this was not a clean stationarity story.ADF and KPSS did not provide a fully decisive interpretation, which suggested that the usual stationary versus non-stationary question might be too narrow for this series. That’s why these tests can be difficult to interpret in the presence of structural breaks, and the evidence was pointing to that hypothesis [4].From ambiguous tests to structural break: Zivot-AndrewsTo overcome the limitations of ADF and KPSS as stationarity tests, Zivot-Andrews was the chosen statistical method.Zivot-Andrews extends the unit-root testing framework by allowing the evaluation of whether the series is stationary while considering one endogenous break. In practical terms, it helps test whether a series that appears non-stationary may actually be stationary around a changing intercept, trend, or both. [5]za_stat, za_pvalue, _, za_lags, za_break = zivot_andrews(y, regression="ct")print(f"Test statistic: {za_stat:.3f} | p-value: {za_pvalue:.3f} | lags: {za_lags}")Test statistic: -8.313 | p-value: 0.001 | lags: 3The result supported the structural-break hypothesis in the synthetic series, due to rejecting the unit root null under the break-adjusted specification. That did not fully explain the process yet, but it changed the investigation.The Markov regression: from structural break to regime switchingThis is the moment Markov Regression becomes useful. Now, the exploratory analysis centered around whether the data process could be better framed as either a regime change (temporary and recurring parameters) or as a structural break (non-recurring and permanent shifts) [6].To explore this, the MarkovRegression implementation from statsmodels was used to fit a two-regime model to the synthetic series. [7]# Start values only stabilize the optimizer; all final parameters are estimatedfit = MarkovRegression(y, k_regimes=2, trend="c", switching_variance=True).fit( start_params=[0.98, 0.02, *np.quantile(y, [0.25, 0.75]), y.var() / 4, y.var()], method="lbfgs",maxiter=500, em_iter=0, cov_type="robust", disp=False)Source: author-generated from the notebook synthetic data. No proprietary data shown.The fitted model gave a plausible explanation of the previous evidence. The synthetic series was better described by two regimes: a more stable regime and a crisis-like regime. The transition point aligned with the visible shock in the plot; the estimated dispersion in the crisis-like regime was substantially higher than in the previous regime, and the probability of remaining in that regime once the series entered it was above 80%.The model also assigns high crisis-regime probability to an earlier isolated shock, before the persistent transition around 2023.Hence, the relevant question had to evolve again. From that point onward, the issue was not only whether a model could be fitted, but whether the recent and unstable regime could provide enough evidence to trust a forecast in production.Benchmarking the different forecasting alternativesUnder these circumstances, a small set of alternatives was chosen to be evaluated. Sorted by increasing modeling complexity: a naive last-value predictor [8], classical linear regression [9], an XGBoost regressor [10] and Chronos-T5-mini, a pretrained forecasting model used for zero-shot inference (50 sampled forecast paths, using the median forecast) [11]. Each model represented a different forecasting family, from simple baselines to modern foundation models.The experimental configuration was simple and it was applied across all models. The first 70% of the data (the stable regime) was used as training for the supervised models or context for Chronos-T5-mini while the remaining 30% (the crisis regime) was used as the evaluation period. The split was strictly chronological to avoid data leakage. Linear Regression and XGBoost were trained as univariate autoregressive forecasters using the previous 12 monthly values as predictors. During multi-step forecasting, predictions were generated recursively, meaning that each predicted value was fed back as input for the following step.With the setup ready, the question was if changing the model family could overcome a severe regime shift when the available historical context came predominantly from the previous regime.https://medium.com/media/7d22cda5f15bb899d23bc1a3ebcdd6d4/hrefSource: author-generated from the notebook synthetic data. No proprietary data shown.Overall, the results were unsatisfactory across the board. Every model produced a negative R², meaning that none of them improved over the mean-based reference under this evaluation. No model showed enough improvement to turn the forecast into a reliable production candidate.The benchmark was not designed to prove that these models are weak. It was designed to test whether changing the modeling family was enough under a regime-shift scenario. In this setup, it was not.The capabilities and limitations of pretrained forecasting modelsIt is worth noting that pretrained forecasting models are one of the most recent directions in time-series forecasting. Models such as Chronos, TimesFM and TimeGPT adapt the transformer-based architectures to time series. [11, 12, 13]Because they are pretrained on large and diverse time-series datasets, they can be used in zero or few-shot inference, which makes them especially attractive when specific data is scarce. They can also reduce the initial amount of specific preprocessing and feature engineering to obtain a first viable forecast, and in some benchmarks, they show competitive performance against traditional statistical and deep-learning forecasting methods. [11, 12, 13, 14]That being said, this does not make them a universal answer. Once these forecasting models are introduced in a production environment, depending on the deployment architecture, usual engineering constraints like privacy, inference cost, monitoring and explainability may still apply. In a regime-shift scenario, a pretrained model may produce a forecast, but that is not the same as proving that the forecast is stable enough to support operational decisions. [14]Therefore, pretrained forecasting models can be highly useful within the right context, but they do not remove the need to diagnose the data-generating process. In this case, the bottleneck was not only model capacity; it was whether the recent regime contained enough reliable evidence to justify a production forecast.The final production decisionComing back to the synthetic example, the analysis revealed that the new regime in the time series was short, volatile and difficult to validate. A small set of models were selected to represent the main forecasting approaches. However, none of them met the requirements needed for a safe production deployment.The reconstruction illustrates the same failure pattern that informed the original production discussion. In the real project, the available evidence ultimately led us to remove this forecasting component from scope. The decision was not based on a lack of experimentation, but on the evidence that suggested that the operational risk was too high and the expected trust in the forecast was too low.Conclusion: a prediction is not permission to deployWhen a model fails badly, it is not always because of a lack of complexity. Fast experimentation is valuable only when there is a clear hypothesis behind it. Otherwise, it quickly becomes a random search.Modern forecasting tools make it easier than ever to generate another prediction. While that is useful, it also makes undirected experimentation easier.That is why engineering judgment matters. An LLM, an AutoML system or a forecasting foundation model can suggest another experiment, another feature set or another architecture. But the responsibility of deciding whether the evidence is strong enough for production still belongs to the human team.Sometimes the most valuable output of a machine learning workflow is not a prediction, but preventing an unreliable prediction from becoming a real-world action.References[1] scikit-learn, “r2_score.” https://scikit-learn.org/stable/modules/generated/sklearn.metrics.r2_score.html[2] Wikipedia, “Coefficient of determination.” https://en.wikipedia.org/wiki/Coefficient_of_determination[3] statsmodels, “Stationarity and detrending: ADF/KPSS.” https://www.statsmodels.org/stable/examples/notebooks/generated/stationarity_detrending_adf_kpss.html[4] Aptech, “Unit Root Tests with Structural Breaks.” https://www.aptech.com/blog/unit-root-tests-with-structural-breaks/[5] statsmodels, “zivot_andrews.” https://www.statsmodels.org/dev/generated/statsmodels.tsa.stattools.zivot_andrews.html[6] Aptech, “Introduction to Markov-Switching Models.” https://www.aptech.com/blog/introduction-to-markov-switching-models/[7] statsmodels, “MarkovRegression.” https://www.statsmodels.org/stable/generated/statsmodels.tsa.regime_switching.markov_regression.MarkovRegression.html[8] R. J. Hyndman and G. Athanasopoulos, “Some simple forecasting methods.” Forecasting: Principles and Practice. https://otexts.com/fpp3/simple-methods.html[9] scikit-learn, “LinearRegression.” https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html[10] XGBoost, “XGBRegressor API.” https://xgboost.readthedocs.io/en/stable/python/python_api.html#xgboost.XGBRegressor[11] A. F. Ansari et al., “Chronos: Learning the Language of Time Series” (2024), Amazon Science. https://www.amazon.science/publications/chronos-learning-the-language-of-time-series[12] A. Das et al., “TimesFM-3: A zero-shot foundation model for multivariate forecasting” (2026), Google Research. https://research.google/blog/timesfm-3-a-zero-shot-foundation-model-for-multivariate-forecasting/[13] A. Garza et al., “TimeGPT-1” (2023), arXiv. https://arxiv.org/abs/2310.03589[14] “Scaling transformers for time series forecasting: do pretrained large models outperform small-scale alternatives?” (2026), Artificial Intelligence Review. https://link.springer.com/article/10.1007/s10462-025-11481-7When not Modeling is the Pragmatic Decision was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.