File size: 1,862 Bytes
c9669f0
 
 
 
 
 
 
 
 
 
 
834c351
da16e08
834c351
c9669f0
6f2ff6e
5509aa0
 
 
 
 
 
c9669f0
 
 
 
 
834c351
 
 
 
 
 
c9669f0
 
 
 
 
 
 
 
 
75d42c3
834c351
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
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="jarpan03/engine-predictive-maintenance-model", filename="best_engine_maintenance_model_v1.joblib")

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

# Streamlit UI for Predictive Maintenance Prediction
st.title("Engine Maintenance Prediction")
st.write("Fill the engine details below to predict if they'll need a maintenance")

# Collect user input 
Engine_RPM = st.number_input("Engine_RPM", min_value=1, max_value=10000, value=100,step=1)
Lub_Oil_Pressure = st.number_input("Lub_Oil_Pressure", min_value=0.0, value=1.0,step=0.000001,format="%.6f")
Fuel_Pressure = st.number_input("Fuel_Pressure", min_value=0.0, value=1.0,step=0.000001,format="%.6f")
Coolant_Pressure = st.number_input("Coolant_Pressure", min_value=0.0, value=1.0,step=0.000001,format="%.6f")
Lub_Oil_Temperature = st.number_input("Lub_Oil_Temperature", min_value=0.0, value=1.0,step=0.000001,format="%.6f")
Coolant_Temperature = st.number_input("Coolant_Temperature", min_value=0.0, value=1.0,step=0.000001,format="%.6f")

# ----------------------------
# Prepare input data
# ----------------------------
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_Temperature,
    'Coolant temp': Coolant_Temperature
}])

# Set the classification threshold
classification_threshold = 0.45

# Predict button
if st.button("Predict"):
    prob = model.predict_proba(input_data)[0,1]
    pred = int(prob >= classification_threshold)
    result = "will need maintenance!" if pred == 1 else "doesn't need any maintenance!"
    st.write(f"Prediction: Engine {result}")