Пример #1
0
def test_replace_population_previous_estopping():
    from EvoDAG import RGP
    gp = RGP(generations=np.inf,
             tournament_size=2,
             early_stopping_rounds=-1,
             classifier=False,
             seed=0,
             popsize=3)
    gp.X = X
    y = cl.copy()
    mask = y == 0
    y[mask] = 1
    y[~mask] = -1
    gp.y = y
    gp.create_population()
    gp.unfeasible_offspring()
    es = gp.population.estopping
    for i in range(20):
        n = gp.random_offspring()
        if n.fitness_vs > es.fitness_vs:
            break
    print(es.fitness_vs, n.fitness_vs, gp._unfeasible_counter)
    assert gp._unfeasible_counter >= 1
    gp.replace(n)
    assert gp.population.previous_estopping
Пример #2
0
def test_unfeasible_counter():
    from EvoDAG import RGP
    gp = RGP(generations=np.inf,
             tournament_size=2,
             early_stopping_rounds=-1,
             seed=0,
             popsize=100)
    assert gp._unfeasible_counter == 0
    assert gp.unfeasible_offspring() is None
    assert gp._unfeasible_counter == 1
Пример #3
0
def test_unfeasible_counter():
    from EvoDAG import RGP
    gp = RGP(generations=np.inf,
             tournament_size=2,
             early_stopping_rounds=-1,
             classifier=False,
             seed=0,
             popsize=100)
    assert gp._unfeasible_counter == 0
    assert gp.unfeasible_offspring() is None
    assert gp._unfeasible_counter == 1
Пример #4
0
def test_add():
    from EvoDAG import RGP
    gp = RGP(generations=np.inf,
             tournament_size=2,
             early_stopping_rounds=-1,
             seed=0,
             popsize=3)
    gp.X = X
    y = cl.copy()
    mask = y == 0
    y[mask] = 1
    y[~mask] = -1
    gp.y = y
    gp.create_population()
    gp.unfeasible_offspring()
    es = gp.population.estopping
    for i in range(10):
        n = gp.random_offspring()
        if n.fitness_vs > es.fitness_vs:
            break
    gp.add(n)
    assert gp._unfeasible_counter == 0