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

New to Prophet #2552

Open
NickR001 opened this issue Feb 14, 2024 · 3 comments
Open

New to Prophet #2552

NickR001 opened this issue Feb 14, 2024 · 3 comments

Comments

@NickR001
Copy link

NickR001 commented Feb 14, 2024

Hi,

So I wanted to forecast some figures based on last years data...I have installed Prophet and using Notebook Jupyter

I can run these commands where I see the first 4 lines of the imported CSV sheet.

import pandas as pd
df = pd.read_csv(r'C:\Users\Public\Meds.csv',header=None)
df.head()

When trying to run anything with Prophet i.e m = Prophet() I get

NameError Traceback (most recent call last)
Cell In[109], line 1
----> 1 m = prophet()

NameError: name 'prophet' is not defined

Any help would be appreciated or sign posted towards a forum that may be able to offer some assistance. Thanks,

@Vaslo
Copy link

Vaslo commented Feb 14, 2024

Hi,

So I wanted to forecast some figures based on last years data...I have installed Prophet and using Notebook Jupyter

I can run these commands where I see the first 4 lines of the imported CSV sheet.

import pandas as pd

df = pd.read_csv(r'C:\Users\Public\Meds.csv',header=None)

df.head()

When trying to run anything with Prophet i.e m = Prophet() I get

NameError Traceback (most recent call last)

Cell In[109], line 1

----> 1 m = prophet()

NameError: name 'prophet' is not defined

Any help would be appreciated or sign posted towards a forum that may be able to offer some assistance. Thanks,

Are you sure you have done 'pip install prophet'? And if so have your made sure to import prophet at the top of your code?

Make sure to check the quick start:
quick start

@NickR001
Copy link
Author

Hi Vaslo,

I found this blog and started again https://blog.quantinsti.com/installing-prophet-library-windows/ and all seems okay at least nothing failed when installing!

I can run the command m = Prophet() in Notebook and doesn't complain now but my datasheet doesn't pass the fit test. I take this as a success but now need to work out why it doesn't like my datasheet as both coloums have ds (for dates) and y (for the figures) in the first cell of the spreadsheet as shown below when running the commands

import pandas as pd
df = pd.read_csv(r'C:\Users\Public\Meds.csv',header=None)
df.head()

0	1

0 ds y
1 01/01/2023 102
2 02/01/2023 114
3 03/01/2023 123
4 04/01/2023 116

m.fit(df) output

ValueError Traceback (most recent call last)
Cell In[133], line 1
----> 1 m.fit(df)

File ~\AppData\Local\anaconda3\Lib\site-packages\prophet\forecaster.py:1117, in Prophet.fit(self, df, **kwargs)
1114 raise Exception('Prophet object can only be fit once. '
1115 'Instantiate a new object.')
1116 if ('ds' not in df) or ('y' not in df):
-> 1117 raise ValueError(
1118 'Dataframe must have columns "ds" and "y" with the dates and '
1119 'values respectively.'
1120 )
1121 history = df[df['y'].notnull()].copy()
1122 if history.shape[0] < 2:

ValueError: Dataframe must have columns "ds" and "y" with the dates and values respectively.

@gvas7
Copy link

gvas7 commented Feb 15, 2024

Hi NickR001,

Without seeing your actual data, I think you might want your read_csv to be have a header for row 1 so that your dataframe should have ds and y as the first line when you read the head of the dataframe, and then your data will follow from there. This is more of a pandas issue rather than prophet, so once that is right you can at least get a simple model.

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

3 participants