gpt4 book ai didi

python-3.x - SVR对象不可调用

转载 作者:行者123 更新时间:2023-11-30 08:58:03 25 4
gpt4 key购买 nike

我想使用 sklearn SVR 方法,但当我编写 SVR() 函数时,它会抛出错误。它说SVR 不是可调用的

我就是这样调用它的

from sklearn.svm import SVR

这是我收到错误的代码

svr_lin = SVR(kernel='linear', C=1e3)
svr_poli = SVR(kernel='poly', C=1e3, degree = 2)
svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1)

这是我得到的错误:

error in prediccion(fechas, precios, x)

24     svr_rbf = SVR(kernel='rbf', C=1e3, gamma=0.1)
25
26 svr_lin(fechas, precios) <----
27 svr_poli(fechas, precios)
28 svr_rbf(fechas, precios)

TypeError: 'SVR' object is not callable

我也尝试过使用 SVC 等其他方法,但出现了相同的错误。

提前致谢。

最佳答案

您需要在 SVR 对象上调用函数 fit(),例如:

svr_lin.fit(fechas, precios)

了解更多 here

关于python-3.x - SVR对象不可调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51693059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com