Yaovi
Yaovi

Reputation: 41

ValueError: You must pass a freq argument as current index has none

I'm using pycaret.time_series alpha module but I have this problem avec launching my experiment. I think this is internal to the module. Can anyone help ?

`from pycaret.time_series import *

 exp_name = setup(data = df ,index='ds', target='y', fold = 5, fh = 15)`

and i got this :


ValueError Traceback (most recent call last) c:\Users\elsem\Python\Andre_Coach\ts.ipynb Cell 46' in <cell line: 1>() ----> 1 exp_name = setup(data = df ,index='ds', target='y', fold = 5, fh = 15)

enter image description hereenter image description here

my df looks like this:

enter image description here

Upvotes: 2

Views: 4314

Answers (5)

otmane42
otmane42

Reputation: 643

I had the same issue, and this is how I could solve it :

import pandas as pd
df["ds"] = pd.to_datetime(df["ds"])
df=df.set_index("ds")
df.index = df.index.to_period(freq="d")

and setup arguments will alter accordingly by removing index="ds" as follows :

exp_name = setup(data = df, target='y', fold = 5, fh = 15) 

this works with pycaret==3.1.0

Upvotes: 0

Nikhil Gupta
Nikhil Gupta

Reputation: 1486

First of all, you should not use the pycaret-ts-alpha library anymore as it is old and deprecated. Instead, you can use the pre-release version of pycaret now which has the time series module integrated

pip install --pre pycaret

To solve the particular problem you have, try setting the frequency as mentioned. Alternately, if you data has missing index values (e.g. the walmart data set has missing values for some store-dept combinations), try adding these indices to the data and imputing them in pycaret.

Upvotes: 0

Abdolamir Karbalaie
Abdolamir Karbalaie

Reputation: 29

You need to see the type of your data by using

df.dtypes

check the type of ds that should be

ds        datetime64[ns] 

Upvotes: 1

Mohamed Eshra
Mohamed Eshra

Reputation: 53

You can set solve this by setting the dataframe's date frequency.

For example, to set business day frequency use:

df= df.asfreq('B')

Upvotes: 0

Nikhil Gupta
Nikhil Gupta

Reputation: 1486

Try converting the ds column to datetime manually outside pycaret before feeding to setup. That should hopefully resolve the issue.

Upvotes: 0

Related Questions