File size: 2,099 Bytes
f72601d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

# Hugging Face Model Repo
MODEL_REPO = "Vignesh-vigu/PM-XGBoost-Model"
MODEL_FILE = "best_xgb_model.joblib"

# Download and Load Model
@st.cache_resource
def load_model():
    model_path = hf_hub_download(
        repo_id=MODEL_REPO,
        filename=MODEL_FILE,
        repo_type="model"
    )
    return joblib.load(model_path)

model = load_model()

# Page Config
st.set_page_config(page_title="Engine Predictive Maintenance",
                   page_icon="βš™οΈ", layout="wide")

st.title("πŸš— Engine Predictive Maintenance System")
st.write("Predict whether an engine requires maintenance using sensor data.")

# Sidebar Inputs
st.sidebar.header("πŸ“ Engine Sensor Inputs")

rpm = st.sidebar.number_input("Engine RPM", min_value=0, max_value=4000, value=750)
oil_pressure = st.sidebar.number_input("Lub Oil Pressure (bar)", min_value=0.0, max_value=15.0, value=3.0)
fuel_pressure = st.sidebar.number_input("Fuel Pressure (bar)", min_value=0.0, max_value=30.0, value=5.0)
coolant_pressure = st.sidebar.number_input("Coolant Pressure (bar)", min_value=0.0, max_value=20.0, value=2.0)
oil_temp = st.sidebar.number_input("Lub Oil Temperature (Β°C)", min_value=0.0, max_value=200.0, value=75.0)
cool_temp = st.sidebar.number_input("Coolant Temperature (Β°C)", min_value=0.0, max_value=250.0, value=80.0)

if st.sidebar.button("πŸ” Predict Engine Condition"):
    input_df = pd.DataFrame([[
        rpm, oil_pressure, fuel_pressure,
        coolant_pressure, oil_temp, cool_temp
    ]], columns=[
        "Engine rpm", "Lub oil pressure", "Fuel pressure",
        "Coolant pressure", "lub oil temp", "Coolant temp"
    ])

    prediction = model.predict(input_df)[0]
    status = ("⚠️ Faulty Engine β€” Maintenance Required!"
              if prediction == 1
              else "βœ… Normal Engine β€” No Action Required")

    st.subheader("🧾 Prediction Result:")
    st.markdown(f"### {status}")

    st.write("### πŸ” Input Data")
    st.dataframe(input_df, use_container_width=True)