Ejemplo n.º 1
0
def test_label_encoder():
    y = ['one', 'one', 'one', 'zero', 'zero', 'two']
    X = np.random.rand(6, 3)
    pool = [DecisionTreeClassifier().fit(X, y) for _ in range(5)]
    stacked = StackedClassifier(pool).fit(X, y)
    pred = stacked.predict(X)
    assert np.array_equal(pred, y)
Ejemplo n.º 2
0
def test_label_encoder_base_ensemble():
    from sklearn.ensemble import RandomForestClassifier
    X, y = make_classification()
    y[y == 1] = 2
    y = y.astype(np.float)
    pool = RandomForestClassifier().fit(X, y)
    st = StackedClassifier(pool)
    st.fit(X, y)
    pred = st.predict(X)
    assert np.isin(st.classes_, pred).all()