import gradio as gr import pandas as pd import numpy as np import joblib from huggingface_hub import hf_hub_download # Download model from your repository repo_id = "DevNumb/random-forest-model-reduced" model_path = hf_hub_download(repo_id=repo_id, filename="model.joblib") # Load model model = joblib.load(model_path) print("✅ Model loaded successfully!") # Your 18 feature names FEATURE_NAMES = [ 'OA_TEMP', 'OA_TEMP_WB', 'Hour', 'Weekday', 'Month', 'CHL_STA_1', 'CHL_STA_2', 'CHL_STA_3', 'CHL_COMP_SPD_CTRL_1', 'CHL_COMP_SPD_CTRL_2', 'CHL_COMP_SPD_CTRL_3', 'CT_FAN_SPD_CTRL_1', 'CT_FAN_SPD_CTRL_2', 'CT_FAN_SPD_CTRL_3', 'CHL_CD_FLOW_1', 'CHL_CD_FLOW_2', 'CHL_CD_FLOW_3', 'CWL_SEC_LOAD' ] def predict(*args): """Make prediction from 18 features""" input_data = pd.DataFrame([list(args)], columns=FEATURE_NAMES) prediction = model.predict(input_data)[0] return f"**Prediction:** {prediction:.2f}" # Create input fields inputs = [gr.Number(label=name) for name in FEATURE_NAMES] # Create interface demo = gr.Interface( fn=predict, inputs=inputs, outputs=gr.Markdown(label="Result"), title="HVAC Chiller Prediction API", description="Predicts chiller system performance" ) demo.launch()