File size: 1,287 Bytes
2a3cbd5
 
 
 
 
 
 
 
 
 
 
 
 
 
c4e6ab0
 
1ec0728
 
2a3cbd5
1ec0728
2a3cbd5
1ec0728
 
2a3cbd5
1ec0728
2a3cbd5
1ec0728
 
2a3cbd5
1ec0728
2a3cbd5
 
1ec0728
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# risk_model.py
import numpy as np

def predict_risk(temp, duration):
    """
    Predicts the risk level, risk score, and alert for a given temperature and duration.

    Args:
    - temp (float): The maximum temperature of the heating mantle.
    - duration (float): The duration the mantle is used.

    Returns:
    - tuple: (risk_level, risk_score, alert)
    """
    
    # Define risk level, score, and alert based on temperature and duration conditions
    if temp <= 100 and duration <= 45:
        # Low Risk: temperature between 0°C and 100°C, and duration <= 45 minutes
        risk_level = "Low"
        risk_score = np.random.uniform(0, 33)  # Low risk score (0 to 33%)
        alert = "Safe"
    elif 101 <= temp <= 150 and 46 <= duration <= 70:
        # Moderate Risk: temperature between 101°C and 150°C, and duration between 46 and 70 minutes
        risk_level = "Moderate"
        risk_score = np.random.uniform(34, 66)  # Moderate risk score (34 to 66%)
        alert = "Risk"
    else:
        # High Risk: temperature between 151°C and 200°C, and duration > 70 minutes
        risk_level = "High"
        risk_score = np.random.uniform(67, 100)  # High risk score (67 to 100%)
        alert = "High Risk"

    return risk_level, round(risk_score, 2), alert