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
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