Skip to content

forecast() takes 1 positional argument but 2 were given #3

Open

Description

@muhdzubair

Hi, I am tryin to run this code but it is throwing error on forecast function

`gm11 = grey.gm11

gm11.add_pattern(223.3, "a1")
gm11.add_pattern(227.3, "a2")
gm11.add_pattern(230.5, "a3")
gm11.add_pattern(238.1, "a4")
gm11.add_pattern(242.9, "a5")
gm11.add_pattern(251.1, "a6")

gm11.forecast(2) # Default is 1, the parameter means how many next moments need to forcast continually.


TypeError Traceback (most recent call last)
in
14 gm11.add_pattern(df_mbu_p2.loc[1]['M1'], "M1")
15
---> 16 gm11.forecast(1)

TypeError: forecast() takes 1 positional argument but 2 were given`

Activity

  1. RSerSYQ commented on Jan 8, 2021

    @RSerSYQ

    Did you solve this question?I have met the same question, thanks!

  2. Kalvar commented on Jan 8, 2021

    @Kalvar
    Owner

    Hi, It works for:
    gm11.period = 2
    gm11.forecast()

    And thanks to open an issue to inform me this jotting code, I will find another time to optimize the algorithm.

  3. muhdzubair commented on Jan 11, 2021

    @muhdzubair
    Author

    Hi, It works for:
    gm11.period = 2
    gm11.forecast()

    And thanks to open an issue to inform me this jotting code, I will find another time to optimize the algorithm.

    Yes it worked! 😊

    Now I am wondering how to get forecast values as print_forecasted_results() only print original and forecast values from self.analyzed_results as checked in grey_class.py

    @Kalvar if you can guide. Thanks.

  4. no-trick-pony commented on Feb 19, 2021

    @no-trick-pony

    @muhdzubair

    Now I am wondering how to get forecast values as print_forecasted_results() only print original and forecast values from self.analyzed_results as checked in grey_class.py

    If you look at the gm11 class and the forecast method there, you will see that it returns the output of the internal __forecast method, which is an array of grey_forecast objects - see: https://github.com/Kalvar/python-GreyTheory/blob/master/greytheory/packages/models/grey_forecast.py

    So you can simply do:

    results = gm11.forecast()
    
    for r in results:
        print(r.forecast_value)
    

    gm11 also stores the result internally, so you could also do:

    gm11.forecast()
    
    for r in gm11.analyzed_results:
        print(r.forecast_value)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions