예제 #1
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':
    
    testName = "LR03-testLRCNN01-GA"
    
    lr = NeuralNetworkCalculator(3, 10)
    lr.load('nn_data.csv')

    lr.runCnt = 100
    lr.calcByGA(500, [-10.0, 10.0], 0.05)

    print lr.betas
    print lr.mse
    
    lr.log(testName)
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    #plt.show()
    plt.savefig(testName)
    
    print lr.fitnessVal[lr.runCnt-1]
예제 #2
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':

    #lr = NeuralNetworkCalculator(7)
    #lr.load('auto_mpg-norm.csv')
    lr = NeuralNetworkCalculator(1)
    lr.load('mlp_reg.csv')
    #lr.calc()
    lr.runCnt = 100
    lr.calcByGA(1000, [-10.0, 10.0])
    #lr.calcByPSO(1000, [-5.0, 5.0])
    print lr.betas
    print lr.mle

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    plt.show()

    print lr.fitnessVal[lr.runCnt - 1]
예제 #3
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':

    testName = "LR05-testLRCNN01-GA"

    lr = NeuralNetworkCalculator(3, 10)
    lr.loadTrainData('nn_data-train.csv')
    lr.loadTestData('nn_data-test.csv')

    lr.runCnt = 200
    lr.calcByGA(1000, [-10.0, 10.0], 0.1)
    lr.calcTestMSE(lr.betas)

    print lr.betas
    print "TRAIN SIZE: " + str(lr.trainDataSize) + " MSE: " + str(lr.trainMSE)
    print "TEST SIZE: " + str(lr.testDataSize) + " MSE: " + str(lr.testMSE)

    lr.log(testName)

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.trainFitnessVal)
    ax.set_xlabel("Iteration")
    ax.set_ylabel("Fitness")
    title_str = "Train M.S.E = " + str(lr.trainMSE) + " "
    title_str += "Test M.S.E = " + str(lr.testMSE) + "\n"
    title_str += "  beta 0 = " + str(lr.betas[0])
    title_str += ", beta 1 = " + str(lr.betas[1])
    ax.set_title(title_str)
예제 #4
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':
    
    testName = "LR02-testLRC07-GA"
    
    lr = NeuralNetworkCalculator(6, 10)
    lr.load('yacht-norm.csv')
    lr.runCnt = 100
    lr.calcByGA(1000, [-10.0, 10.0])
    print lr.betas
    print lr.mse
    
    lr.log(testName)
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    #plt.show()
    plt.savefig(testName)
    
    print lr.fitnessVal[lr.runCnt-1]
예제 #5
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':
    
    testName = "LR02-testLRCNN01-PSO"
    
    lr = NeuralNetworkCalculator(3)
    lr.load('nn_data.csv')
    lr.runCnt = 100
    lr.calcByPSO(500, [-10.0, 10.0])
    print lr.betas
    print lr.mle
    
    lr.log(testName)
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    #plt.show()
    plt.savefig(testName)
    
    print lr.fitnessVal[lr.runCnt-1]
예제 #6
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':

    testName = "LR02-testLRC06-GA"

    lr = NeuralNetworkCalculator(7, 10)
    lr.load('auto_mpg-norm.csv')
    lr.runCnt = 500
    lr.calcByGA(2000, [-10.0, 10.0])
    print lr.betas
    print lr.mse

    lr.log(testName)

    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    #plt.show()
    plt.savefig(testName)

    print lr.fitnessVal[lr.runCnt - 1]
예제 #7
0
from NeuralNetworkCalculator import *
import matplotlib.pyplot as plt

if __name__ == '__main__':
    
    testName = "LR02-testLRC06-PSO"
    
    lr = NeuralNetworkCalculator(7)
    lr.load('auto_mpg-norm.csv')

    lr.runCnt = 100
    lr.calcByPSO(500, [-10.0, 10.0])
    print lr.betas
    print lr.mle
    
    lr.log(testName)
    
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(np.arange(lr.runCnt), lr.fitnessVal)
    #plt.show()
    plt.savefig(testName)
    
    print lr.fitnessVal[lr.runCnt-1]