pingdwende's picture
Create app.py
2136084 verified
import gradio as gr
import joblib
# Charger le modèle
model = joblib.load('salary_prediction_model.joblib')
# Définir l'interface Gradio
def predict_salary(age, gender, education, job_title, years_experience, country, race):
# Préparer les données d'entrée
input_data = [[age, gender, education, job_title, years_experience, country, race]]
# Faire la prédiction
prediction = model.predict(input_data)
return prediction[0]
# Créer l'interface
iface = gr.Interface(
fn=predict_salary,
inputs=[
gr.inputs.Number(label="Age"),
gr.inputs.Dropdown(choices=["Male", "Female"], label="Gender"),
gr.inputs.Dropdown(choices=["Bachelor's", "Master's", "PhD"], label="Education Level"),
gr.inputs.Textbox(label="Job Title"),
gr.inputs.Number(label="Years of Experience"),
gr.inputs.Dropdown(choices=["USA", "UK", "Canada"], label="Country"),
gr.inputs.Dropdown(choices=["White", "Hispanic", "Asian"], label="Race")
],
outputs="number",
title="Salary Prediction Model",
description="Predict salary based on various factors."
)
# Lancer l'interface
iface.launch()