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

Forecast completely off from python #20

Closed
noctivityinc opened this issue May 6, 2024 · 6 comments
Closed

Forecast completely off from python #20

noctivityinc opened this issue May 6, 2024 · 6 comments

Comments

@noctivityinc
Copy link

I'm seeing some very odd behavior that I have now verified three different ways, including with AI, a Python script (attached), and running the exact copy in the README.

If you run the attached dataframe in Prophet Python, here is the tail, which looks correct:

696 2024-12-28  141.356832  105.973119  177.261087
697 2024-12-29  140.713400  107.343008  176.244366
698 2024-12-30  148.743931  113.715838  182.574506
699 2024-12-31  147.336429  111.642556  182.159546

But run that in this gem and you get this:

            ds                 yhat           yhat_lower          yhat_upper
2024-12-27 00:00:00 UTC  -1.1887472613597119  -31.812688420865282  26.381005627285898
2024-12-28 00:00:00 UTC  -1.7816324776096835   -31.38135594605859     28.010771843324
2024-12-29 00:00:00 UTC  -1.4581236205197925   -33.33384483777272  30.054684620606043
2024-12-30 00:00:00 UTC    7.853848559633956  -23.424339484797493   39.16282449671608
2024-12-31 00:00:00 UTC    8.104537440580243  -22.121849157788585   37.58356822292222

Here is the python code:

import pandas as pd
from prophet import Prophet

df = pd.read_csv('data.csv')
df.head()

model = Prophet()
model.fit(df)

future = model.make_future_dataframe(periods=240)
future.tail()

forecast = model.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']])

and here is the ruby code

df = Rover.read_csv("data.csv")
df.head
m = Prophet.new
m.fit(df)
future = m.make_future_dataframe(periods: 240)
future.tail

I have no idea where to go from here but it looks like something is seriously off.

data.csv

@ankane ankane closed this as completed in 6f613f0 May 6, 2024
@ankane
Copy link
Owner

ankane commented May 6, 2024

Hi @noctivityinc, thanks for the great report! Fixed in the commit above.

@noctivityinc
Copy link
Author

Amazing. You might want to bump the gem to 0.5.1 so others can get this fix.

@noctivityinc
Copy link
Author

@ankane not exact but closer. And idea what could be causing the discrepancy:

prophet-rb 0.5.1

"2024-12-27 00:00:00 UTC - 144.45107984480057 "
"2024-12-28 00:00:00 UTC - 144.58676506566425 "
"2024-12-29 00:00:00 UTC - 144.722450286528 "
"2024-12-30 00:00:00 UTC - 144.8581355073917 "
"2024-12-31 00:00:00 UTC - 144.9938207282554 "

prophet python

695 2024-12-27  142.530510  108.755248  177.333980
696 2024-12-28  141.356832  109.430728  178.663280
697 2024-12-29  140.713400  105.770788  172.597794
698 2024-12-30  148.743931  115.585700  181.051046
699 2024-12-31  147.336429  114.247664  182.089826

@ankane
Copy link
Owner

ankane commented May 6, 2024

What platform are you on (bundle platform)?

Here's what I'm getting with 0.5.1:

2024-12-27 00:00:00 UTC  142.51836211570543
2024-12-28 00:00:00 UTC  141.34461585360677
2024-12-29 00:00:00 UTC   140.7011304632125
2024-12-30 00:00:00 UTC  148.73183906835592
2024-12-31 00:00:00 UTC  147.32427227459667

@noctivityinc
Copy link
Author

Here you go:

Your platform is: x86_64-darwin-23

@ankane
Copy link
Owner

ankane commented May 6, 2024

Just tried it on Mac x86-64 and am seeing similar results as Python. I'd double check that the input and options are correct.

2024-12-27 00:00:00 UTC  142.52208791475115
2024-12-28 00:00:00 UTC   141.3483631849485
2024-12-29 00:00:00 UTC  140.70489925375247
2024-12-30 00:00:00 UTC  148.73555905539158
2024-12-31 00:00:00 UTC  147.32801368787972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants