errors+=int(update!=0.0)
self.errors_.append(errors)
pass
pass
def net_input(self,x):
return np.dot(X,self.w_[1:])+self.w_[0]
pass
def predict(self,x):
return np.where(self.net_input(x)>=0.0,1,-1)
pass
pass
pass
点赞排序吧!
self.errors_.append(errors)
pass
pass
def net_input(self,x):
return np.dot(X,self.w_[1:])+self.w_[0]
pass
def predict(self,x):
return np.where(self.net_input(x)>=0.0,1,-1)
pass
pass
pass
点赞排序吧!
2017-06-30
self.w_=np.zeros(1+x.shape[1]);
self.errors_=[]
for _ in range(self.n_iter):
errors=0
for xi,taret in zip(x,y):
"""
update=eat*(y-y')
xi 向量
"""
update =self.eta*(target-self.predict(xi))
self.w_[1:]+=update*xi
self.w_[0]+=update;
self.errors_=[]
for _ in range(self.n_iter):
errors=0
for xi,taret in zip(x,y):
"""
update=eat*(y-y')
xi 向量
"""
update =self.eta*(target-self.predict(xi))
self.w_[1:]+=update*xi
self.w_[0]+=update;
2017-06-30
#-*- coding: utf8 -*-
import numpy as np
class Perceptron(object):
"""
eat 学习率
n_iter 权重向量的训练次数
w—— 神经分叉权重
errors 记录神经元判断出错次数
"""
def __init__(self, eat=0.01,n_iter=10):
self.eta = eta
self.n_iter=n_iter
def fit(self,x,y):
import numpy as np
class Perceptron(object):
"""
eat 学习率
n_iter 权重向量的训练次数
w—— 神经分叉权重
errors 记录神经元判断出错次数
"""
def __init__(self, eat=0.01,n_iter=10):
self.eta = eta
self.n_iter=n_iter
def fit(self,x,y):
2017-06-30