hasContent: |
"""
def ANN(x,y,xt,yt):
size = len(x)
##########################################
#x = sklearn.preprocessing.normalize(x, norm="l1")
#xt = sklearn.preprocessing.normalize([xt], norm="l1")
#scaler_x = MinMaxScaler(feature_range=(0, 1))
#x = pd. DataFrame(scaler_x.fit_transform(x))
#xt = pd. DataFrame(scaler_x.fit_transform([xt]))
#scaler_y = MinMaxScaler(feature_range=(0, 1))
#y = pd. DataFrame(scaler_y.fit_transform([y]))
#yt = pd. DataFrame(scaler_y.fit_transform([[yt]]))
maxmin=[]
for i in range(0,100):
maxmin.append([0, 1])
##########################################
inp = x#.reshape(size,1)
tar = y.reshape(size,1)
# Create network with 2 layers and random initialized
net = nl.net.newff(maxmin,[20, 1])
# Train network
error = net.train(inp, tar, epochs=5000, show=100, goal=0.01)
# Simulate network
out = net.sim(inp)
# Plot result
#pl.subplot(211)
#pl.plot(error)
#pl.xlabel('Epoch number')
#pl.ylabel('error (default SSE)')
#x2 = xt#np.linspace(-6.0,6.0,150)
ytt = net.sim([xt])
return ytt
ytt=np.round(ytt)
yttn=[]
for item in ytt:
if item[0]==0:
yttn.append(0)
else:
yttn.append(1)
return len([a for a in np.isclose(yttn , yt) if(a)]) / len(yttn) * 100
""" |