Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| from huggingface_hub import hf_hub_download | |
| # ---------------------------- | |
| # Load model from Hugging Face | |
| # ---------------------------- | |
| HF_MODEL_REPO = "vihu21/adaboost-predictive-maintenance" | |
| MODEL_FILE = "adaboost_pm.joblib" | |
| model_path = hf_hub_download( | |
| repo_id="vihu21/adaboost-predictive-maintenance", | |
| filename="adaboost_pm.joblib", | |
| repo_type="model" | |
| ) | |
| model = joblib.load(model_path) | |
| # ---------------------------- | |
| # Streamlit UI | |
| # ---------------------------- | |
| st.title("🔧 Engine Condition Prediction") | |
| st.write("Fill in the engine parameters to predict engine condition.") | |
| # ---------------------------- | |
| # User Inputs | |
| # ---------------------------- | |
| engine_rpm = st.number_input("Engine RPM", min_value=50, max_value=6000, value=3000) | |
| lub_oil_pressure = st.number_input("Lub Oil Pressure", min_value=0.0, value=7.25) | |
| fuel_pressure = st.number_input("Fuel Pressure", min_value=0.0, value=21.4) | |
| coolant_pressure = st.number_input("Coolant Pressure", min_value=0.0, value=7.5) | |
| lub_oil_temp = st.number_input("Lub Oil Temperature", min_value=50.0, value=90.0) | |
| coolant_temp = st.number_input("Coolant Temperature", min_value=60.0, value=195.0) | |
| # ---------------------------- | |
| # Prepare input data | |
| # ⚠️ Column names must EXACTLY match 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 | |
| }]) | |
| # ---------------------------- | |
| # Prediction | |
| # ---------------------------- | |
| if st.button("Predict Engine Condition"): | |
| prediction = model.predict(input_data)[0] | |
| st.subheader("Prediction Result") | |
| if prediction == 1 or prediction == "Good": | |
| st.success("✅ Engine Condition: GOOD") | |
| else: | |
| st.error("⚠️ Engine Condition: BAD") | |