for i in range(0, 1000): #Gerando funcao aleatoria func = Function() # func.set(1, 0) x0 = uniform(-1,1) y0 = uniform(-1,1) x1 = uniform(-1,1) y1 = uniform(-1,1) func.buildFromPoints( x0, y0, x1, y1) # func._print() #Gerando pontos aleatorios com base na funcao X = generatePoints(100) y = generateY(func, X) #Treinando modelo com perceptron perc = Perceptron() perc.train(X, y) # print( 'Iterations: ', perc.iterations) iterations.append(perc.iterations) #Plotando dados na amostra de treinamento xs = [ x[0] for x in X] ys = [ x[1] for x in X]
errors = [] for iter in range(0, 1000): func = Function() x0 = uniform(-1, 1) y0 = uniform(-1, 1) x1 = uniform(-1, 1) y1 = uniform(-1, 1) func.buildFromPoints(x0, y0, x1, y1) # func._print() #Gerando pontos aleatorios com base na funcao X = generatePoints(100) X_with_x0 = [[1] + x for x in X] ##adicionando bias y = generateNoise(generateY(func, X)) # print(y) perc = PocketPLA() perc.train(X, y, MAX_ITERATIONS=50) #gerando dados fora da amostra de treino X = generatePoints(1000) X_with_x0 = [[1] + x for x in X] ##adicionando bias y = generateY(func, X) #generateNoise( generateY(func, X) ) # plot(X,y,perc,func) #Calculando Erro Fora da amostra errorCount = 0