File size: 849 Bytes
8876cd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import joblib

# Load your saved model
model = joblib.load("model.joblib")

# Define the prediction function
def predict(age, hours, education, capital_gain, capital_loss):
    features = [[age, hours, education, capital_gain, capital_loss]]
    prediction = model.predict(features)
    return "Income >50K" if prediction == 1 else "Income <=50K"

# Create the Gradio interface
interface = gr.Interface(
    fn=predict,
    inputs=[
        gr.Slider(18, 90, step=1, label="Age"),
        gr.Slider(1, 99, step=1, label="Hours Per Week"),
        gr.Slider(1, 20, step=1, label="Education Level (Years)"),
        gr.Slider(0, 100000, step=100, label="Capital Gain"),
        gr.Slider(0, 5000, step=50, label="Capital Loss"),
    ],
    outputs="text",
    title="Adult Income Predictor",
)

# Launch the app
interface.launch()