File size: 1,732 Bytes
83b8346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib

# Download and load the model

# replace with your repoid
model_path = hf_hub_download(repo_id="varun109/Predictive_Maintenance", filename="best_machine_failure_model_v1.joblib")

model = joblib.load(model_path)

# Streamlit UI for Machine Failure Prediction
st.title("Predictive_Maintenance App")
st.write("""
This application predicts the likelihood of a machine failing based on its operational parameters.
Please enter the sensor and configuration data below to get a prediction.
""")

# User input
coolant_pressure = st.selectbox("Coolant pressure", [0, 1])
lub_oil_temperature = st.number_input("Lub oil temperature (K)", min_value=250.0, max_value=400.0, value=298.0, step=0.1)
coolant_temperature = st.number_input("Coolant temperature (K)", min_value=250.0, max_value=500.0, value=324.0, step=0.1)
engine_rpm = st.number_input("Engine rpm (RPM)", min_value=0, max_value=3000, value=1400)
lub_oil_pressure = st.number_input("Lub oil pressure", min_value=0.0, max_value=100.0, value=40.0, step=0.1)
fuel_pressure = st.number_input("Fuel pressure", min_value=0, max_value=300, value=10)

# Assemble input into DataFrame
input_data = pd.DataFrame([{
    'Coolant pressure': coolant_pressure,
    'lub oil temp': lub_oil_temperature,
    'Coolant temp': coolant_temperature,
    'Engine rpm': engine_rpm,
    'Lub oil pressure': lub_oil_pressure,
    'Fuel pressure': fuel_pressure
}])


if st.button("Predict Failure"):
    prediction = model.predict(input_data)[0]
    result = "Machine Failure" if prediction == 1 else "No Failure"
    st.subheader("Prediction Result:")
    st.success(f"The model predicts: **{result}**")