File size: 2,446 Bytes
de0a31f
 
 
 
 
 
 
d26d48a
de0a31f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib

# Download the model from the Model Hub
model_path = hf_hub_download(
    repo_id="adityapvdp/engine-predictive-maintainance-model",
    filename="best_engine_prediction_model_v1.joblib"
)

# Load the model
model = joblib.load(model_path)

# Streamlit UI for Engine Fault Prediction
st.title("Engine Fault Prediction App")
st.write(
    "The Engine Fault Prediction App is an internal tool that predicts whether an engine is likely to be faulty "
    "based on its operational sensor readings."
)
st.write("Enter the engine parameters below to check the predicted engine condition.")

# Collect user input
engine_rpm = st.number_input(
    "Engine RPM (engine speed in revolutions per minute)",
    min_value=0.0,
    value=791.0
)

lub_oil_pressure = st.number_input(
    "Lub Oil Pressure (lubricating oil pressure in bar/kPa)",
    min_value=0.0,
    value=3.30
)

fuel_pressure = st.number_input(
    "Fuel Pressure (fuel supply pressure in bar/kPa)",
    min_value=0.0,
    value=6.65
)

coolant_pressure = st.number_input(
    "Coolant Pressure (coolant system pressure in bar/kPa)",
    min_value=0.0,
    value=2.33
)

lub_oil_temp = st.number_input(
    "Lub Oil Temperature (lubricating oil temperature in °C)",
    min_value=0.0,
    value=77.64
)

coolant_temp = st.number_input(
    "Coolant Temperature (coolant temperature in °C)",
    min_value=0.0,
    value=78.43
)

# Create input dataframe
input_data = pd.DataFrame([{
    "Engine rpm": engine_rpm,
    "Lub oil pressure": lub_oil_pressure,
    "Fuel pressure": fuel_pressure,
    "Coolant pressure": coolant_pressure,
    "lub oil temp": lub_oil_temp,
    "Coolant temp": coolant_temp
}])

# Set classification threshold
classification_threshold = 0.45

# Predict button
if st.button("Predict"):
    prediction_proba = model.predict_proba(input_data)[0, 1]
    prediction = int(prediction_proba >= classification_threshold)

    result = "Faulty" if prediction == 1 else "Active / Normal"

    st.subheader("Prediction Result")
    st.write(f"**Predicted Engine Condition:** {result}")
    st.write(f"**Fault Probability:** {prediction_proba:.2%}")

    if prediction == 1:
        st.warning("The engine is likely to be in a faulty condition. Further inspection is recommended.")
    else:
        st.success("The engine is likely to be in an active/normal condition.")