File size: 1,620 Bytes
921c256 61697b3 a6f7d15 61697b3 921c256 61697b3 c598b42 921c256 c598b42 921c256 9dbc5f9 921c256 9dbc5f9 c598b42 9dbc5f9 c598b42 921c256 c598b42 921c256 | 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 |
import streamlit as st
import pandas as pd
import joblib
st.set_page_config(page_title="Predictive Maintenance App V2", layout="centered")
@st.cache_resource
def load_model():
return joblib.load("best_model.joblib")
st.title("Predictive Maintenance for Engine Health")
st.write("Enter the engine sensor values below to predict engine condition.")
engine_rpm = st.number_input("Engine RPM", min_value=0.0, value=850.0)
lub_oil_pressure = st.number_input("Lub Oil Pressure", min_value=0.0, value=3.5)
fuel_pressure = st.number_input("Fuel Pressure", min_value=0.0, value=6.8)
coolant_pressure = st.number_input("Coolant Pressure", min_value=0.0, value=2.4)
lub_oil_temp = st.number_input("Lub Oil Temperature", min_value=0.0, value=78.0)
coolant_temp = st.number_input("Coolant Temperature", min_value=0.0, value=80.5)
if st.button("Predict Engine Condition"):
try:
model = load_model()
input_df = 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
}])
prediction = model.predict(input_df)[0]
if prediction == 1:
st.error("Prediction: Engine may require maintenance.")
else:
st.success("Prediction: Engine appears to be operating normally.")
st.write("Input dataframe used for prediction:")
st.dataframe(input_df)
except Exception as e:
st.error(f"Prediction failed: {e}")
|