'Perceptron' object has no attribute 'predict'
def predict(self, X): return np.where(self.net_input(X) >= 0.0, 1, -1) def net_input(self, X): """ z = W0*X0 + W1*X1 + W2*X2 + ....Wn*Xn 对电信号加总求和 """ return np.dot(X, self.w_[1:] + self.w_[0]) # 把上面两函数放到fit()上面 def fit(self, X, y):
把predict函数拿出来,和fit函数并列