Skip to content

Commit

Permalink
bumped toolbox
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahannes committed Jun 24, 2024
1 parent 66590aa commit 7f2e8a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
17 changes: 11 additions & 6 deletions algo/curve_anomaly/cont_det/online_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ def check(self, value, timestamp):
util.logger.debug("Model is not available. Skip inference")
return False, ''

util.logger.debug(f"First Data Point: {self.data_list[0]} - Last Data Point: {self.data_list[-1]}")
if self.data_list[-1][0] - self.data_list[0][0] < pd.Timedelta(4, "h"):
util.logger.debug("Not enough data for inference. Need at least 4 hours")

if not self.inference_shall_start():
return False, ''

anomalies, self.reconstruction_errors = self.test(self.data_list, self.model)
Expand All @@ -78,7 +77,14 @@ def check(self, value, timestamp):
return True, self.create_result(f'In der Zeit seit {str(time_window_start)} wurde eine Anomalie im Lastprofil festgestellt.', str(time_window_start), "continous_device")

return False, ''


def inference_shall_start(self):
util.logger.debug(f"First Data Point: {self.data_list[0]} - Last Data Point: {self.data_list[-1]}")
if self.data_list[-1][0] - self.data_list[0][0] < pd.Timedelta(4, "h"):
util.logger.debug("Not enough data for inference. Need at least 4 hours")
return False
return True

def start_training(self, timestamp):
topic_name, path_to_time, path_to_value = self._get_input_topic()
job_request = {
Expand All @@ -88,7 +94,7 @@ def start_training(self, timestamp):
"window_length": 205,
"batch_size": 1,
"lr": 0.0001,
"num_epochs": 20,
"num_epochs": 2, # TODO increase prod
"loss": "MSE",
"op": "Adam",
"latent_dims": 32,
Expand Down Expand Up @@ -121,7 +127,6 @@ def start_training(self, timestamp):
}
self.trainer.start_training(job_request)
self.last_training_time = timestamp


def load_model(self):
# TODO christoph doch lieber model abspeichern beim stoppen und laden
Expand Down
24 changes: 13 additions & 11 deletions algo/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ def parse_bool(value):

class CustomConfig(Config):
data_path = "/opt/data"
check_data_anomalies: bool = False
check_data_extreme_outlier: bool = True
check_data_schema: bool = True
check_receive_time_outlier: bool = True
check_consumption: bool = False
init_phase_length: float = 2
check_data_anomalies: bool = False # Detect complex anomalies based on the curve are detected
check_data_extreme_outlier: bool = True # Detect extreme point outlier based on simple statistics
check_data_schema: bool = True # Detect wrong input
check_receive_time_outlier: bool = True # Detect anomalies in the time between inputs
check_consumption: bool = False #
init_phase_length: float = 2 # How long the complete operator is init phase
init_phase_level: str = "d"
train_interval: float = 14
train_interval: float = 14 # How long curve explorere waits until it starts training & optional retraining
train_level: str = "d"
retrain: bool = False
ml_trainer_url: str = "http://ml-trainer-svc.trainer:5000"
mlflow_url: str = "http://mlflow-svc.mlflow:5000"
curve_detector_training_mode: str = "offline"
inference_time: float = 1 # How long operator waits until it starts inference. Should match with the model architecture
inference_time_level: str = "s"
retrain: bool = False # Only train once in the beginning or retrain periodically
ml_trainer_url: str = "http://ml-trainer-svc.trainer:5000" # URL to the Trainer API
mlflow_url: str = "http://mlflow-svc.mlflow:5000" # URL for MLFlow to download the model
curve_detector_training_mode: str = "offline" # Train inside the operator or use the training platform

def __init__(self, d, **kwargs):
super().__init__(d, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
git+https://github.com/SENERGY-Platform/[email protected]
toolbox[anomaly_detection] @ git+https://github.com/SENERGY-Platform/[email protected].74
toolbox[anomaly_detection] @ git+https://github.com/SENERGY-Platform/[email protected].76

pandas<2
pandas==2.2.2
kazoo<3
astral
pytz
Expand Down

0 comments on commit 7f2e8a2

Please sign in to comment.