Example #1
0
def test_own_regression_reports():
    """
    testing regressor.test_on
    """
    X, y, sample_weight = generate_regression_data()
    regressor = SklearnRegressor(RandomForestRegressor())
    regressor.fit(X, y, sample_weight=sample_weight)
    report = regressor.test_on(X, y, sample_weight=sample_weight)
    mse1 = report.compute_metric(mean_squared_error)

    lds = LabeledDataStorage(X, y, sample_weight=sample_weight)
    mse2 = regressor.test_on_lds(lds=lds).compute_metric(mean_squared_error)
    assert mse1 == mse2, 'Something wrong with test_on'
Example #2
0
def test_own_regression_reports():
    """
    testing regressor.test_on
    """
    X, y, sample_weight = generate_regression_data()
    regressor = SklearnRegressor(RandomForestRegressor())
    regressor.fit(X, y, sample_weight=sample_weight)
    report = regressor.test_on(X, y, sample_weight=sample_weight)
    mse1 = report.compute_metric(mean_squared_error)

    lds = LabeledDataStorage(X, y, sample_weight=sample_weight)
    mse2 = regressor.test_on_lds(lds=lds).compute_metric(mean_squared_error)
    assert mse1 == mse2, 'Something wrong with test_on'
Example #3
0
def check_grid(estimator, check_instance=True, has_staged_pp=True, has_importances=True, use_weights=False,
               classification=True):
    if classification:
        X, y, sample_weight = generate_classification_data()
    else:
        X, y, sample_weight = generate_regression_data()
    assert len(sample_weight) == len(X), 'somehow lengths are different'

    if use_weights:
        assert estimator == estimator.fit(X, y, sample_weight=sample_weight)
        estimator = estimator.fit_best_estimator(X, y, sample_weight=sample_weight)
    else:
        assert estimator == estimator.fit(X, y)
        estimator = estimator.fit_best_estimator(X, y)

    if classification:
        check_classification_model(estimator, X, y, check_instance=check_instance, has_staged_pp=has_staged_pp,
                                   has_importances=has_importances)
    else:
        check_regression_model(estimator, X, y, check_instance=check_instance, has_stages=has_staged_pp,
                               has_importances=has_importances)

    return estimator
Example #4
0
def check_grid(estimator,
               check_instance=True,
               has_staged_pp=True,
               has_importances=True,
               use_weights=False,
               classification=True):
    if classification:
        X, y, sample_weight = generate_classification_data()
    else:
        X, y, sample_weight = generate_regression_data()
    assert len(sample_weight) == len(X), 'somehow lengths are different'

    if use_weights:
        assert estimator == estimator.fit(X, y, sample_weight=sample_weight)
        estimator = estimator.fit_best_estimator(X,
                                                 y,
                                                 sample_weight=sample_weight)
    else:
        assert estimator == estimator.fit(X, y)
        estimator = estimator.fit_best_estimator(X, y)

    if classification:
        check_classification_model(estimator,
                                   X,
                                   y,
                                   check_instance=check_instance,
                                   has_staged_pp=has_staged_pp,
                                   has_importances=has_importances)
    else:
        check_regression_model(estimator,
                               X,
                               y,
                               check_instance=check_instance,
                               has_stages=has_staged_pp,
                               has_importances=has_importances)

    return estimator
Example #5
0
def test_Exception_reg_feature_importances():
    X, _, _ = generate_regression_data()
    cl = MatrixNetRegressor(api_config_file=CONFIG_FILE_WRONG_URL, iterations=50)
    print(cl.feature_importances_)
Example #6
0
def test_Exception_reg_staged_predict():
    X, _, _ = generate_regression_data()
    cl = MatrixNetRegressor(api_config_file=CONFIG_FILE_WRONG_URL, iterations=50)
    for _ in cl.staged_predict(X):
        pass
Example #7
0
def test_Exception_reg_synchronized():
    X, _, _ = generate_regression_data()
    cl = MatrixNetRegressor(api_config_file=CONFIG_FILE_WRONG_URL, iterations=50)
    cl.synchronize()
Example #8
0
def test_Exception_reg_trained_status():
    X, _, _ = generate_regression_data()
    cl = MatrixNetRegressor(api_config_file=CONFIG_FILE_WRONG_URL, iterations=50)
    cl.training_status()