Exemplo n.º 1
0
def test_basic_billing(input_billing_df, monkeypatch_temperature_data,
                       mock_isd_weather_source):
    m = CaltrackMonthlyModel(fit_cdd=True)
    assert str(m).startswith("Caltrack")
    assert m.n is None
    assert m.params is None
    assert m.r2 is None
    assert m.rmse is None
    assert m.y is None

    output = m.fit(input_billing_df)

    assert "r2" in output
    assert "rmse" in output
    assert "cvrmse" in output
    assert "model_params" in output
    assert "n" in output

    assert 'formula' in m.params
    assert 'X_design_info' in m.params
    assert 'coefficients' in m.params

    index = pd.date_range('2011-01-01', freq='D', periods=365, tz=pytz.UTC)
    formatter = ModelDataBillingFormatter()
    formatted_predict_data = formatter.create_demand_fixture(
        index, mock_isd_weather_source)

    outputs, variance = m.predict(formatted_predict_data, summed=False)
    assert outputs.shape == (365, )
    assert all(variance > 0)

    outputs, variance = m.predict(formatted_predict_data, summed=True)
    assert outputs > 0
    assert variance > 0
Exemplo n.º 2
0
def test_basic_usage(trace, monkeypatch_temperature_data,
                     mock_isd_weather_source):
    formatter = ModelDataBillingFormatter()
    model = BillingElasticNetCVModel(65, 65)

    formatted_input_data = formatter.create_input(trace,
                                                  mock_isd_weather_source)

    outputs = model.fit(formatted_input_data)
    assert 'upper' in outputs
    assert 'lower' in outputs
    assert 'n' in outputs
    assert 'r2' in outputs
    assert 'rmse' in outputs
    assert 'cvrmse' in outputs
    assert 'model_params' in outputs

    index = pd.date_range('2011-01-01',
                          freq='H',
                          periods=365 * 24,
                          tz=pytz.UTC)
    formatted_predict_data = formatter.create_demand_fixture(
        index, mock_isd_weather_source)

    outputs, variance = model.predict(formatted_predict_data, summed=False)
    assert outputs.shape == (365, )
    assert variance > 0

    index = pd.date_range('2011-01-01', freq='D', periods=365, tz=pytz.UTC)
    formatted_predict_data = formatter.create_demand_fixture(
        index, mock_isd_weather_source)

    outputs, variance = model.predict(formatted_predict_data, summed=False)
    assert outputs.shape == (365, )
    assert variance > 0

    outputs, variance = model.predict(formatted_predict_data, summed=True)
    assert outputs > 0
    assert variance > 0

    assert "ModelDataBillingFormatter" in str(ModelDataBillingFormatter)
Exemplo n.º 3
0
def test_basic_usage(trace, mock_isd_weather_source):
    formatter = ModelDataBillingFormatter()
    model = BillingElasticNetCVModel(65, 65)

    formatted_input_data = formatter.create_input(
        trace, mock_isd_weather_source)

    outputs = model.fit(formatted_input_data)
    assert 'upper' in outputs
    assert 'lower' in outputs
    assert 'n' in outputs
    assert 'r2' in outputs
    assert 'rmse' in outputs
    assert 'cvrmse' in outputs
    assert 'model_params' in outputs

    index = pd.date_range('2011-01-01', freq='H', periods=365*24, tz=pytz.UTC)
    formatted_predict_data = formatter.create_demand_fixture(
        index, mock_isd_weather_source)

    outputs = model.predict(formatted_predict_data)
    assert outputs.shape == (365,)

    assert "ModelDataBillingFormatter" in str(ModelDataBillingFormatter)