File size: 4,893 Bytes
a178367
 
 
 
 
43f3a5b
 
 
a178367
 
43f3a5b
a178367
 
 
 
43f3a5b
 
 
 
a178367
43f3a5b
c1412d9
43f3a5b
 
c1412d9
a178367
43f3a5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efcd9d9
43f3a5b
 
 
 
 
a178367
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43f3a5b
a178367
 
43f3a5b
 
 
a178367
 
 
c1412d9
 
 
 
 
 
 
 
43f3a5b
 
a178367
 
 
 
 
 
 
 
 
43f3a5b
a178367
 
 
 
 
43f3a5b
a178367
 
 
 
 
43f3a5b
a178367
 
 
 
 
43f3a5b
a178367
 
 
 
 
43f3a5b
a178367
 
43f3a5b
 
 
a178367
43f3a5b
a178367
 
43f3a5b
 
 
 
 
 
a178367
 
 
 
 
c1412d9
 
 
43f3a5b
 
 
a178367
 
 
43f3a5b
 
 
 
a178367
43f3a5b
 
 
 
 
 
c1412d9
43f3a5b
c1412d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43f3a5b
 
 
 
a178367
43f3a5b
a178367
43f3a5b
c1412d9
43f3a5b
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

# ==========================================================
# PAGE CONFIGURATION
# ==========================================================

st.set_page_config(
    page_title="Predictive Maintenance System",
    page_icon="πŸš—",
    layout="centered"
)

# ==========================================================
# TITLE
# ==========================================================

st.title("πŸš— Predictive Maintenance System")

st.write("""
This application predicts whether an engine requires maintenance
based on its sensor readings using a trained **AdaBoost Classifier**.
""")

# ==========================================================
# SIDEBAR
# ==========================================================

st.sidebar.title("πŸ“Œ Project Information")

st.sidebar.markdown("""
### πŸ€– Model
AdaBoost Classifier

### 🎯 Model Accuracy
**66.75%**

### πŸ“Š Dataset
Predictive Maintenance Dataset

### πŸš€ Deployment
Hugging Face Spaces

### πŸ‘©β€πŸ’» Developed By
Brijesh Pandey
""")

# ==========================================================
# LOAD MODEL
# ==========================================================

MODEL_REPO = "killswitch009/predictive-maintenance-model"
MODEL_FILE = "best_model.pkl"

@st.cache_resource
def load_model():
    model_path = hf_hub_download(
        repo_id=MODEL_REPO,
        filename=MODEL_FILE
    )
    return joblib.load(model_path)

try:
    model = load_model()
    st.success("βœ… Model loaded successfully!")
except Exception as e:
    st.error(f"Unable to load model.\n\n{e}")
    st.stop()

# ==========================================================
# USER INPUTS
# ==========================================================

st.header("Enter Engine Sensor Values")

with st.expander("πŸ“‹ Example Sensor Values", expanded=True):
    st.markdown("""
- **Engine RPM:** 700
- **Lub Oil Pressure:** 2.5
- **Fuel Pressure:** 12
- **Coolant Pressure:** 3.2
- **Lub Oil Temperature:** 84
- **Coolant Temperature:** 82
""")

engine_rpm = st.number_input(
    "Engine RPM",
    min_value=0,
    value=800
)

lub_pressure = st.number_input(
    "Lub Oil Pressure",
    min_value=0.0,
    value=3.20
)

fuel_pressure = st.number_input(
    "Fuel Pressure",
    min_value=0.0,
    value=6.50
)

coolant_pressure = st.number_input(
    "Coolant Pressure",
    min_value=0.0,
    value=2.30
)

lub_temp = st.number_input(
    "Lub Oil Temperature",
    min_value=0.0,
    value=77.00
)

coolant_temp = st.number_input(
    "Coolant Temperature",
    min_value=0.0,
    value=78.00
)

# ==========================================================
# PREDICTION
# ==========================================================

if st.button("πŸ” Predict Engine Condition", use_container_width=True):

    input_data = pd.DataFrame({
        "Engine rpm": [engine_rpm],
        "Lub oil pressure": [lub_pressure],
        "Fuel pressure": [fuel_pressure],
        "Coolant pressure": [coolant_pressure],
        "lub oil temp": [lub_temp],
        "Coolant temp": [coolant_temp]
    })

    prediction = model.predict(input_data)[0]
    probability = model.predict_proba(input_data)[0]

    healthy_prob = probability[0] * 100
    maintenance_prob = probability[1] * 100

    st.divider()

    st.header("Prediction Result")

    if prediction == 1:
        st.error("⚠️ Engine Requires Maintenance")
        st.warning(
            "The sensor readings indicate that the engine may require maintenance. "
            "A detailed inspection is recommended."
        )
    else:
        st.success("βœ… Engine is Operating Normally")

    st.divider()

    st.header("Prediction Confidence")

    col1, col2 = st.columns(2)

    with col1:
        st.metric(
            label="βœ… Healthy Engine",
            value=f"{healthy_prob:.2f}%"
        )

    with col2:
        st.metric(
            label="⚠️ Maintenance Required",
            value=f"{maintenance_prob:.2f}%"
        )

    st.divider()

    st.subheader("Summary")

    if prediction == 1:
        st.markdown(f"""
- **Prediction:** Engine Requires Maintenance
- **Healthy Probability:** **{healthy_prob:.2f}%**
- **Maintenance Probability:** **{maintenance_prob:.2f}%**
- **Recommendation:** Schedule maintenance as soon as possible.
""")
    else:
        st.markdown(f"""
- **Prediction:** Engine Operating Normally
- **Healthy Probability:** **{healthy_prob:.2f}%**
- **Maintenance Probability:** **{maintenance_prob:.2f}%**
- **Recommendation:** Continue normal operation and routine monitoring.
""")

# ==========================================================
# FOOTER
# ==========================================================

st.markdown("---")

st.caption(
    "Developed by Brijesh Pandey | Python β€’ Scikit-learn β€’ Streamlit β€’ Hugging Face"
)