Пример #1
0
def test_pipeline_with_classification(classification_dataset, model_key):
    X_train, X_test, y_train, y_test = classification_dataset
    model_const = models[model_key]
    if model_key == 'RandomForestClassifier':
        model = model_const(n_bins=2)
    else:
        model = model_const()
    pipe = Pipeline(steps=[('scaler', StandardScaler()), ('model', model)])
    pipe.fit(X_train, y_train)
    prediction = pipe.predict(X_test)
    assert isinstance(prediction, cupy.ndarray)
Пример #2
0
def test_pipeline_with_regression(regression_dataset, model_key,
                                  instantiation):
    X_train, X_test, y_train, y_test = regression_dataset
    model_const = models[model_key]
    if model_key == 'RandomForestRegressor':
        model = model_const(n_bins=2)
    else:
        model = model_const()

    if instantiation == 'Pipeline':
        pipe = Pipeline(steps=[('scaler', StandardScaler()), ('model', model)])
    elif instantiation == 'make_pipeline':
        pipe = make_pipeline(StandardScaler(), model)
    pipe.fit(X_train, y_train)
    prediction = pipe.predict(X_test)
    assert isinstance(prediction, cupy.ndarray)
    _ = pipe.score(X_test, y_test)
Пример #3
0
def test_pipeline_with_classification(classification_dataset, model_key,
                                      instantiation):
    X_train, X_test, y_train, y_test = classification_dataset
    model_const = models[model_key]
    if model_key == 'RandomForestClassifier':
        model = model_const(n_bins=2)
    else:
        model = model_const()
    if instantiation == 'Pipeline':
        pipe = Pipeline(steps=[('scaler', StandardScaler()), ('model', model)])
    elif instantiation == 'make_pipeline':
        pipe = make_pipeline(StandardScaler(), model)
    pipe.fit(X_train, y_train)
    prediction = pipe.predict(X_test)
    assert isinstance(prediction, cupy.ndarray)
    if model_key == 'RandomForestClassifier':
        pytest.skip("RandomForestClassifier is not yet supported"
                    "by the Pipeline utility")
    _ = pipe.score(X_test, y_test)