Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| import pandas as pd | |
| # Charger ton modèle entraîné (ex: model.pkl) | |
| model = joblib.load("xgb.joblib") | |
| # Charger l'encodeur pour la variable catégorielle | |
| encoder = joblib.load("Extracurricular_Activities.joblib") | |
| # Fonction de prédiction | |
| def predict(hours, score, activity): | |
| activity_encoded = encoder.transform([activity])[0] | |
| # Créer un tableau avec les features dans le bon ordre | |
| features = np.array([[hours, score, activity_encoded]]) | |
| # Prédiction | |
| prediction = model.predict(features)[0] | |
| return f"Prédiction de performance : {prediction:.2f}" | |
| # Interface Gradio | |
| interface = gr.Interface( | |
| fn=predict, | |
| inputs=[ | |
| gr.Number(label="Hours Studied"), | |
| gr.Number(label="Previous Scores"), | |
| gr.Dropdown(choices=["Yes", "No"], label="Extracurricular Activities") | |
| ], | |
| outputs="text" | |
| ) | |
| interface.launch() | |