alperugurcan commited on
Commit
c9dff70
·
verified ·
1 Parent(s): 1584745

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ # Download model and feature names from Hugging Face
7
+ model_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="mercedes_model.joblib")
8
+ feature_names_path = hf_hub_download(repo_id="alperugurcan/mercedes", filename="feature_names.joblib")
9
+
10
+ # Load the saved model and feature names
11
+ model = joblib.load(model_path)
12
+ feature_names = joblib.load(feature_names_path)
13
+
14
+ def predict(*features):
15
+ # Create a DataFrame with the input features
16
+ df = pd.DataFrame([features], columns=feature_names)
17
+
18
+ # Make prediction
19
+ prediction = model.predict(df)[0]
20
+ return f"Predicted time: {prediction:.2f}"
21
+
22
+ # Create the interface
23
+ inputs = [gr.Number(label=f"Feature {i+1}") for i in range(len(feature_names))]
24
+ output = gr.Textbox(label="Prediction")
25
+
26
+ interface = gr.Interface(
27
+ fn=predict,
28
+ inputs=inputs,
29
+ outputs=output,
30
+ title="Mercedes-Benz Manufacturing Time Prediction",
31
+ description="Enter feature values to predict manufacturing time"
32
+ )
33
+
34
+ interface.launch()