@@ -0,0 +1,1928 @@
+import pandas as pd%0A%0A%0Aclass TraceModeler(object):%0A%0A    freq_str = None%0A%0A    def __init__(self, model, modeling_period, trace):%0A        self.model = model%0A        self.modeling_period = modeling_period%0A        self.trace = trace%0A        self.params = None%0A        self.invalid_fit = None%0A%0A    def create_model_input(self, weather_source):%0A        '''Return a %60DatetimeIndex%60ed dataframe containing necessary model data%0A        '''%0A        trace_values = self.trace.data.value.resample(self.freq_str).sum()%0A        temp_values = weather_source.indexed_temperatures(trace_values.index,%0A                                                          %22degF%22)%0A%0A        return pd.DataFrame(%7B%22tempF%22: temp_values, %22energy%22: trace_values%7D,%0A                            columns=%5B%22energy%22, %22tempF%22%5D)%0A%0A    def create_demand_fixture(self, weather_fixture_source, index):%0A        temp_values = weather_fixture_source %5C%0A            .indexed_temperatures(index, %22degF%22)%0A%0A        return pd.DataFrame(%7B%22tempF%22: temp_values%7D)%0A%0A    def evaluate(self, df):%0A        try:%0A            params, cvrmse, r2 = self.model.fit(df)%0A        except ValueError:%0A            # fit failed, probably because of insufficient data.%0A            self.invalid_fit = True%0A            return None, None, None%0A        else:%0A            self.invalid_fit = False%0A            self.params = params%0A            return params, r2, cvrmse%0A%0A    def predict(self, df):%0A        if self.invalid_fit is None:%0A            message = (%0A                'Please, run %60modeler.evaluate()%60 before predicting.'%0A            )%0A            raise ValueError(message)%0A        elif self.invalid_fit:%0A            message = (%0A                'Fit invalid, please check input data.'%0A                ' Cannot call %60.predict()%60 without a valid fit.'%0A            )%0A            raise ValueError(message)%0A%0A        return self.model.predict(df, self.params)%0A%0A%0Aclass DailyModeler(TraceModeler):%0A%0A    freq_str = %22D%22%0A

Add modelers