-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Labels
Description
What happened + What you expected to happen
Observed behavior: many reconciled bootstrap samples are negative even when nonnegative = True in the hierarchicalforecast.methods and despite base forecasts and prediction intervals being positive.
Expected behavior: strictly positive values of reconciled bootstrap samples when nonnegative = True.
No warnings or error messages were returned.
Versions / Dependencies
Python version: '3.10.18 (main, Sep 2 2025, 14:15:06) [MSC v.1944 64 bit (AMD64)]'
pandas v2.3.2
hierarchicalforecast v1.2.1
Reproduction script
summing_matrix.csv
yfitted_df.csv
yhat_df.csv
import pandas as pd
import hierarchicalforecast.core as hf_core
import hierarchicalforecast.methods as hf_methods
# Load example data
tags = {
"Country": ["Canada"],
"Country/Province": ["Canada/Ontario"],
"Country/Province/City": ["Canada/Ontario/Ottawa", "Canada/Ontario/Kingston"]
}
summing_matrix = pd.read_csv("summing_matrix.csv")
yhat_df = pd.read_csv("yhat_df.csv")
yfitted_df = pd.read_csv("yfitted_df.csv")
# Reconcile
hrec = hf_core.HierarchicalReconciliation(
reconcilers = [hf_methods.MinTrace(nonnegative = True, method = 'mint_shrink')]
)
yrec_df = hrec.reconcile(
Y_hat_df = yhat_df,
Y_df = yfitted_df,
S = summing_matrix,
tags = tags,
level = [90],
intervals_method = "bootstrap",
num_samples = 1000,
seed = 1,
id_col = "UniqueId",
time_col = "Date",
target_col = "Quantity"
)
Issue Severity
High: It blocks me from completing my task.