def reporting_model_hourly(il_electricity_cdd_hdd_hourly): meter_data = il_electricity_cdd_hdd_hourly["meter_data"] temperature_data = il_electricity_cdd_hdd_hourly["temperature_data"] blackout_end_date = il_electricity_cdd_hdd_hourly["blackout_end_date"] reporting_meter_data, warnings = get_reporting_data( meter_data, start=blackout_end_date) preliminary_hourly_design_matrix = create_caltrack_hourly_preliminary_design_matrix( reporting_meter_data, temperature_data) segmentation = segment_time_series(preliminary_hourly_design_matrix.index, "three_month_weighted") occupancy_lookup = estimate_hour_of_week_occupancy( preliminary_hourly_design_matrix, segmentation=segmentation) occupied_temperature_bins, unoccupied_temperature_bins = fit_temperature_bins( preliminary_hourly_design_matrix, segmentation=segmentation, occupancy_lookup=occupancy_lookup, ) design_matrices = create_caltrack_hourly_segmented_design_matrices( preliminary_hourly_design_matrix, segmentation, occupancy_lookup, occupied_temperature_bins, unoccupied_temperature_bins, ) segmented_model = fit_caltrack_hourly_model( design_matrices, occupancy_lookup, occupied_temperature_bins, unoccupied_temperature_bins, ) return segmented_model
def test_serialize_caltrack_hourly_model(segmented_design_matrices, occupancy_lookup, temperature_bins, temps): segmented_model = fit_caltrack_hourly_model(segmented_design_matrices, occupancy_lookup, temperature_bins) assert json.dumps(segmented_model.json())
def test_fit_caltrack_hourly_model(segmented_design_matrices, occupancy_lookup, temperature_bins, temps): segmented_model = fit_caltrack_hourly_model(segmented_design_matrices, occupancy_lookup, temperature_bins) assert segmented_model.segment_models is not None prediction = segmented_model.predict(temps.index, temps).result
def test_fit_caltrack_hourly_model( segmented_design_matrices, occupancy_lookup, temperature_bins, temps ): segmented_model_results = fit_caltrack_hourly_model( segmented_design_matrices, occupancy_lookup, temperature_bins ) assert segmented_model_results.model.segment_models is not None assert str(segmented_model_results).startswith("CalTRACKHourlyModelResults") prediction = segmented_model_results.predict(temps.index, temps).result
def test_predict_caltrack_hourly_model_empty_models( temps, segmented_design_matrices_empty_models, occupancy_lookup, temperature_bins ): segmented_model_results = fit_caltrack_hourly_model( segmented_design_matrices_empty_models, occupancy_lookup, temperature_bins ) assert segmented_model_results.model.segment_models is not None prediction = segmented_model_results.predict(temps.index, temps).result assert prediction.shape[0] == 24 assert prediction.dropna().shape[0] == 0
def test_fit_caltrack_hourly_model_nans_less_than_week_fit( segmented_design_matrices_nans_less_than_week, occupancy_lookup_nans_less_than_week, temperature_bins_nans_less_than_week, temps_extended, ): segmented_model = fit_caltrack_hourly_model( segmented_design_matrices_nans_less_than_week, occupancy_lookup_nans_less_than_week, temperature_bins_nans_less_than_week, ) assert segmented_model.segment_models is not None prediction = segmented_model.predict(temps_extended.index, temps_extended).result assert prediction.shape[0] == 168 assert prediction.dropna().shape[0] == 4
def test_fit_caltrack_hourly_model_nans_less_than_week_predict( segmented_design_matrices_nans, occupancy_lookup_nans, temperature_bins_nans, temps_extended, temps, ): segmented_model = fit_caltrack_hourly_model(segmented_design_matrices_nans, occupancy_lookup_nans, temperature_bins_nans) assert segmented_model.segment_models is not None assert segmented_model.model_lookup["jan"].model is not None assert segmented_model.model_lookup["may"].model is None assert (segmented_model.model_lookup["may"].warnings[0].qualified_name == "eemeter.fit_caltrack_hourly_model_segment.no_nonnull_data") prediction = segmented_model.predict(temps.index, temps).result assert prediction.shape[0] == 24 assert prediction["predicted_usage"].sum().round() == 955.0
def test_fit_caltrack_hourly_model_nans_less_than_week_predict( segmented_design_matrices_nans, occupancy_lookup_nans, temperature_bins_nans, temps_extended, temps, ): segmented_model_results = fit_caltrack_hourly_model( segmented_design_matrices_nans, occupancy_lookup_nans, temperature_bins_nans, temperature_bins_nans, ) assert segmented_model_results.model.segment_models is not None assert segmented_model_results.model.model_lookup["jan"].model is not None assert segmented_model_results.model.model_lookup["may"].model is not None assert segmented_model_results.model.model_lookup["may"].warnings == [] prediction = segmented_model_results.predict(temps.index, temps).result assert prediction.shape[0] == 24 assert prediction["predicted_usage"].sum().round() == 955.0