不能在 PyCaret 中使用 Setup() 函数:ValueError:必须设置 data 和 data_func 中的一个且只有一个

问题描述 投票:0回答:1

我运行下面的代码,它产生了上面的 ValueError,我不知道为什么。

我有一个不同的虚拟环境,它工作得很好,唯一的区别是我用“pip install pycaret”安装了 PyCaret。我使用 --pre PyCaret 安装代替,因为 setup() 函数在该安装中有 fh(预测地平线)参数。

已安装的包

pip install --pre pycaret
pip install openpyxl
install jupyter

python version 3.8.13

代码

from pycaret.regression import *
from pycaret.datasets import get_data
from pycaret.time_series import *
import pandas as pd
import numpy as np

xls = pd.ExcelFile('El-data.xlsx')
el_tavle = pd.read_excel(xls, 'El-tavle')

el_tavle.set_index('Fra_dato', drop = True,  inplace = True)

el_tavle['Maengde'].plot()

el_tavle['Maengde'].plot(kind = 'box')

el_tavle_setup = setup(el_tavle, 'Maengde', fh = 90, session_id = 123)

我预计 setup() 函数可以正常运行。相反,它产生了一个错误。

python installation forecasting valueerror pycaret
1个回答
0
投票

在您的设置调用中,您同时指定了 data 和 data_func

el_tavle_setup = setup(el_tavle, 'Maengde', fh = 90, session_id = 123)

等于

el_tavle_setup = setup(data=el_tavle, data_func='Maengde', fh = 90, session_id = 123)

你想写的是:

el_tavle_setup = setup(data=el_tavle, target='Maengde', fh = 90, session_id = 123)

传递未命名参数时要小心。

© www.soinside.com 2019 - 2024. All rights reserved.