facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.33k stars 4.52k forks source link

New to Prophet #2552

Open NickR001 opened 7 months ago

NickR001 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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.