def test_it_without_bp(): pop, stats = main() stringh = "_without_bp" fronts = tools.sortNondominated(pop, len(pop)) if len(fronts[0]) < 30: pareto_front = fronts[0] else: pareto_front = random.sample(fronts[0], 30) print("Pareto Front: ") for i in range(len(pareto_front)): print(pareto_front[i].fitness.values) neter = Neterr(indim, outdim, n_hidden, random) neter = Neterr(indim, outdim, n_hidden, random) print("\ntest: test on one with min validation error", neter.test_err(min(pop, key=lambda x: x.fitness.values[1]))) tup = neter.test_on_pareto_patch(pareto_front) print("\n test: avg on sampled pareto set", tup[0], "least found avg", tup[1]) st = str(neter.test_err(min( pop, key=lambda x: x.fitness.values[1]))) + " " + str( tup[0]) + " " + str(tup[1]) print(note_this_string(st, stringh))
def test_it_with_bp(play=1, NGEN=100, MU=4 * 25): pop, stats = main(play=play, NGEN=NGEN, MU=MU) stringh = "_with_bp_without_clustring" + str(play) + "_" + str(NGEN) fronts = tools.sortNondominated(pop, len(pop)) if len(fronts[0]) < 30: pareto_front = fronts[0] else: pareto_front = random.sample(fronts[0], 30) print("Pareto Front: ") for i in range(len(pareto_front)): print(pareto_front[i].fitness.values) neter = Neterr(indim, outdim, n_hidden, random) print("\ntest: test on one with min validation error", neter.test_err(min(pop, key=lambda x: x.fitness.values[1]))) tup = neter.test_on_pareto_patch_correctone(pareto_front) print("\n test: avg on sampled pareto set", tup) st = str(neter.test_err(min( pop, key=lambda x: x.fitness.values[1]))) + " " + str(tup) print( note_this_string(st, stringh) ) ##################################################################################
from deap.benchmarks.tools import diversity, convergence from deap import creator from deap import tools import os from population import * from network import Neterr from chromosome import Chromosome, crossover import traceback n_hidden = 100 indim = 32 outdim = 5 network_obj_src = Neterr(indim, outdim, n_hidden, change_to_target=0, rng=random) network_obj_tar = Neterr(indim, outdim, n_hidden, change_to_target=2, rng=random) creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.0, -1.0, -1.0)) creator.create("Individual", Chromosome, fitness=creator.FitnessMin) print("here network object created") toolbox = base.Toolbox() def minimize_src(individual): outputarr = network_obj_src.feedforward_ne(
import cluster from deap import algorithms from deap import base from deap import benchmarks from deap.benchmarks.tools import diversity, convergence from deap import creator from deap import tools import os from population import * from network import Neterr from chromosome import Chromosome, crossover n_hidden = 100 indim = 8 outdim = 2 network_obj = Neterr(indim, outdim, n_hidden, random) creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.0, 0.0, 0.0)) creator.create("Individual", Chromosome, fitness=creator.FitnessMin) toolbox = base.Toolbox() def minimize(individual): outputarr = network_obj.feedforward_ne(individual, final_activation=network.softmax) neg_log_likelihood_val = give_neg_log_likelihood(outputarr, network_obj.resty) mean_square_error_val = give_mse(outputarr, network_obj.resty) false_positve_rat = give_false_positive_ratio(outputarr, network_obj.resty) false_negative_rat = give_false_negative_ratio(outputarr,