Spaces:
Sleeping
Sleeping
Download status_evaluator.py from zaheer140/TestingLSTM: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/spaces/zaheer140/TestingLSTM/resolve/main/status_evaluator.py
- Command line
-
hf download hf://spaces/zaheer140/TestingLSTM/status_evaluator.py
-
curl -L -o status_evaluator.py https://huggingface.co/spaces/zaheer140/TestingLSTM/resolve/main/status_evaluator.py
1.6 kB
| import numpy as np | |
| from datetime import datetime | |
| def evaluate_coldroom_status(anomaly_detected, temp, is_night, is_weekend, is_peak, reconstruction_error, threshold): | |
| """ | |
| Implements the intensity math from your JavaScript snippet for Coldrooms. | |
| """ | |
| intense = 0 | |
| if anomaly_detected: | |
| intense += 2 | |
| if is_night: | |
| intense += 1 | |
| if is_weekend: | |
| intense += 1 | |
| if not is_peak and temp > 35: | |
| intense += 2 | |
| if reconstruction_error > threshold * 0.8: | |
| intense += 2 | |
| level = "Normal" | |
| if intense >= 4: | |
| level = "Critical" | |
| elif intense >= 2: | |
| level = "Warning" | |
| return intense, level | |
| def evaluate_tank_status(anomaly_detected, anomalies, is_night): | |
| """ | |
| Implements the intensity math from your JavaScript snippet for Tanks. | |
| """ | |
| intense = 0 | |
| if anomaly_detected: | |
| intense += 2 | |
| # Check for specific dangerous types | |
| has_impossible = any(a.get('type') == 'impossible_value' for a in anomalies) | |
| has_spike = any(a.get('type') == 'sudden_spike' for a in anomalies) | |
| has_fault = any(a.get('type') == 'sensor_fault' for a in anomalies) | |
| if has_impossible: | |
| intense += 2 | |
| if has_spike: | |
| intense += 1 | |
| if has_fault: | |
| intense += 1 | |
| if anomaly_detected and is_night: | |
| intense += 1 | |
| # Mapping to Level | |
| level = "Normal" | |
| if intense >= 4: | |
| level = "Critical" | |
| elif intense >= 2: | |
| level = "Warning" | |
| return intense, level | |