I'm studiyng Adaline GSD algorithm and I have an error that says TypeError: activation () takes 1 positional argument but 2 were given. How I interpretate that? There are two variables in that line?
I know my code looks long, but most are methods
My code is:
def __init__(self, eta=0.01, n_iter=50, shuffle=True, random_state =None) :
self.eta = eta
self.n_iter=n_iter
self.w_initialized=False
self.shuffle=True
self.random_state = random_state
def fit(self, X, y):
self._initialize_weights(X.shape[1])
self.cost_=[]
for i in range (self.n_iter):
if self.shuffle:
X, y= self._shuffle(X,y)
cost =[]
for xi, target in zip(X,y):
cost.append(self._update_weights(xi,target))
avg_cost=sum(cost)/len(y)
self.cost._append(avg_cost)
return self
def partial_fit(self,X,y):
if not self.w_initialized:
self._initialize_weights(X.shape[1])
if y.ravel().shape[0]>1:
for xi, target in zip(X,y):
self._update_weights(xi, target)
else:
self._update_weights(X,y)
return self
def _shuffle(self,X,y):
r=self.rgen.permutation(len(y))
return X[r], y[r]
def _initialize_weights(self,m):
self.rgen= np.random.RandomState(self.random_state)
self.w_=self.rgen.normal(loc= 0.0, scale= 0.01, size= 1+m)
self.w_initialized=True
def _update_weights(self, xi, target):
output= self.activation(self.net_input(xi))
error=(target- output)
self.w_[1:] += self.eta * xi.dot(error)
self.w_[0] += self.eta * error
cost= 0.5*error**2
return cost
def net_input(self,X):
return np.dot(X, self.w_[1:])+ self.w_[0]
def activation(X):
return X
def predict(self,X):
return np.where(self.activation(self.net_input(X)) >= 0.0, 1, -1)
It is not all my code, but is enaugh.
How can I write output= self.activation(self.net_input(xi)) without getting an error like that?