diff --git a/pvpower/estimator.py b/pvpower/estimator.py index d662bbb..4b656e2 100644 --- a/pvpower/estimator.py +++ b/pvpower/estimator.py @@ -28,7 +28,7 @@ class CoreVectorizer(Vectorizer): def vectorize(self, sample: WeatherForecast) -> List[float]: vectorized = [self._scale(sample.time_utc.month, 12), - self._scale(12-abs(12-sample.time_utc.hour), 12), + self._scale(sample.time_utc.hour, 24), self._scale(sample.irradiance, 1000)] return vectorized @@ -207,6 +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 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: diff --git a/pvpower/trainingcenter.py b/pvpower/trainingcenter.py index d9f924f..8ca1f92 100644 --- a/pvpower/trainingcenter.py +++ b/pvpower/trainingcenter.py @@ -15,9 +15,8 @@ def __init__(self, estimator: Estimator, train_data: TrainData): self.predictions = [estimator.predict(validation_record) for validation_record in self.validation_samples] self.estimator.retrain(train_data) # retrain with all data - def __score(self, real, predicted): - distance = abs(real - predicted) - return distance + def __score(self, real, predicted)-> int: + return round(abs(real - predicted) / 10)*10 @property def score(self) -> float: @@ -28,8 +27,8 @@ def score(self) -> float: if real == 0 and predicted == 0: # do not waste the total score by true zero predictions continue scores.append(self.__score(real, predicted)) - scores = self.__without_outliners(scores, 0.1) - return mean(scores) + scores_without_outliners = self.__without_outliners(scores, 0.1) + return mean(scores_without_outliners) @staticmethod def __without_outliners(scores: List[int], percent: float) -> List[int]: