Update app.py
Browse files
app.py
CHANGED
|
@@ -19,12 +19,10 @@ st.set_page_config(
|
|
| 19 |
|
| 20 |
st.title("π Predictive Maintenance System")
|
| 21 |
|
| 22 |
-
st.write(
|
| 23 |
-
"""
|
| 24 |
This application predicts whether an engine requires maintenance
|
| 25 |
based on its sensor readings using a trained **AdaBoost Classifier**.
|
| 26 |
-
"""
|
| 27 |
-
)
|
| 28 |
|
| 29 |
# ==========================================================
|
| 30 |
# SIDEBAR
|
|
@@ -56,7 +54,6 @@ Brijesh Pandey
|
|
| 56 |
MODEL_REPO = "killswitch009/predictive-maintenance-model"
|
| 57 |
MODEL_FILE = "best_model.pkl"
|
| 58 |
|
| 59 |
-
|
| 60 |
@st.cache_resource
|
| 61 |
def load_model():
|
| 62 |
model_path = hf_hub_download(
|
|
@@ -65,7 +62,6 @@ def load_model():
|
|
| 65 |
)
|
| 66 |
return joblib.load(model_path)
|
| 67 |
|
| 68 |
-
|
| 69 |
try:
|
| 70 |
model = load_model()
|
| 71 |
st.success("β
Model loaded successfully!")
|
|
@@ -79,15 +75,14 @@ except Exception as e:
|
|
| 79 |
|
| 80 |
st.header("Enter Engine Sensor Values")
|
| 81 |
|
| 82 |
-
st.
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
-
|
| 86 |
-
-
|
| 87 |
-
-
|
| 88 |
-
-
|
| 89 |
-
-
|
| 90 |
-
- Coolant Temperature : **82**
|
| 91 |
""")
|
| 92 |
|
| 93 |
engine_rpm = st.number_input(
|
|
@@ -144,6 +139,9 @@ if st.button("π Predict Engine Condition", use_container_width=True):
|
|
| 144 |
prediction = model.predict(input_data)[0]
|
| 145 |
probability = model.predict_proba(input_data)[0]
|
| 146 |
|
|
|
|
|
|
|
|
|
|
| 147 |
st.divider()
|
| 148 |
|
| 149 |
st.header("Prediction Result")
|
|
@@ -156,23 +154,43 @@ if st.button("π Predict Engine Condition", use_container_width=True):
|
|
| 156 |
)
|
| 157 |
else:
|
| 158 |
st.success("β
Engine is Operating Normally")
|
| 159 |
-
st.balloons()
|
| 160 |
|
| 161 |
st.divider()
|
| 162 |
|
| 163 |
st.header("Prediction Confidence")
|
| 164 |
|
| 165 |
-
st.
|
| 166 |
-
"Healthy Engine Probability",
|
| 167 |
-
f"{probability[0]*100:.2f}%"
|
| 168 |
-
)
|
| 169 |
-
st.progress(float(probability[0]))
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
# ==========================================================
|
| 178 |
# FOOTER
|
|
@@ -181,5 +199,5 @@ if st.button("π Predict Engine Condition", use_container_width=True):
|
|
| 181 |
st.markdown("---")
|
| 182 |
|
| 183 |
st.caption(
|
| 184 |
-
"Developed by
|
| 185 |
)
|
|
|
|
| 19 |
|
| 20 |
st.title("π Predictive Maintenance System")
|
| 21 |
|
| 22 |
+
st.write("""
|
|
|
|
| 23 |
This application predicts whether an engine requires maintenance
|
| 24 |
based on its sensor readings using a trained **AdaBoost Classifier**.
|
| 25 |
+
""")
|
|
|
|
| 26 |
|
| 27 |
# ==========================================================
|
| 28 |
# SIDEBAR
|
|
|
|
| 54 |
MODEL_REPO = "killswitch009/predictive-maintenance-model"
|
| 55 |
MODEL_FILE = "best_model.pkl"
|
| 56 |
|
|
|
|
| 57 |
@st.cache_resource
|
| 58 |
def load_model():
|
| 59 |
model_path = hf_hub_download(
|
|
|
|
| 62 |
)
|
| 63 |
return joblib.load(model_path)
|
| 64 |
|
|
|
|
| 65 |
try:
|
| 66 |
model = load_model()
|
| 67 |
st.success("β
Model loaded successfully!")
|
|
|
|
| 75 |
|
| 76 |
st.header("Enter Engine Sensor Values")
|
| 77 |
|
| 78 |
+
with st.expander("π Example Sensor Values", expanded=True):
|
| 79 |
+
st.markdown("""
|
| 80 |
+
- **Engine RPM:** 700
|
| 81 |
+
- **Lub Oil Pressure:** 2.5
|
| 82 |
+
- **Fuel Pressure:** 12
|
| 83 |
+
- **Coolant Pressure:** 3.2
|
| 84 |
+
- **Lub Oil Temperature:** 84
|
| 85 |
+
- **Coolant Temperature:** 82
|
|
|
|
| 86 |
""")
|
| 87 |
|
| 88 |
engine_rpm = st.number_input(
|
|
|
|
| 139 |
prediction = model.predict(input_data)[0]
|
| 140 |
probability = model.predict_proba(input_data)[0]
|
| 141 |
|
| 142 |
+
healthy_prob = probability[0] * 100
|
| 143 |
+
maintenance_prob = probability[1] * 100
|
| 144 |
+
|
| 145 |
st.divider()
|
| 146 |
|
| 147 |
st.header("Prediction Result")
|
|
|
|
| 154 |
)
|
| 155 |
else:
|
| 156 |
st.success("β
Engine is Operating Normally")
|
|
|
|
| 157 |
|
| 158 |
st.divider()
|
| 159 |
|
| 160 |
st.header("Prediction Confidence")
|
| 161 |
|
| 162 |
+
col1, col2 = st.columns(2)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
+
with col1:
|
| 165 |
+
st.metric(
|
| 166 |
+
label="β
Healthy Engine",
|
| 167 |
+
value=f"{healthy_prob:.2f}%"
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
with col2:
|
| 171 |
+
st.metric(
|
| 172 |
+
label="β οΈ Maintenance Required",
|
| 173 |
+
value=f"{maintenance_prob:.2f}%"
|
| 174 |
+
)
|
| 175 |
+
|
| 176 |
+
st.divider()
|
| 177 |
+
|
| 178 |
+
st.subheader("Summary")
|
| 179 |
+
|
| 180 |
+
if prediction == 1:
|
| 181 |
+
st.markdown(f"""
|
| 182 |
+
- **Prediction:** Engine Requires Maintenance
|
| 183 |
+
- **Healthy Probability:** **{healthy_prob:.2f}%**
|
| 184 |
+
- **Maintenance Probability:** **{maintenance_prob:.2f}%**
|
| 185 |
+
- **Recommendation:** Schedule maintenance as soon as possible.
|
| 186 |
+
""")
|
| 187 |
+
else:
|
| 188 |
+
st.markdown(f"""
|
| 189 |
+
- **Prediction:** Engine Operating Normally
|
| 190 |
+
- **Healthy Probability:** **{healthy_prob:.2f}%**
|
| 191 |
+
- **Maintenance Probability:** **{maintenance_prob:.2f}%**
|
| 192 |
+
- **Recommendation:** Continue normal operation and routine monitoring.
|
| 193 |
+
""")
|
| 194 |
|
| 195 |
# ==========================================================
|
| 196 |
# FOOTER
|
|
|
|
| 199 |
st.markdown("---")
|
| 200 |
|
| 201 |
st.caption(
|
| 202 |
+
"Developed by Brijesh Pandey | Python β’ Scikit-learn β’ Streamlit β’ Hugging Face"
|
| 203 |
)
|