energy_fault_detector.core.fault_detection_model
Template for anomaly detection models
- class FaultDetectionModel(config=None, model_directory='models')
Bases:
ABCTemplate for fault detection models. Train and predicts should be implemented.
- Parameters:
- anomaly_score
AnomalyScore object.
- autoencoder
Autoencoder object.
- threshold_selector
ThresholdSelector object.
- data_preprocessor
DataPreprocessorPipeline object.
- save_timestamps
a list of string timestamps, indicating when the model was saved.
- abstractmethod fit(sensor_data, normal_index=None, asset_id=None, **kwargs)
Fit models on the given sensor_data and save them locally and return the metadata.
- Parameters:
asset_id (
Union[int,str]) – asset ID of the asset for which the model should be trained.sensor_data (
DataFrame) – pandas DataFrame with the sensor data to use. The time stamp should be the index and the sensor values as columns.normal_index (
Series) – a pandas Series indicating normal behaviour as boolean with the timestamp as index.
- Return type:
- Returns:
ModelMetadata object.
- load_models(model_path)
Load saved models given the model path.
- abstractmethod predict(sensor_data, model_path=None, asset_id=None)
Predict with given models for specific asset ID. Return dictionary with results.
- Parameters:
- Return type:
- Returns:
FaultDetectionResult object.
- save_models(model_name=None, overwrite=False)
Save the model objects. Model files are saved in self.model_directory/model_name/datetime if overwrite is set to False, otherwise, they are saved in self.model_directory/model_name
- Parameters:
model_name (optional str) – model name, will be the directory in which the model files are saved. Changes model path to self.model_directory/model_name. Defaults to None.
overwrite (optional bool) – If True existing folders can be overwritten. Default: False
- Return type:
- Returns:
The full path to the saved models and the timestamp of the function call in string format.
- train(sensor_data, normal_index=None, asset_id=None, **kwargs)
Same as the fit-method.
- Return type: