Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparse Methods Missing from 0.3.0 #234

Closed
tbellamey opened this issue Oct 3, 2023 · 3 comments
Closed

Sparse Methods Missing from 0.3.0 #234

tbellamey opened this issue Oct 3, 2023 · 3 comments
Labels

Comments

@tbellamey
Copy link

What happened + What you expected to happen

I attempted to import the BottomUpSparse and MinTraceSparse methods from hierarchicalforecast.methods

However, upon inspection of the class, I noticed that release 0.3.0 doesn't contain either of these sparse methods:
NAME
hierarchicalforecast.methods - # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/methods.ipynb.

CLASSES
HReconciler(builtins.object)
BottomUp
ERM
MiddleOut
MinTrace
OptimalCombination
TopDown

I used the standard pip install command: pip install hierarchicalforecast

Is there a different version that I should install to access these sparse methods?

Versions / Dependencies


dateutil 2.8.2
hierarchicalforecast 0.3.0
matplotlib 3.7.1
numpy 1.23.5
pandas 2.0.2
session_info 1.0.0
statsforecast 1.6.0


IPython 8.14.0
jupyter_client 8.2.0
jupyter_core 5.3.0
notebook 6.5.4

Python 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0]
Linux-4.18.0-372.16.1.0.1.el8_6.x86_64-x86_64-with-glibc2.35

Reproduction script

from hierarchicalforecast.methods import BottomUp, TopDown, MinTrace, ERM, OptimalCombination, MiddleOut, BottomUpSparse, MinTraceSparse

Issue Severity

Low: It annoys or frustrates me.

@jmoralez
Copy link
Member

jmoralez commented Oct 3, 2023

Hey @tbellamey, we just released 0.4.0. You should be able to use those methods if you upgrade your installation.

@tbellamey
Copy link
Author

Hi @jmoralez , I upgraded my installation to 0.4.0. However, upon running my script (no code changed), I am now getting the below error. This seems to be inducing an error in using StatsForecast AutoETS models now. I also tried StatsForecast HoltWinters and received the same error.

This error did not raise with the same dataset & script when running 0.3.0 - any ideas what might have changed the behavior from 0.3.0 to 0.4.0? I can also open this as a new issue for tracking.


NotImplementedError Traceback (most recent call last)
Cell In[8], line 109
98 #valid_agg_reset = valid_agg.reset_index()
100 model = StatsForecast(models=[
102 AutoETS(season_length=12,model='AAA',alias='AutoETS_AAA')
(...)
107 ],
108 freq='MS', n_jobs=1, verbose=True)
--> 109 model.fit(train_agg)
111 p = model.forecast(h=h_months, fitted=True)
112 p_fitted = model.forecast_fitted_values()

File ~/lib/python3.10/site-packages/statsforecast/core.py:880, in StatsForecast.fit(self, df, sort_df, prediction_intervals)
878 self.prepare_fit(df, sort_df)
879 if self.n_jobs == 1:
--> 880 self.fitted
= self.ga.fit(models=self.models)
881 else:
882 self.fitted
= self._fit_parallel()

File ~/lib/python3.10/site-packages/statsforecast/core.py:77, in GroupedArray.fit(self, models)
75 for i_model, model in enumerate(models):
76 new_model = model.new()
---> 77 fm[i, i_model] = new_model.fit(y=y, X=X)
78 return fm

File ~/lib/python3.10/site-packages/statsforecast/models.py:650, in AutoETS.fit(self, y, X)
628 def fit(
629 self,
630 y: np.ndarray,
631 X: Optional[np.ndarray] = None,
632 ):
633 """Fit the Exponential Smoothing model.
634
635 Fit an Exponential Smoothing model to a time series (numpy array) y
(...)
648 Exponential Smoothing fitted model.
649 """
--> 650 self.model_ = ets_f(
651 y, m=self.season_length, model=self.model, damped=self.damped
652 )
653 self.model_["actual_residuals"] = y - self.model_["fitted"]
654 self._store_cs(y=y, X=X)

File ~/lib/python3.10/site-packages/statsforecast/ets.py:1241, in ets_f(y, m, model, damped, alpha, beta, gamma, phi, additive_only, blambda, biasadj, lower, upper, opt_crit, nmse, bounds, ic, restrict, allow_multiplicative_trend, use_initial_values, maxit)
1238 # ses for non-optimized tiny datasets
1239 if n <= npars + 4:
1240 # we need HoltWintersZZ function
-> 1241 raise NotImplementedError("tiny datasets")
1242 # fit model (assuming only one nonseasonal model)
1243 if errortype == "Z":

NotImplementedError: tiny datasets

@jmoralez
Copy link
Member

jmoralez commented Oct 4, 2023

Closing since the original issue is solved.

@jmoralez jmoralez closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants