matsammut commited on
Commit
8876cd2
·
verified ·
1 Parent(s): 9607599

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+
4
+ # Load your saved model
5
+ model = joblib.load("model.joblib")
6
+
7
+ # Define the prediction function
8
+ def predict(age, hours, education, capital_gain, capital_loss):
9
+ features = [[age, hours, education, capital_gain, capital_loss]]
10
+ prediction = model.predict(features)
11
+ return "Income >50K" if prediction == 1 else "Income <=50K"
12
+
13
+ # Create the Gradio interface
14
+ interface = gr.Interface(
15
+ fn=predict,
16
+ inputs=[
17
+ gr.Slider(18, 90, step=1, label="Age"),
18
+ gr.Slider(1, 99, step=1, label="Hours Per Week"),
19
+ gr.Slider(1, 20, step=1, label="Education Level (Years)"),
20
+ gr.Slider(0, 100000, step=100, label="Capital Gain"),
21
+ gr.Slider(0, 5000, step=50, label="Capital Loss"),
22
+ ],
23
+ outputs="text",
24
+ title="Adult Income Predictor",
25
+ )
26
+
27
+ # Launch the app
28
+ interface.launch()