반환값
-------
self : LogisticRegressionGD 객체
"""
rgen = np.random.RandomState(self.random_state)
self.w_ = rgen.normal(loc=0.0, scale=0.01, size=X.shape[1])
self.b_ = np.float_(0.)
self.losses_ = []
for i in range(self.n_iter):
net_input = self.net_input(X)
output = self.activation(net_input)
errors = (y - output)
self.w_ += self.eta * 2.0 * X.T.dot(errors) / X.shape[0]
self.b_ += self.eta * 2.0 * errors.mean()
loss = (-y.dot(np.log(output))
- ((1 - y).dot(np.log(1 - output)))
/ X.shape[0])
self.losses_.append(loss)
return self
def net_input(self, X):
"""최종 입력 계산"""
return np.dot(X, self.w_) + self.b_