gpt4 book ai didi

python-3.x - TypeError:fit()缺少1个必需的位置参数: 'y'

转载 作者:行者123 更新时间:2023-12-03 08:01:39 25 4
gpt4 key购买 nike

我正在尝试使用高斯朴素贝叶斯“分类器”预测经济周期。

数据(输入X):

             SPY    Interest Rate    Unemployment   Employment  CPI
Date
1997-01-02 56.05 7.82 9.7 3399.9 159.100
1997-02-03 56.58 7.65 9.8 3402.8 159.600
1997-03-03 54.09 7.90 9.9 3414.7 160.000

目标(输出Y):
    Economy
0 Expansion
1 Expansion
2 Expansion
3 Expansion

下面是我的代码:
from sklearn.naive_bayes import GaussianNB
from sklearn import metrics
from sklearn.cross_validation import train_test_split
X = data
Y = target
model = GaussianNB
X_train, X_test, Y_train, Y_test = train_test_split(X,Y)
model.fit(X_train, Y_train)

以下是错误:
TypeError                                 Traceback (most recent call last)
<ipython-input-132-b0975752a19f> in <module>()
6 model = GaussianNB
7 X_train, X_test, Y_train, Y_test = train_test_split(X,Y)
----> 8 model.fit(X_train, Y_train)

TypeError: fit() missing 1 required positional argument: 'y'

我究竟做错了什么?我该如何解决此问题/错误?

最佳答案

您忘记了括号“()”:

model = GaussianNB()

关于python-3.x - TypeError:fit()缺少1个必需的位置参数: 'y',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35996970/

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