Model/backend/app/BatterySapScorer.py
2025-12-10 12:33:22 +00:00

30 lines
891 B
Python

import numpy as np
class BatterySAPScorer:
"""
Lightweight production scorer — no sklearn dependency.
Uses hard-coded coefficients discovered offline. The code for discovering the coefficients
can be found in etl/battery_model/train.py
We're only concerned with SAP, as we already have a method for carbon and bill savings.
"""
INTERCEPT = 10.310168559226678
COEF_STARTING_SAP = -0.16120648633993315
COEF_PV_SIZE = 1.0500492005420736
@classmethod
def score(cls, starting_sap, pv_size):
"""
heating_system: string used to infer is_electric
"""
sap_uplift = (
cls.INTERCEPT
+ cls.COEF_STARTING_SAP * starting_sap
+ cls.COEF_PV_SIZE * pv_size
)
# Round + clamp to [0,5]
sap_uplift = int(np.round(np.clip(sap_uplift, 0, 5)))
return sap_uplift