Example #1
0
def test_EvoMSA_transform():
    from sklearn.preprocessing import LabelEncoder
    X, y = get_data()
    Xn = [X, [x for x, y0 in zip(X, y) if y0 in ['P', 'N']]]
    Y = [y, [x for x in y if x in ['P', 'N']]]
    Yn = []
    for y0 in Y:
        _ = LabelEncoder().fit(y0)
        Yn.append(_.transform(y0).tolist())
    X = Xn
    y = Yn
    for m, shape, TR in zip(
        [[['EvoMSA.model.Corpus', 'EvoMSA.model.Bernulli']],
         [['EvoMSA.model.Corpus', 'EvoMSA.model.Bernulli']]], [11, 6],
        [True, False]):
        evo = EvoMSA(evodag_args=dict(popsize=10,
                                      early_stopping_rounds=10,
                                      time_limit=15,
                                      n_estimators=10),
                     TR=TR,
                     models=m,
                     n_jobs=1)
        evo.fit_svm(X, y)
        D = evo.transform(X[0], y[0])
        D.shape[1] == shape
Example #2
0
def test_EvoMSA_fit2():
    X, y = get_data()
    evo = EvoMSA(
        evodag_args=dict(popsize=10,
                         early_stopping_rounds=10,
                         time_limit=5,
                         n_estimators=5),
        n_jobs=2).fit([X, [x for x, y0 in zip(X, y) if y0 in ['P', 'N']]],
                      [y, [x for x in y if x in ['P', 'N']]])
    assert evo
    D = evo.transform(X, y)
    assert len(D[0]) == 5
Example #3
0
def test_EvoMSA_exogenous_model():
    X, y = get_data()
    model = EvoMSA(evodag_args=dict(popsize=10, early_stopping_rounds=10),
                   n_jobs=2).fit(X, y)
    evo = EvoMSA(evodag_args=dict(popsize=10,
                                  early_stopping_rounds=10,
                                  time_limit=5,
                                  n_estimators=5),
                 n_jobs=2)
    evo.exogenous_model = model
    evo.fit(X, y)
    D = evo.transform(X)
    assert D.shape[1] == 8