0
有人可以幫我調試這段代碼嗎?謝謝!使用SciKit的Logisitc迴歸瞭解
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
from sklearn import linear_model
data = pd.read_csv('Mower.csv')
data = data.values
y = data[:,2]
x = data[:,:2]
y_train = y[:int(0.3*len(y))]
x_train = x[:int(0.3*len(y)),:]
y_validate = y[int(0.3*len((y))):]
x_validate = x[int(0.3*len((y))):,:]
clf = linear_model.LogisticRegression
clf.fit(x_train,y_train)
y_hat = clf.predict(x_validate)
給了我以下錯誤:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-77-a0a54feba3ef> in <module>()
1 clf = linear_model.LogisticRegression
----> 2 clf.fit(x_train,y_train)
3 y_hat = clf.predict(x_validate)
TypeError: unbound method fit() must be called with LogisticRegression instance as first argument (got ndarray instance instead)