d = euclideanDistance(x[best], y[best], x[j], y[j]) h = np.exp((-1*(d**2))/(2*(S**2))) board[j].setWeight(board[j].getWeight() + N*h*(trX[i]-board[j].getWeight())) cost = difWeight(prev, board) print("Cost: {}".format(cost)) costV.append(cost) prev = deepcopy(board) bestNeurons = [] for i in range(len(trX)): index = getBest(distance(trX[i], board)) bestNeurons.append((x[index], y[index])) return bestNeurons, costV trX, labels = Persistence.getTrxPaises() # #Parameters neuronNumber = 20 #neuronNumber^2 nIterations = 100 S = neuronNumber/2 N = 0.001 N_limit = 0.01 S_limit = 1 T1 = nIterations*len(trX)/math.log(S) T2 = T1 board = initBoard(neuronNumber*neuronNumber, len(trX[0])) bestNeurons, costV = train(board, trX) Graphic.showCost(costV) Graphic.showBoard(bestNeurons, labels, neuronNumber)