Example #1
0
File: UI.py Project: SabaAlex/AI
    def __process(nrOfIterations, learningRate, hiddenNeuronsNumber, aConst):
        dataset = ProblemData("resources/data.data")
        trainX, trainY, testX, testY = dataset.splitData()

        neuralNetwork = ANN(deepcopy(trainX), deepcopy(trainY), learningRate,
                            hiddenNeuronsNumber, aConst)

        iterations = []
        for i in range(nrOfIterations):
            neuralNetwork.feedForward()
            neuralNetwork.backProp()
            iterations.append(i)

        for i in range(len(testX)):
            predictedOut = neuralNetwork.getOutput(testX[i])
            print("Predicted output: {0}\nReal value: {1}".format(
                predictedOut, testY[i]))

        matplotlib.pyplot.plot(iterations,
                               neuralNetwork.getLoss(),
                               label='loss value vs iteration')
        matplotlib.pyplot.xlabel('Iterations')
        matplotlib.pyplot.ylabel('Loss function')
        matplotlib.pyplot.legend()
        matplotlib.pyplot.show()