carlomazzaferro / scikit-hts-examples

Example usage of scikit-hts
MIT License
53 stars 22 forks source link

revise_forecasts() method raises an attribute error. AttributeError: 'Series' object has no attribute 'yhat' #13

Closed aakashparsi closed 3 years ago

aakashparsi commented 3 years ago

I want to revise my base forecasts, so wanted to use revise_forecasts() method but got an error like this. This is entire stack trace.

AttributeError                            Traceback (most recent call last)
<ipython-input-191-307987f74b26> in <module>
----> 1 revise_forecasts(method = 'FP', forecasts = pred, summing_matrix = sum_mat, nodes = hierarchyNodes)

/home/Gopal/anaconda/envs/time_series/lib/python3.6/site-packages/hts/convenience.py in revise_forecasts(method, forecasts, errors, residuals, summing_matrix, nodes, transformer)
     63     )
     64 
---> 65     revised = revision.revise(forecasts=forecasts, mse=errors, nodes=nodes)
     66 
     67     return pandas.DataFrame(revised, columns=list(forecasts.keys()))

/home/Gopal/anaconda/envs/time_series/lib/python3.6/site-packages/hts/revision.py in revise(self, forecasts, mse, nodes)
     74 
     75         elif self.name == MethodT.FP.name:
---> 76             return forecast_proportions(forecasts, nodes)
     77 
     78         else:

/home/Gopal/anaconda/envs/time_series/lib/python3.6/site-packages/hts/functions.py in forecast_proportions(forecasts, nodes)
    196 
    197     key = choice(list(forecasts.keys()))
--> 198     new_mat = np.empty([len(forecasts[key].yhat), n_cols - 1])
    199     new_mat[:, 0] = forecasts[key].yhat
    200 

/home/Gopal/anaconda/envs/time_series/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
   5137             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5138                 return self[name]
-> 5139             return object.__getattribute__(self, name)
   5140 
   5141     def __setattr__(self, name: str, value) -> None:

AttributeError: 'Series' object has no attribute 'yhat'

What could be the best fix for this problem?

carlomazzaferro commented 3 years ago

Hi, would you mind sharing:

so that we can better troubleshoot this?

aakashparsi commented 3 years ago

@carlomazzaferro

  1. scikit-hts==0.5.4
  2. Sorry, I can share my hierarchyNodes.
  3. preds.head(4) looks something like this.

image

carlomazzaferro commented 3 years ago

would you mind opening an issue at https://github.com/carlomazzaferro/scikit-hts ? this seems to be related to the package, not to the examples