Ejemplo n.º 1
0
def test_predict(input_df):
    model = HourlyDayOfWeekModel(min_contiguous_months=0)
    model.fit(input_df)

    # Test cases on the output data types of predict function.
    # When summed = True, prediction and variance are atomic
    # floating point numbers
    prediction, variance= model.predict(input_df, summed=True)
    assert type(prediction) == np.float64
    #assert type(variance) == np.float64

    # When summed=False, prediction and variance are pandas Series.
    prediction, variance= model.predict(input_df, summed=False)
    assert type(prediction) == pd.Series
    assert type(variance) == pd.Series
    # We expect out linear regression model to make prediction between 0.95 & 2.0 because the energy
    # consumed in input_df dataframe is always 1.0, please take a look at hourly_trace_with_dummy_energy function
    assert prediction[0].item() > 0.95 and prediction[0].item()  < 2.0
Ejemplo n.º 2
0
def test_min_contiguous_months(input_df):
    min_contiguous_months = 9
    model = HourlyDayOfWeekModel(min_contiguous_months=min_contiguous_months)
    with pytest.raises(model_exceptions.DataSufficiencyException) as sufficiency_exception:
        model.fit(input_df)