Coder Social home page Coder Social logo

revise_forecasts() method raises an attribute error. AttributeError: 'Series' object has no attribute 'yhat' about scikit-hts HOT 9 CLOSED

carlomazzaferro avatar carlomazzaferro commented on June 6, 2024
revise_forecasts() method raises an attribute error. AttributeError: 'Series' object has no attribute 'yhat'

from scikit-hts.

Comments (9)

carlomazzaferro avatar carlomazzaferro commented on June 6, 2024

This was due to bad assumptions on the format of the forecasts dict. It was assumed that it is a DataFrame with a single columns, named yhat.

This PR address it. Feel free to take a look, the tests should make it clear what the PR is achieving.

from scikit-hts.

aakashparsi avatar aakashparsi commented on June 6, 2024

Thanks for the update @carlomazzaferro.
I just want to clarify one thing here. So, according to the updated code, To revise the forecasts we have to pass the DataFrame with one column. Is that right?

from scikit-hts.

aakashparsi avatar aakashparsi commented on June 6, 2024

And, the same error pops up when using optimal_combination().
Here is the stack trace

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-152-a556a14422e8> in <module>
----> 1 optimal_combination(dict(pred[-4:]), sum_mat = htsmodel.sum_mat, method = 'OLS', mse = {} )

~/.conda/envs/lts/lib/python3.6/site-packages/hts/functions.py in optimal_combination(forecasts, sum_mat, method, mse)
    128 
    129     """
--> 130     hat_mat = y_hat_matrix(forecasts)
    131     transpose = np.transpose(sum_mat)
    132 

~/.conda/envs/lts/lib/python3.6/site-packages/hts/functions.py in y_hat_matrix(forecasts, keys)
     89         keys = forecasts.keys()
     90     first = list(forecasts.keys())[0]
---> 91     y_hat_mat = np.zeros([len(forecasts[first].yhat), 1])
     92     for key in keys:
     93         f1 = np.array(forecasts[key].yhat)

~/.conda/envs/lts/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'

from scikit-hts.

carlomazzaferro avatar carlomazzaferro commented on June 6, 2024

You should not use optimal_combination directly. The new function that perform sanitization on the inputs should transform whatever you pass as your forecasts to a format that should work with the revised = revision.revise(forecasts=forecasts, mse=errors, nodes=nodes) (optimal_combination gets called by this method).

Now, you should be able to pass as forecasts a dict of strings to either numpy.array (as long as the array has ndim == 1), pandas.Series or pandas.DataFrame (as long as the df has only one column).

But I suggest you to wait till tomorrow, as I'm still working on some further fixes to the convenience methods. You can track the progress here: #68

from scikit-hts.

aakashparsi avatar aakashparsi commented on June 6, 2024

Hey @carlomazzaferro, your quick response is appreciated. I'll check out #68 for further updates.

from scikit-hts.

carlomazzaferro avatar carlomazzaferro commented on June 6, 2024

Feel free to bump to scikit-hts 0.5.6, see updated convenience docs https://scikit-hts.readthedocs.io/en/latest/hts.html#module-hts.convenience

Thanks for your patience!

from scikit-hts.

aakashparsi avatar aakashparsi commented on June 6, 2024

Sure @carlomazzaferro. Also, It would be very helpful If you throw some light on #66.

from scikit-hts.

carlomazzaferro avatar carlomazzaferro commented on June 6, 2024

Yes, that is next on my task list and will tackle that together with the related issue about fixing the transforms functionality. Will keep posted when I have a PR in the works

from scikit-hts.

aakashparsi avatar aakashparsi commented on June 6, 2024

Sure @carlomazzaferro. I Wholeheartedly appreciate all your efforts on this. Thank you so much.

from scikit-hts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.