Example #1
0
def test_init_empty():
    Predictions = make_regression()
    predictions = Predictions(n_samples=3)
    assert_array_equal(predictions.y_pred, np.array([np.nan, np.nan, np.nan]))
    # multi-target regression
    Predictions = make_regression(label_names=[1, 2, 3])
    predictions = Predictions(n_samples=4)
    assert_array_equal(
        predictions.y_pred,
        np.array([
            [np.nan, np.nan, np.nan],
            [np.nan, np.nan, np.nan],
            [np.nan, np.nan, np.nan],
            [np.nan, np.nan, np.nan],
        ]))
Example #2
0
def test_set_valid_in_train2():
    Predictions = make_regression()
    predictions = Predictions(n_samples=4)
    y_pred = [0.7, 0.1, 0.2]
    predictions_valid = Predictions(y_pred=y_pred)
    predictions.set_valid_in_train(predictions_valid, [0, 2, 3])
    assert_array_equal(predictions.y_pred, np.array([0.7, np.nan, 0.1, 0.2]))
Example #3
0
def test_set_valid_in_train():
    Predictions = make_regression()
    y_pred = [0.7, 0.1, 0.2]
    predictions = Predictions(y_pred=y_pred)
    cv_y_pred = [0.6, 0.3]
    cv_predictions = Predictions(y_pred=cv_y_pred)
    updated_y_pred = [0.6, 0.1, 0.3]
    updated_predictions = Predictions(y_pred=updated_y_pred)
    predictions.set_valid_in_train(cv_predictions, [0, 2])
    assert_array_equal(predictions.y_pred, updated_predictions.y_pred)
from rampwf.utils.importing import import_file

problem_title = 'Predicting Buzz of a theme'

# -----------------------------------------------------------------------------
# Workflow
# -----------------------------------------------------------------------------

workflow = rw.workflows.FeatureExtractorRegressor()

# -------------------------------------------------------------------
# The prediction type (class) to create wrapper objects for `y_pred`,
# -------------------------------------------------------------------

Predictions = make_regression()

# -----------------------------------------------------------------------------
# Score Metrics
# -----------------------------------------------------------------------------


class R2(BaseScoreType):
    is_lower_the_better = True
    minimum = 0.0
    maximum = np.inf

    def __init__(self, name='R2', precision=2):
        self.name = name
        self.precision = precision
        self.r2_score = r2_score
Example #5
0
def test_init():
    Predictions = make_regression()
    y_pred = [0.7, 0.1, 0.2]
    predictions = Predictions(y_pred=y_pred)
    assert_array_equal(predictions.y_pred, y_pred)