ValueError:您必须传递一个频率参数,因为当前索引没有

发布于 2025-01-15 05:44:18 字数 889 浏览 3 评论 0原文

我正在使用 pycaret.time_series alpha 模块,但我在启动实验时遇到了这个问题。我认为这是模块内部的。有人可以帮忙吗?

`from pycaret.time_series import *

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

我得到了这个:


ValueError Traceback(最近调用 最后)c:\ Users \ elsem \ Python \ Andre_Coach \ ts.ipynb Cell 46' in <单元格 行:1>() ----> 1 exp_name = setup(data = df,index='ds', target='y', Fold = 5, fh = 15)

在此处输入图像描述在此处输入图像描述

我的 df 看起来像这样:

在此处输入图像描述

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

瑾兮 2025-01-22 05:44:18

来查看数据的类型

df.dtypes

您需要通过使用检查 ds 的类型

ds        datetime64[ns] 

You need to see the type of your data by using

df.dtypes

check the type of ds that should be

ds        datetime64[ns] 
故人爱我别走 2025-01-22 05:44:18

在提供给设置之前,尝试在 pycaret 外部手动将 ds 列转换为日期时间。这应该有望解决问题。

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

骄傲 2025-01-22 05:44:18

您可以通过设置数据框的日期频率来解决此问题。

例如,要设置工作日频率,请使用:

df= df.asfreq('B')

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

For example, to set business day frequency use:

df= df.asfreq('B')
美人迟暮 2025-01-22 05:44:18

首先,您不应该再使用 pycaret-ts-alpha 库,因为它已经过时且已弃用。相反,您现在可以使用 pycaret 的预发布版本,它集成了时间序列模块。

pip install --pre pycaret

要解决您遇到的特定问题,请尝试按上述设置频率。或者,如果您的数据缺少索引值(例如,沃尔玛数据集缺少某些商店部门组合的值),请尝试将这些索引添加到数据中并将它们输入到 pycaret 中。

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.

翻身的咸鱼 2025-01-22 05:44:18

我遇到了同样的问题,这就是我解决它的方法:

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

并且设置参数将通过删除 index="ds" 进行相应更改,如下所示:

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

这适用于 pycaret==3.1.0

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文