예제 #1
0
def test_boss_on_power_demand():
    # load power demand data
    X_train, y_train = load_italy_power_demand(split='train', return_X_y=True)
    X_test, y_test = load_italy_power_demand(split='test', return_X_y=True)
    indices = np.random.RandomState(0).permutation(100)

    # train BOSS
    boss = BOSSEnsemble(random_state=47)
    boss.fit(X_train, y_train)

    score = boss.score(X_test.iloc[indices], y_test[indices])
    assert (score >= 0.80)
예제 #2
0
def test_boss_on_gunpoint():
    # load gunpoint data
    X_train, y_train = load_gunpoint(split='train', return_X_y=True)
    X_test, y_test = load_gunpoint(split='test', return_X_y=True)
    indices = np.random.RandomState(0).permutation(10)

    # train boss
    boss = BOSSEnsemble(random_state=0)
    boss.fit(X_train.iloc[indices], y_train[indices])

    # assert probabilities are the same
    probas = boss.predict_proba(X_test.iloc[indices])
    testing.assert_array_equal(probas, boss_gunpoint_probas)
예제 #3
0
def test_boss_train_estimate():
    """Test of BOSS train estimate on unit test data."""
    # load unit test data
    X_train, y_train = load_unit_test(split="train")

    # train BOSS
    boss = BOSSEnsemble(max_ensemble_size=2,
                        random_state=0,
                        save_train_predictions=True)
    boss.fit(X_train, y_train)

    # test train estimate
    train_probas = boss._get_train_probs(X_train, y_train)
    assert train_probas.shape == (20, 2)
    train_preds = boss.classes_[np.argmax(train_probas, axis=1)]
    assert accuracy_score(y_train, train_preds) >= 0.6
예제 #4
0
def test_boss_on_unit_test_data():
    """Test of BOSS on unit test data."""
    # load unit test data
    X_train, y_train = load_unit_test(split="train", return_X_y=True)
    X_test, y_test = load_unit_test(split="test", return_X_y=True)
    indices = np.random.RandomState(0).choice(len(y_train), 10, replace=False)

    # train BOSS
    boss = BOSSEnsemble(max_ensemble_size=5,
                        random_state=0,
                        save_train_predictions=True)
    boss.fit(X_train, y_train)

    # assert probabilities are the same
    probas = boss.predict_proba(X_test.iloc[indices])
    testing.assert_array_almost_equal(probas, boss_unit_test_probas, decimal=2)

    # test train estimate
    train_probas = boss._get_train_probs(X_train, y_train)
    train_preds = boss.classes_[np.argmax(train_probas, axis=1)]
    assert accuracy_score(y_train, train_preds) >= 0.75