Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

python 3.x - TypeError: fit() missing 1 required positional argument: 'y'

I am trying to predict economic cycles using Gaussian Naive Bayes "Classifier".

data (input 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

target (output Y) :

    Economy
0   Expansion
1   Expansion
2   Expansion
3   Expansion

Below is my code:

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)

Below is Error:

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'

What am I doing wrong? How can I resolve this issue /error ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You forgot the parenthesis "()" in:

model = GaussianNB()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...