<ipython-input-21-d853d9208eef> in predict(self, X)
36
37 def predict(self, X):
---> 38 return np.where(self,net_input(X) >= 0.0 , 1, -1)
39 pass
40 pass
NameError: name 'net_input' is not defined
36
37 def predict(self, X):
---> 38 return np.where(self,net_input(X) >= 0.0 , 1, -1)
39 pass
40 pass
NameError: name 'net_input' is not defined
1.對象初始化 def __init__(self,eta=0.01,n_iter=10):
2.AttributeError 'Precetron' object has no attribute 'predict'
把def net_input(self, X),def predict(self, X)移到fit的外面
2.AttributeError 'Precetron' object has no attribute 'predict'
把def net_input(self, X),def predict(self, X)移到fit的外面
AttributeError: module 'numpy' has no attribute 'zero'
in[5] 運行后,報錯:
----> 2 ppn.fit(X,y)
---> 45 update=self.eta*(target-self.predict(xi))
46
47 """
AttributeError: 'Perceptron' object has no attribute 'predict'
----> 2 ppn.fit(X,y)
---> 45 update=self.eta*(target-self.predict(xi))
46
47 """
AttributeError: 'Perceptron' object has no attribute 'predict'
最新回答 / zony
先創(chuàng)建感知器ppn?=?Perceptron(eta=0.1,?n_iter=10)然后訓(xùn)練就可以了ppn.fit(X,?y)
最新回答 / 暴躁的飛毛腿
模型的學(xué)習(xí)率η是根據(jù)經(jīng)驗人為調(diào)整的,這個值會影響整個模型的學(xué)習(xí)效果,過小則會導(dǎo)致學(xué)習(xí)時間過長,過大則學(xué)習(xí)結(jié)果會出現(xiàn)震蕩。
2017-07-16