File size: 1,254 Bytes
addd3fd
 
cb1531e
07806b1
addd3fd
 
07806b1
 
 
addd3fd
07806b1
 
 
cb1531e
07806b1
cb1531e
 
 
 
 
 
 
 
 
 
07806b1
cb1531e
 
07806b1
addd3fd
07806b1
cb1531e
addd3fd
07806b1
addd3fd
 
cb1531e
 
07806b1
 
addd3fd
 
 
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
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()