Spaces:
Sleeping
Sleeping
Update risk_model.py
Browse files- risk_model.py +10 -15
risk_model.py
CHANGED
|
@@ -14,25 +14,20 @@ def predict_risk(temp, duration):
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
# Define risk level, score, and alert based on temperature and duration conditions
|
| 17 |
-
if temp <=
|
| 18 |
-
# Low Risk: temperature
|
| 19 |
risk_level = "Low"
|
| 20 |
-
risk_score =
|
| 21 |
alert = "Safe"
|
| 22 |
-
elif
|
| 23 |
-
# Moderate Risk: temperature between
|
| 24 |
risk_level = "Moderate"
|
| 25 |
-
risk_score =
|
| 26 |
alert = "Risk"
|
| 27 |
-
|
| 28 |
-
# High Risk: temperature
|
| 29 |
risk_level = "High"
|
| 30 |
-
risk_score =
|
| 31 |
alert = "High Risk"
|
| 32 |
-
else:
|
| 33 |
-
# Conditions between Moderate and High Risk
|
| 34 |
-
risk_level = "Moderate"
|
| 35 |
-
risk_score = round(np.random.uniform(40, 70), 2) # Moderate risk score (40 to 70%)
|
| 36 |
-
alert = "Risk"
|
| 37 |
|
| 38 |
-
return risk_level, risk_score, alert
|
|
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
# Define risk level, score, and alert based on temperature and duration conditions
|
| 17 |
+
if temp <= 100 and duration <= 45:
|
| 18 |
+
# Low Risk: temperature between 0°C and 100°C, and duration <= 45 minutes
|
| 19 |
risk_level = "Low"
|
| 20 |
+
risk_score = np.random.uniform(0, 33) # Low risk score (0 to 33%)
|
| 21 |
alert = "Safe"
|
| 22 |
+
elif 101 <= temp <= 150 and 46 <= duration <= 70:
|
| 23 |
+
# Moderate Risk: temperature between 101°C and 150°C, and duration between 46 and 70 minutes
|
| 24 |
risk_level = "Moderate"
|
| 25 |
+
risk_score = np.random.uniform(34, 66) # Moderate risk score (34 to 66%)
|
| 26 |
alert = "Risk"
|
| 27 |
+
else:
|
| 28 |
+
# High Risk: temperature between 151°C and 200°C, and duration > 70 minutes
|
| 29 |
risk_level = "High"
|
| 30 |
+
risk_score = np.random.uniform(67, 100) # High risk score (67 to 100%)
|
| 31 |
alert = "High Risk"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
return risk_level, round(risk_score, 2), alert
|