File size: 1,201 Bytes
c9dff70
 
 
 
 
4ef2b90
 
c9dff70
4ef2b90
 
 
a373624
 
 
 
 
4ef2b90
a373624
 
 
8618cef
4ef2b90
 
 
 
 
c9dff70
4ef2b90
c9dff70
4ef2b90
 
a373624
4ef2b90
a373624
4ef2b90
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
import gradio as gr
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

model = joblib.load(hf_hub_download(repo_id="alperugurcan/mercedes", filename="mercedes_model.joblib"))
feature_names = joblib.load(hf_hub_download(repo_id="alperugurcan/mercedes", filename="feature_names.joblib"))

CONFIGS = {
    "z (360 cases)": "z",
    "ak (349 cases)": "ak", 
    "y (324 cases)": "y",
    "ay (313 cases)": "ay",
    "t (306 cases)": "t",
    "x (300 cases)": "x",
    "o (269 cases)": "o",
    "f (227 cases)": "f", 
    "n (195 cases)": "n",
    "w (182 cases)": "w"
}

def predict(option):
    input_data = {name: 0.0 for name in feature_names}
    input_data[f'X0_{CONFIGS[option]}'] = 1.0
    prediction = model.predict(pd.DataFrame([input_data]))[0]
    return f"Predicted manufacturing time: {prediction:.2f} seconds"

gr.Interface(
    fn=predict,
    inputs=gr.Dropdown(choices=list(CONFIGS.keys()), label="Manufacturing Configuration"),
    outputs=gr.Textbox(label="Prediction"),
    title="Mercedes-Benz Manufacturing Time Predictor",
    description="Select a manufacturing configuration to predict production time.",
    theme=gr.themes.Soft()
).launch(debug=True)