DSatishchandra commited on
Commit
79404a1
Β·
verified Β·
1 Parent(s): ea7776b

Update models/energy_anomaly_detection.py

Browse files
Files changed (1) hide show
  1. models/energy_anomaly_detection.py +2 -2
models/energy_anomaly_detection.py CHANGED
@@ -27,7 +27,7 @@ def detect_energy_anomalies(file_path):
27
  Returns:
28
  - anomaly (str): Energy anomaly detection result
29
  """
30
- # Load energy generation data (assumes CSV format with timestamp and generation columns)
31
  if not os.path.exists(file_path):
32
  raise FileNotFoundError(f"Error: Data file {file_path} not found.")
33
  try:
@@ -57,7 +57,7 @@ def detect_energy_anomalies(file_path):
57
  prediction = model.predict(X)
58
  last_predicted_value = prediction[-1][0] # Get last prediction
59
 
60
- # Define threshold for anomaly (e.g., 10% deviation from the normal value)
61
  threshold = 0.1
62
  anomaly = "Anomaly Detected" if abs(last_predicted_value - energy_data[-1][0]) > threshold else "No Anomaly"
63
 
 
27
  Returns:
28
  - anomaly (str): Energy anomaly detection result
29
  """
30
+ # Load energy generation data
31
  if not os.path.exists(file_path):
32
  raise FileNotFoundError(f"Error: Data file {file_path} not found.")
33
  try:
 
57
  prediction = model.predict(X)
58
  last_predicted_value = prediction[-1][0] # Get last prediction
59
 
60
+ # Define threshold for anomaly
61
  threshold = 0.1
62
  anomaly = "Anomaly Detected" if abs(last_predicted_value - energy_data[-1][0]) > threshold else "No Anomaly"
63