Beispiel #1
0
def main():
    # BPSO parameters
    num_pop = 50
    num_feat = 385
    num_gens = 1000

    # initialize objects
    model = mlr.MLR()
    fdf = FromDataFileMLR.FromDataFileMLR()
    fff = FromFinessFileMLR.FromFinessFileMR(fdf)
    bpso = BinaryParticleSwarmOptimization(model, fff, num_pop, num_feat,
                                           num_gens)

    # load in data from files
    trainX, trainY, validateX, validateY, testX, testY = fdf.getAllOfTheData()
    trainX, validateX, testX = fdf.rescaleTheData(trainX, validateX, testX)

    # BPSO algorithm
    bpso.create_initial_population()
    bpso.evaluate_population(trainX, trainY, validateX, validateY, testX,
                             testY)
    bpso.create_initial_velocity()
    initial_local_best_matrix, initial_local_fitness = bpso.create_initial_local_best_matrix(
    )
    bpso.create_initial_global_best_row()
    bpso.evolve_population(initial_local_best_matrix, initial_local_fitness,
                           trainX, trainY, validateX, validateY, testX, testY)
Beispiel #2
0
def main():
    # GA parameters
    num_pop = 50
    num_feat = 385
    num_gens = 1000

    # initialize objects
    model = mlr.MLR()
    fdf = FromDataFileMLR.FromDataFileMLR()
    fff = FromFinessFileMLR.FromFinessFileMR(fdf)
    GA = GeneticAlgorithm(model, fff, num_pop, num_feat, num_gens)

    # load in data from files
    trainX, trainY, validateX, validateY, testX, testY = fdf.getAllOfTheData()
    trainX, validateX, testX = fdf.rescaleTheData(trainX, validateX, testX)

    # genetic algorithm
    GA.create_initial_population()
    GA.evaluate_population(trainX, trainY, validateX, validateY, testX, testY)
    GA.evolve_population(trainX, trainY, validateX, validateY, testX, testY)
Beispiel #3
0
def main():
    # DE parameters
    num_pop = 50
    num_feat = 385
    num_gens = 100

    # initialize objects
    model = mlr.MLR()
    FDF = FromDataFileMLR.FromDataFileMLR()
    FFF = FromFinessFileMLR.FromFinessFileMR(FDF)
    DE = DifferentialEvolution(model, FFF, num_pop, num_feat, num_gens)

    # load in data from files
    trainX, trainY, validateX, validateY, testX, testY = FDF.getAllOfTheData()
    trainX, validateX, testX = FDF.rescaleTheData(trainX, validateX, testX)

    # differential evolution algorithm
    DE.create_initial_population()
    DE.evaluate_population(trainX, trainY, validateX, validateY, testX, testY)
    DE.evolve_population(trainX, trainY, validateX, validateY, testX, testY)