Spaces:
Runtime error
Runtime error
File size: 2,139 Bytes
912dcb0 32a8897 912dcb0 32a8897 2a9f82d 912dcb0 32a8897 912dcb0 32a8897 912dcb0 | 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 | import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib
# Download and load the model
model_path = hf_hub_download(repo_id="mkrish2025/Machine-Failure-Prediction", filename="best_mc_failure_prediction_model_v1.joblib")
model = joblib.load(model_path)
# Streamlit UI for Machine Failure Prediction
st.title("Machine Failure Prediction App")
st.write("""
This application predicts the likelihood of machine failures and classifies whether an engine requires maintenance or is operating normally.
Please enter the machine sensor details below to get a prediction.
""")
EngineRPM = st.number_input("Engine RPM", min_value=60, max_value=2500, value=70)
LubOilPressure = st.number_input("Lub Oil Pressure", min_value=0.003, max_value=8.000, value=0.100,format="%.3f")
FuelPressure = st.number_input("Fuel Pressure", min_value=0.003, max_value=21.000, value=0.010,format="%.3f")
CoolantPressure = st.number_input("Coolant Pressure", min_value=0.002, max_value=8.000, value=0.200,format="%.3f")
LubOilTemperature = st.number_input("Lub Oil Temperature", min_value=70.000, max_value=90.000, value=86.00,format="%.3f")
CoolantTemperature = st.number_input("Coolant Temperature", min_value=70.000, max_value=200.000, value=100.000,format="%.3f")
# Assemble input into DataFrame
input_data = pd.DataFrame([{
"engine_rpm": EngineRPM,
"lub_oil_pressure": LubOilPressure,
"fuel_pressure": FuelPressure,
"coolant_pressure": CoolantPressure,
"lub_oil_temp": LubOilTemperature,
"coolant_temp": CoolantTemperature
}])
st.subheader("Raw Input Data")
st.dataframe(input_data)
# Prediction
if st.button("Predict"):
try:
prediction = model.predict(input_data)[0]
prediction_proba = model.predict_proba(input_data)[0][1]
if prediction == 1:
st.success(f"❌ Machine is likely to fail and requires maintenance (Confidence: {prediction_proba:.2f})")
else:
st.warning(f"✅ Machine is likely in good condition (Confidence: {1 - prediction_proba:.2f})")
except Exception as e:
st.error(f"Prediction failed: {e}")
|