Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
0
def test_time_limit():
    from EvoDAG import RGP
    import time
    y = cl.copy()
    t = time.time()
    gp = RGP(generations=np.inf,
             tournament_size=2,
             early_stopping_rounds=100,
             multiple_outputs=True,
             time_limit=0.9,
             seed=0,
             popsize=10000).fit(X, y, test_set=X)
    t2 = time.time()
    print(t2 - t)
    assert t2 - t < 1
    assert gp._time_limit == 0.9
Exemplo n.º 5
0
def test_add():
    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
    gp.population.add(n)
    print(gp._unfeasible_counter)
    assert gp._unfeasible_counter == 0
Exemplo n.º 6
0
def test_model_len():
    from EvoDAG import RGP
    rgp = RGP(popsize=5).fit(X, cl)
    m = rgp.model()
    print(len(m))
Exemplo n.º 7
0
def test_model_iter():
    from EvoDAG import RGP
    rgp = RGP(popsize=5).fit(X, cl)
    m = rgp.model()
    x = [x for x in m]
    print(x)