Summary
HyperTreeNetAR.forecast currently passes NumPy arrays to LightGBM prediction:
self.model.predict(test_data[self.features].values)
This drops pandas dtype metadata. In particular, pandas category columns lose their categorical dtype, so LightGBM cannot use its built-in categorical handling consistently at prediction time.
The other model forecast paths (HyperTreeAR, HyperTreeETS, and HyperTreeSTL) pass pandas DataFrames into LightGBM prediction, so this is also an API consistency issue.
Reproduction
Train HyperTreeNetAR with a pandas categorical feature:
train["item"] = train["item"].astype("category")
test["item"] = test["item"].astype("category")
model = HyperTreeNetAR(p=6, freq="M", fcst_h=3)
model.train(
lgb_params={"learning_rate": 0.05, "num_leaves": 5},
network_params={
"learning_rate": 0.01,
"hidden_dim": 16,
"embedding_dimension": 4,
"use_random_projection": False,
"rp_embed_dim": None,
"dropout": 0.05,
},
gradient_mode="separate",
num_iterations=5,
train_data=train,
validation=False,
)
model.forecast(test_data=test)
The training path creates LightGBM datasets from pandas DataFrames, preserving categorical columns. The forecast path converts the feature DataFrame to .values, which strips that information.
Expected behavior
HyperTreeNetAR.forecast should preserve pandas categorical dtypes for LightGBM prediction, matching the other model classes.
Suggested fix
Change:
self.model.predict(test_data[self.features].values)
to:
self.model.predict(test_data[self.features])
and add a regression test asserting the LightGBM predict input remains a pandas DataFrame.
I can open a PR with this small patch.
Summary
HyperTreeNetAR.forecastcurrently passes NumPy arrays to LightGBM prediction:This drops pandas dtype metadata. In particular, pandas
categorycolumns lose their categorical dtype, so LightGBM cannot use its built-in categorical handling consistently at prediction time.The other model forecast paths (
HyperTreeAR,HyperTreeETS, andHyperTreeSTL) pass pandas DataFrames into LightGBM prediction, so this is also an API consistency issue.Reproduction
Train
HyperTreeNetARwith a pandas categorical feature:The training path creates LightGBM datasets from pandas DataFrames, preserving categorical columns. The forecast path converts the feature DataFrame to
.values, which strips that information.Expected behavior
HyperTreeNetAR.forecastshould preserve pandas categorical dtypes for LightGBM prediction, matching the other model classes.Suggested fix
Change:
to:
and add a regression test asserting the LightGBM predict input remains a pandas
DataFrame.I can open a PR with this small patch.