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 [1,5] - there are only a small number of cases with 0 points sap_uplift = int(np.round(np.clip(sap_uplift, 1, 5))) return sap_uplift