Spaces:
Sleeping
Sleeping
File size: 1,670 Bytes
9627b36 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import numpy as np
import pandas as pd
from tensorflow.keras.models import load_model
class EnergyPredictionNorth:
"""
Class for predicting energy consumption in the north wing of the building.
"""
def __init__(self,
model_path=None):
"""
Initialize the EnergyPredictionNorth object.
Args:
model_path (str): Path to the prediction model file.
"""
if model_path is not None:
self.load_model(model_path)
def load_model(self, model_path):
"""
Load the prediction model.
Args:
model_path (str): Path to the prediction model file.
"""
self.model = load_model(model_path)
def predict(self, data):
"""
Predict energy consumption based on the input data.
Args:
data (pd.DataFrame): Input data for prediction.
Returns:
np.ndarray: Predicted energy consumption values.
"""
return self.model.predict(data, verbose=0)
def inverse_transform(self, scaler, pred, df_trans):
"""
Inverse transform the predicted and actual values.
Args:
scaler (object): Scaler object for inverse transformation.
pred (array): Predicted values.
df_trans (DataFrame): Transformed input data.
Returns:
tuple: A tuple containing the actual and predicted values after inverse transformation.
"""
mean = scaler.mean_[0]
std = scaler.scale_[0]
pred = pred * std + mean
actual = df_trans[:,0] * std + mean
return actual, pred |