Пример #1
0
def test_y_proba_on_gunpoint():
    X, y = load_gunpoint(return_X_y=True)
    X_train, X_test, y_train, y_test = train_test_split(
        X, y, test_size=0.1, random_state=42
    )
    stsf = SupervisedTimeSeriesForest(random_state=42, n_estimators=20)
    stsf.fit(X_train, y_train)
    actual = stsf.predict_proba(X_test)
    np.testing.assert_array_equal(actual, expected)
Пример #2
0
def test_stsf_on_gunpoint():
    """Test of STSF on gun point."""
    # 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)

    stsf = SupervisedTimeSeriesForest(n_estimators=20, random_state=0)
    stsf.fit(X_train.iloc[indices], y_train[indices])

    # assert probabilities are the same
    probas = stsf.predict_proba(X_test.iloc[indices])
    testing.assert_array_equal(probas, stsf_gunpoint_probas)
Пример #3
0
def test_stsf_on_unit_test_data():
    """Test of SupervisedTimeSeriesForest 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 STSF
    stsf = SupervisedTimeSeriesForest(n_estimators=10, random_state=0)
    stsf.fit(X_train, y_train)

    # assert probabilities are the same
    probas = stsf.predict_proba(X_test.iloc[indices])
    testing.assert_array_equal(probas, stsf_unit_test_probas)