Spaces:
Sleeping
Sleeping
File size: 1,888 Bytes
7f475ac 09ccf30 7f475ac 09ccf30 c43fa34 09ccf30 7f475ac 7ea8948 7f475ac 7ea8948 7f475ac |
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 |
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib
import os
from huggingface_hub import HfApi, login
HF_TOKEN = os.getenv("HF_TOKEN") # Optional if repo is public
model_path = hf_hub_download(
repo_id="tam3222/Engine_Model",
filename="models/RandomForest.pkl",
repo_type="model",
token=HF_TOKEN # can be None for public repos
)
# Load the model
model = joblib.load(model_path)
# Streamlit UI for Customer Conversion Prediction
st.title("Predictive Maintenance App")
st.write("This app predicts the engine condition.")
st.write("Please enter the customer details below:")
# Collect user input
engine_rpm = st.number_input("Engine_RPM", min_value=0, value=700)
lub_oil_pressure = st.number_input("Pressure of the lubricating oil in the engine(kPa)", min_value=0, value=3)
fuel_pressure = st.number_input("Pressure at which fuel is supplied to the engine(kPa)", min_value=0, value=3)
coolant_pressure = st.number_input("Coolant_Pressure(kPa)", min_value=0, value=2)
lub_oil_temperature = st.number_input("Temperature of the lubricating oil (°C) ", value=75)
coolant_temperature = st.number_input("Coolant_Temperature (°C)", value=78)
# Prepare input DataFrame
input_data = pd.DataFrame([{
'engine_rpm': engine_rpm,
'lub_oil_pressure': lub_oil_pressure,
'fuel_pressure': fuel_pressure,
'coolant_pressure': coolant_pressure,
'lub_oil_temperature': lub_oil_temperature,
'coolant_temperature': coolant_temperature,
}])
# Classification threshold
classification_threshold = 0.45
# Predict button
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 {result}.")
|