Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| from huggingface_hub import hf_hub_download | |
| MODEL_REPO_ID = "Amittripipathi/DecisionTree-engine-predictive-model" | |
| MODEL_FILENAME = "DecisionTree_engine_model.pkl" | |
| # Download model from HF Model Hub & load | |
| model_path = hf_hub_download(repo_id=MODEL_REPO_ID, filename=MODEL_FILENAME) | |
| model = joblib.load(model_path) | |
| # Streamlit UI | |
| st.title("🚗 Engine Failure Prediction") | |
| st.write("Predict whether an engine is faulty or operating normally based on sensor readings.") | |
| # Input form | |
| engine_rpm = st.number_input("Engine RPM", min_value=0, max_value=3000, value=750) | |
| lub_oil_pressure = st.number_input("Lubricating Oil Pressure (MPa)", min_value=0.0, max_value=10.0, value=3.0) | |
| fuel_pressure = st.number_input("Fuel Pressure (MPa)", min_value=0.0, max_value=30.0, value=6.0) | |
| coolant_pressure = st.number_input("Coolant Pressure (MPa)", min_value=0.0, max_value=10.0, value=2.0) | |
| lub_oil_temp = st.number_input("Lubricating Oil Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0) | |
| coolant_temp = st.number_input("Coolant Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0) | |
| if st.button("Predict Engine Condition"): | |
| input_df = 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 = model.predict(input_df)[0] | |
| result = "⚠️ Faulty Engine" if prediction == 1 else "✅ Normal Engine" | |
| st.subheader(result) | |