Spaces:
Sleeping
Sleeping
File size: 1,771 Bytes
0deec4c 1ba5390 b5ec3c9 0deec4c 504afc5 0deec4c | 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 | 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="sasipriyank/predectivemodel", filename="best_predective_model.joblib")
# Load the model
model = joblib.load(model_path)
# Streamlit UI for Prediction Maintenance
st.title("Predective Maintenance App")
st.write("The Predective Maintenance App is an internal tool for customer that predicts whether Machine sensor is failed or not.")
st.write("Kindly enter the details to check whether Machine sensor is failed or not.")
# Collect user input
LuboilPressure = st.number_input("Lub oil pressure",min_value=0.0, value=2.493592)
EngineRpm = st.number_input("Engine rpm", min_value=0, value=700)
FuelPressure= st.number_input("Fuel pressure",min_value=0.0, value=11.790927)
CoolantPressure = st.number_input("Coolant pressure", min_value=0.0, value=3.178981)
LuboilTemp = st.number_input("lub oil temp", min_value=0.0, value=84.144163)
CoolantTemp = st.number_input("Coolant temp", min_value=0.0, value=81.632187)
# Convert categorical inputs to match model training
input_data = pd.DataFrame([{
'Lub oil pressure': LuboilPressure,
'Engine rpm': EngineRpm,
'Fuel pressure': FuelPressure,
'Coolant pressure': CoolantPressure,
'lub oil temp': LuboilTemp,
'Coolant temp': CoolantTemp
}])
# Set the classification threshold
classification_threshold = 0.45
# Predict button
if st.button("Predict"):
prediction_proba = model.predict_proba(input_data)[0, 1]
prediction = (prediction_proba >= classification_threshold).astype(int)
result = "Failed" if prediction == 1 else "NotFailed"
st.write(f"Based on the information provided, the sensor is {result} ")
|