예제 #1
0
    def test_train_regression_regression(self):
        (X_train, y_train), (X_test, y_test) = get_test_data(
            classification=False)
        est = rgf.RegularizedGreedyForestRegressor(
            l2=0.01, max_leaf_nodes=500)
        est.fit(X_train, y_train)

        y_pred = est.predict(X_train)

        fixture_name = get_fixture_path('rgf_regression_regression.npy')
        saved_preds = np.loadtxt(fixture_name)
        np.testing.assert_allclose(y_pred, saved_preds)
예제 #2
0
    def test_classification_regression(self):
        (X_train, y_train), (X_test, y_test) = get_test_data()
        sample_weight = np.ones_like(y_train)
        sample_weight[y_train == 0] = 0.5

        est = rgf.RegularizedGreedyForestClassifier(
            l2=0.01, max_leaf_nodes=500)
        est.fit(X_train, y_train, sample_weight)

        y_pred = est.predict(X_train)

        fixture_name = get_fixture_path('rgf_classification_regression.npy')
        saved_preds = np.loadtxt(fixture_name)
        np.testing.assert_allclose(y_pred, saved_preds)