From f1f0d993f51da6dfb34f39439dcf9552c06f2d0c Mon Sep 17 00:00:00 2001 From: Gregor Roth Date: Tue, 3 Jan 2023 10:33:56 +0100 Subject: [PATCH] scoring function improved --- pvpower/estimator.py | 4 ++-- pvpower/trainingcenter.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pvpower/estimator.py b/pvpower/estimator.py index 4b656e2..141b0a2 100644 --- a/pvpower/estimator.py +++ b/pvpower/estimator.py @@ -207,7 +207,7 @@ def num_samples_last_train(self) -> int: def retrain(self, train_data: TrainData): start = time.time() samples = train_data.samples - samples = [sample for sample in samples if sample.irradiance > 0] # do not train the estimator for zero irradiance + samples = [sample for sample in samples if sample.irradiance > 0] # special handling zero irradiance records feature_vector_list = [self.__vectorizer.vectorize(sample) for sample in samples] label_list = [sample.power_watt for sample in samples] if len(set(label_list)) > 1: @@ -223,7 +223,7 @@ def retrain(self, train_data: TrainData): logging.debug("estimator can not be trained. Insufficient train data") def predict(self, sample: WeatherForecast) -> int: - if sample.irradiance > 0: # shortcut. no irradiance means no power + if sample.irradiance > 0: # special handling zero irradiance records. no irradiance means no power if self.__num_samples_last_train < 1: logging.warning("estimator has not been trained (insufficient train data available). returning 0") return 0 diff --git a/pvpower/trainingcenter.py b/pvpower/trainingcenter.py index 8ca1f92..4acc366 100644 --- a/pvpower/trainingcenter.py +++ b/pvpower/trainingcenter.py @@ -28,7 +28,7 @@ def score(self) -> float: continue scores.append(self.__score(real, predicted)) scores_without_outliners = self.__without_outliners(scores, 0.1) - return mean(scores_without_outliners) + return round(mean(scores_without_outliners), 2) @staticmethod def __without_outliners(scores: List[int], percent: float) -> List[int]: