Пример #1
0
def run_deap(X, y):
    popsize = 500
    mutRate = 0.4
    crRate = 0.6
    GenMax = 250

    # concatenate selected features with their target values
    dataset = np.column_stack((X, y))
    evo = Evolution(
        dataset=dataset.tolist(),  # data samples 
        popsize=popsize,  # initial population size
        hofsize=25,  # the number of best individual to track
        cx=crRate,  # crossover rate
        mut=mutRate,  # mutation rate
        maxgen=GenMax,  # max number of generations
    )

    pop, logbook, hof = evo.run(verbose=1)

    return evo, pop, logbook, hof
Пример #2
0
     evo = Evolution(size=i,
                     fitness=fitness,
                     combine_params=0.5,
                     mutate_params={
                         "std": 0.5,
                         "dim": 1,
                         "min": 0,
                         "max": 5
                     },
                     pop_params={
                         "min": 0,
                         "max": 5,
                         "dim": 1
                     },
                     method="combine")
     evo.run(epochs)
     results.append(evo.result)
 for i in labels:
     evo = Evolution(size=i,
                     fitness=fitness,
                     combine_params=0.1,
                     mutate_params={
                         "std": 0.5,
                         "dim": 1,
                         "min": 0,
                         "max": 5
                     },
                     pop_params={
                         "min": 0,
                         "max": 5,
                         "dim": 1
Пример #3
0
        mut = mutRate[6],                # mutation rate
        maxgen = GenMax[2],              # max number of generations
        )
            
    logs = pd.DataFrame()

    gen = np.zeros((reps, GenMax[2]+1))
    nevals = np.zeros((reps, GenMax[2]+1))
    avg = np.zeros((reps, GenMax[2]+1))
    mini = np.zeros((reps, GenMax[2]+1))    
    maxi = np.zeros((reps, GenMax[2]+1))
    
    for l in range(reps):
        np.random.seed(reps)

        pop, logbook, hof= evo.run()
        gen[l][:] = logbook.select('gen')
        nevals[l][:] = logbook.select('nevals')
        avg[l][:] = logbook.select('avg')
        mini[l][:] = logbook.select('min')
        maxi[l][:] = logbook.select('max')
        
    AvgEval = []
    Avg = []
    AvgMin = []
    AvgMax = []
    
    for n in range(GenMax[2]+1):
        totalEval = 0
        totalAvg = 0
        totalMin = 0