Esempio n. 1
0
        return accuracy


if __name__ == "__main__":

    # set random number generator seed
    np.random.seed(NUMERO_DE_MATRICULA)

    # set floating point formatting when printing
    np.set_printoptions(formatter={"float": "{: 0.6f}".format})

    # load data
    x = DataSets.NOME_DO_DATASET.input
    d = DataSets.NOME_DO_DATASET.output

    # define the network parameters
    n = TAXA_DE_APRENDIZADO
    g = ActivationFunctions.FUNCAO_DE_ATIVACAO

    # create the neural network
    nn = Perceptron(n, g)

    # train the neural network
    w = nn.train(x, d)

    # evaluate the neural network
    acc = nn.evaluate(w, x, d)

    # plot epoch versus error data
    PlotUtils.plot(nn.plot_data_x, "epoch", nn.plot_data_y, "error")
Esempio n. 2
0
                correct = correct + 1
        accuracy = float(correct) / float(total)
        print('Accuracy: {:.2f}% ({}/{})'.format(100.0 * accuracy, correct,
                                                 total))
        return accuracy


if __name__ == '__main__':

    # set random number generator seed
    np.random.seed(42)

    # set floating point formatting when printing
    np.set_printoptions(formatter={'float': '{: 0.6f}'.format})

    # load data
    x = DataSets.BLOOD_TRANSFUSION.input
    d = DataSets.BLOOD_TRANSFUSION.output

    # create the neural network
    nn = Adaline()

    # train the neural network
    w = nn.train(x, d)

    # evaluate the neural network
    acc = nn.evaluate(w, x, d)

    # plot epoch versus error data
    PlotUtils.plot(nn.plot_data_x, 'epoch', nn.plot_data_y, 'mse')
        for i in range(0, len(x)):
            y = self.test(w, x[i])
            if (y == d[i]):
                correct = correct + 1
        accuracy = 100.0 * (float(correct) / float(total))
        print(f"Accuracy: {accuracy:.2f}% ({correct}/{total})")
        return accuracy


if __name__ == "__main__":
    # load data
    x = DataSets.TIC_TAC_TOE_ENDGAME.input
    d = DataSets.TIC_TAC_TOE_ENDGAME.output

    # define the network parameters
    n = 1e-4
    g = ActivationFunctions.heaviside
    e = 1e-10

    # create the neural network
    nn = Adaline(n, g, e)

    # train the neural network
    w = nn.train(x, d)

    # evaluate the neural network
    acc = nn.evaluate(w, x, d)

    # plot epoch versus error data
    PlotUtils.plot(nn.plot_data_x, "epoch", nn.plot_data_y, "mse")
Esempio n. 4
0
            y = self.test(w, x[i])
            if (y == d[i]):
                correct = correct + 1
        accuracy = float(correct) / float(total)
        print('Accuracy: {:.2f}% ({}/{})'.format(100.0 * accuracy, correct, total))
        return accuracy

if  __name__ == '__main__':

    # set random number generator seed
    np.random.seed(42)

    # set floating point formatting when printing
    np.set_printoptions(formatter={'float': '{: 0.6f}'.format})

    # load data
    x = DataSets.LOGIC_GATE_AND.input
    d = DataSets.LOGIC_GATE_AND.output

    # create the neural network
    nn = Perceptron()

    # train the neural network
    w = nn.train(x, d)

    # evaluate the neural network
    acc = nn.evaluate(w, x, d)
    
    # plot epoch versus error data
    PlotUtils.plot(nn.plot_data_x, 'epoch', nn.plot_data_y, 'error')