Ejemplo n.º 1
0
def test_fit_caltrack_hourly_model_segment(segmented_design_matrices):
    segment_name = "dec-jan-feb-weighted"
    segment_data = segmented_design_matrices[segment_name]
    segment_model = fit_caltrack_hourly_model_segment(segment_name,
                                                      segment_data)
    assert segment_model.formula == (
        "meter_value ~ C(hour_of_week) - 1 + bin_0:C(occupancy)"
        " + bin_1:C(occupancy) + bin_2:C(occupancy) + bin_3:C(occupancy)")
    assert segment_model.segment_name == "dec-jan-feb-weighted"
    assert len(segment_model.model_params.keys()) == 32
    assert segment_model.model is not None
    assert segment_model.warnings is not None
    prediction = segment_model.predict(segment_data)
    assert round(prediction.sum(), 2) == 960.0
Ejemplo n.º 2
0
def test_fit_caltrack_hourly_model_segment_single_mode(
        segmented_design_matrices_single_mode):
    segment_name = "dec-jan-feb-weighted"
    segment_data = segmented_design_matrices_single_mode[segment_name]
    segment_model = fit_caltrack_hourly_model_segment(segment_name,
                                                      segment_data)
    assert segment_model.formula == (
        "meter_value ~ C(hour_of_week) - 1 + bin_0_occupied + bin_1_occupied"
        " + bin_2_occupied + bin_3_occupied + bin_0_unoccupied + bin_1_unoccupied"
        " + bin_2_unoccupied")
    assert segment_model.segment_name == "dec-jan-feb-weighted"
    assert len(segment_model.model_params.keys()) == 31
    assert segment_model.model is not None
    assert segment_model.warnings is not None
    prediction = segment_model.predict(segment_data)
    assert round(prediction.sum(), 2) == 960.0