import streamlit as st import pandas as pd from huggingface_hub import hf_hub_download import joblib # Downloading the model from the Model Hub model_path = hf_hub_download(repo_id="skalpitin/Engine-Failure-Prediction", filename="Engine-Failure-Prediction_v1.joblib") # Loading the model model = joblib.load(model_path) # Streamlit UI for Customer Churn Prediction st.title("Engine Failure Prediction App") st.write("The Engine Failure Prediction App is a tool that predicts Engine failures.") st.write("Kindly enter the Engine parameter details to check whether the engine is running in a healthy state or a faulty state.") # Collecting user input Engine_RPM = st.number_input("RPM", min_value=50, value=2500) Lub_oil_pressure = st.number_input("Lubrication Oil Pressure", min_value=0.0, value=5.0) Fuel_pressure = st.number_input("Fuel Pressure", min_value=0.0, value=15.0) Coolant_pressure = st.number_input("Coolant Pressure", min_value=0.0, value=5.0) Lub_oil_temp = st.number_input("Lubrication Oil Temperature", min_value=50, value=100) Coolant_temp = st.number_input("Coolant Temperature", min_value=60, value=150) # Converting inputs to a dataframe to pass to the model 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_temp, 'Coolant temp': Coolant_temp }]) # Setting the classification threshold classification_threshold = 0.45 # Predict button - Calling the model with input dataframe if st.button("Predict"): prediction_proba = model.predict_proba(input_data)[0, 1] prediction = (prediction_proba >= classification_threshold).astype(int) result = "faulty" if prediction == 1 else "healthy" st.write(f"Based on the information provided, the engine is likely to to be running in {result} state.")