From 86e420bd0ae368e73400777c36f3ac34f9ef416a Mon Sep 17 00:00:00 2001 From: sosokker Date: Fri, 10 May 2024 23:58:12 +0700 Subject: [PATCH] Add xgboost regression class --- .../src/analytic/health/indoor_model.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 StreamServer/src/analytic/health/indoor_model.py diff --git a/StreamServer/src/analytic/health/indoor_model.py b/StreamServer/src/analytic/health/indoor_model.py new file mode 100644 index 0000000..674e45b --- /dev/null +++ b/StreamServer/src/analytic/health/indoor_model.py @@ -0,0 +1,19 @@ +import joblib + + +class XgboostIndoorModel: + MODEL_PATH = 'xgboost_model.pkl' + + def __init__(self): + self.__model = joblib.load(self.MODEL_PATH) + + def predict(self, X: list) -> float: + """ + Predict the indoor temperature based on the input features + Input order : ['outdoor_temp', 'outdoor_feels_like', 'outdoor_pressure', + 'outdoor_humidity', 'outdoor_pm25', 'outdoor_pm10'] + """ + if len(X) != 6: + raise ValueError(f"Expected 6 features, got {len(X)}") + + return self.__model.predict([X])[0] \ No newline at end of file