GithubHelp home page GithubHelp logo

Prophet Optimization error about prophet HOT 4 OPEN

Cooliebaj avatar Cooliebaj commented on April 29, 2024
Prophet Optimization error

from prophet.

Comments (4)

Borgna02 avatar Borgna02 commented on April 29, 2024 1

hi Borgna02. I had the same problem like you about the

self.stan_fit = self.model.optimize(**args)

I want to ask you how to handle this error if you already solve it

Hi, i solved it executing the script on ubuntu 22.04, prophet 1.1.1 and holidays 0.18.0.

I don't know if at the moment is possible to execute it on windows..

from prophet.

2victor2 avatar 2victor2 commented on April 29, 2024

I'm also with the same problem... digging deeper into the logs I saw that this error is being raised in cmdstanpy backend.

RuntimeError: Error during optimization! Command '/home/victor/Projects/Infra/natto-forecaster/venv/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin random seed=99561 data file=/tmp/tmpdy1bc6ti/l6ubkhnj.json init=/tmp/tmpdy1bc6ti/5gzpegdq.json output file=/tmp/tmpdy1bc6ti/prophet_modelxvyk50xw/prophet_model-20231201112246.csv method=optimize algorithm=newton iter=10000' failed: console log output:

method = optimize
  optimize
    algorithm = newton
      newton
    jacobian = 0 (Default)
    iter = 10000
    save_iterations = 0 (Default)
id = 1 (Default)
data
  file = /tmp/tmpdy1bc6ti/l6ubkhnj.json
init = /tmp/tmpdy1bc6ti/5gzpegdq.json
random
  seed = 99561
output
  file = /tmp/tmpdy1bc6ti/prophet_modelxvyk50xw/prophet_model-20231201112246.csv
  diagnostic_file =  (Default)
  refresh = 100 (Default)
  sig_figs = -1 (Default)
  profile_file = profile.csv (Default)
num_threads = 1 (Default)

Rejecting initial value:
  Error evaluating the log probability at the initial value.
Exception: normal_lpdf: Random variable is nan, but must be not nan! (in 'prophet.stan', line 130, column 2 to column 19)

Initialization between (-2, 2) failed after 1 attempts. 
 Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
Initialization failed.

I've already tried changing the parameters, specifying initial values and clearing Nan values but, since doesn't seem to be in Prophet initialization, any of them worked. My code if needed:

        # Create a new Prophet model with the loaded parameters
        prophet_model = Prophet(**model)

        # Fit the model with the data
        df_for_prophet = data[["DTNEG", "QTDNEG"]].rename(
            columns={"DTNEG": "ds", "QTDNEG": "y"}
        )
        # Convert 'y' column to numeric, coercing errors
        df_for_prophet["y"] = pd.to_numeric(df_for_prophet["y"], errors="coerce")

        # Drop rows with NaN values after conversion
        df_for_prophet = df_for_prophet.dropna(subset=["y"])
        # Set options to display more rows and columns
        pd.set_option("display.max_rows", None)
        pd.set_option("display.max_columns", None)
        # print(
        #     {
        #         "pickle_parameters": {**model},
        #         "Loaded Prophet model for product": product,
        #         "model_name": model_name,
        #         "df": df_for_prophet,
        #     }
        # )
        prophet_model.fit(df_for_prophet) # error is being raised inside this function
        # Reset display options to default values
        pd.reset_option("display.max_rows")
        pd.reset_option("display.max_columns")

Thanks in advance

from prophet.

Borgna02 avatar Borgna02 commented on April 29, 2024

Same problem, prophet 1.1.5:

16:35:26 - cmdstanpy - INFO - Chain [1] start processing
16:35:26 - cmdstanpy - INFO - Chain [1] done processing
16:35:26 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 3221225657
Optimization terminated abnormally. Falling back to Newton.
16:35:27 - cmdstanpy - INFO - Chain [1] start processing
16:35:27 - cmdstanpy - INFO - Chain [1] done processing
16:35:27 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 3221225657
Traceback (most recent call last):
File "C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\prophet\models.py", line 121, in fit
self.stan_fit = self.model.optimize(**args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\cmdstanpy\model.py", line 659, in optimize
raise RuntimeError(msg)
RuntimeError: Error during optimization! Command 'C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\prophet\stan_model\prophet_model.bin random seed=82529 data file=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\chl1mqe7.json init=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\cfjxi_pi.json output file=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\prophet_modelq8hb3fxt\prophet_model-20240421163526.csv method=optimize algorithm=lbfgs iter=10000' failed:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "d:\Uni\3 anno\1 sem\AI\progetti_corso_AI\progetto_finale\src\fbprophet\fbprhphet_prova.py", line 73, in
model.fit(future_df.reset_index().rename(columns={'index': 'ds', 'daily_return_NVDA': 'y'}))
File "C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\prophet\forecaster.py", line 1232, in fit
self.params = self.stan_backend.fit(stan_init, dat, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\prophet\models.py", line 128, in fit
self.stan_fit = self.model.optimize(**args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\cmdstanpy\model.py", line 659, in optimize
raise RuntimeError(msg)
RuntimeError: Error during optimization! Command 'C:\Users\danyb\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\prophet\stan_model\prophet_model.bin random seed=9043 data file=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\s2v4x2tf.json init=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\8u4b2w1y.json output file=C:\Users\danyb\AppData\Local\Temp\tmpz_z9dcxk\prophet_modelqfm1twda\prophet_model-20240421163527.csv method=optimize algorithm=newton iter=10000' failed:

from prophet.

Tuyen92 avatar Tuyen92 commented on April 29, 2024

hi Borgna02. I had the same problem like you about the

self.stan_fit = self.model.optimize(**args)

I want to ask you how to handle this error if you already solve it

from prophet.

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.