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)