RedeAdaline_PYTHON
RedeAdaline_PYTHON
X = df.iloc[0:35,[0,1,2,3]].values
y = df.iloc[0:35,4].values
#print(X)
#print("Y:", y)
###Construindo Adaline
class Adaline(object):
def __init__(self, eta = 0.001, epoch = 100):
self.eta = eta
self.epoch = epoch
1
def fit(self, X, y):
np.random.seed(16)
self.weight_ = np.random.uniform(-1, 1, X.shape[1] + 1)
self.error_ = []
cost = 0
for _ in range(self.epoch):
output = self.activation_function(X)
error = y - output
return self
step += 1
plt.show()
2
### Plotando as fronteiras de decisao com Adaline
clf = Adaline()
clf.fit(X, y)
A = [0.4329,-1.3719,0.7022,-0.8535] # Classe 1
B = [0.3024,0.2286,0.8630,2.7909] #Classe -1
print (clf.predict(A))
print (clf.predict(B))
3
1
-1
[ ]: