Sirivennela commited on
Commit
1ec0728
·
verified ·
1 Parent(s): 423e505

Update risk_model.py

Browse files
Files changed (1) hide show
  1. 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 <= 160 and duration <= 45:
18
- # Low Risk: temperature <= 160°C and duration <= 45 minutes
19
  risk_level = "Low"
20
- risk_score = round(np.random.uniform(0, 40), 2) # Low risk score (0 to 40%)
21
  alert = "Safe"
22
- elif 161 <= temp <= 190 and 46 <= duration <= 90:
23
- # Moderate Risk: temperature between 161°C and 190°C and duration between 46 and 90 minutes
24
  risk_level = "Moderate"
25
- risk_score = round(np.random.uniform(40, 70), 2) # Moderate risk score (40 to 70%)
26
  alert = "Risk"
27
- elif temp > 190 and duration > 90:
28
- # High Risk: temperature > 190°C and duration > 90 minutes
29
  risk_level = "High"
30
- risk_score = round(np.random.uniform(70, 100), 2) # High risk score (70 to 100%)
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