Spaces:
Runtime error
Runtime error
| 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="sulabhag/predictivemaintenance", filename="best_model_v1.joblib") | |
| # Load the model | |
| model = joblib.load(model_path) | |
| # Streamlit UI for Customer Churn Prediction | |
| st.title("Predictive Maintenance App") | |
| st.write("The Predictive Maintenance App is to predict machine failure based on sensor data.") | |
| st.write("Kindly enter the sensor details to check whether machine is like to fail or not") | |
| # Collect Machine input | |
| Engine_rpm = st.number_input("Engine RPM (Engine speed in revolutions per minute)",min_value=0, max_value = 3000, value = 791) | |
| Lub_oil_pressure = st.number_input("Lub oil pressure (Pressure of the lub oil in the engine)",min_value=0.001, max_value = 8.000, value = 3.300) | |
| Fuel_pressure = st.number_input("Fuel pressure (Pressure of the fuel in the engine)",min_value=0.00, max_value = 22.00, value = 6.65) | |
| Coolant_pressure = st.number_input("Coolant pressure (Pressure of the coolant in the engine)",min_value = 0.01, max_value = 8.00, value = 2.33) | |
| Lub_oil_temp = st.number_input("Lub oil temperature (Temperature of the lub oil in the engine)",min_value = 70.00, max_value = 90.00, value = 77.64) | |
| Coolant_temp = st.number_input("Coolant temperature (Temperature of the coolant in the engine)",min_value =60.00, max_value = 200.00, value = 78.42) | |
| # Convert categorical inputs to match model training | |
| 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 | |
| }]) | |
| # Set the classification threshold | |
| # classification_threshold = 0.45 | |
| # Predict button | |
| if st.button("Predict"): | |
| prediction = model.predict(input_data) | |
| # prediction = (prediction_proba >= classification_threshold).astype(int) | |
| result = "failure" if prediction == 1 else "not fail" | |
| st.write(f"Based on the information provided, the machine is likely to {result}.") | |