Spaces:
Sleeping
Sleeping
File size: 1,089 Bytes
c9dff70 |
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 |
import gradio as gr
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
# Download model and feature names from Hugging Face
model_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="mercedes_model.joblib")
feature_names_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="feature_names.joblib")
# Load the saved model and feature names
model = joblib.load(model_path)
feature_names = joblib.load(feature_names_path)
def predict(*features):
# Create a DataFrame with the input features
df = pd.DataFrame([features], columns=feature_names)
# Make prediction
prediction = model.predict(df)[0]
return f"Predicted time: {prediction:.2f}"
# Create the interface
inputs = [gr.Number(label=f"Feature {i+1}") for i in range(len(feature_names))]
output = gr.Textbox(label="Prediction")
interface = gr.Interface(
fn=predict,
inputs=inputs,
outputs=output,
title="Mercedes-Benz Manufacturing Time Prediction",
description="Enter feature values to predict manufacturing time"
)
interface.launch() |