abdoulayee commited on
Commit
ebdd226
·
verified ·
1 Parent(s): fb8f973

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 joblib
3
+ import numpy as np
4
+ import pandas as pd
5
+ # Charger ton modèle entraîné (ex: model.pkl)
6
+ model = joblib.load("xgb.joblib")
7
+
8
+ # Charger l'encodeur pour la variable catégorielle
9
+ encoder = joblib.load("Extracurricular_Activities.joblib")
10
+
11
+ # Fonction de prédiction
12
+ def predict(hours, score, activity):
13
+ activity_encoded = encoder.transform([activity])[0]
14
+
15
+ # Créer un tableau avec les features dans le bon ordre
16
+ features = np.array([[hours, score, activity_encoded]])
17
+
18
+ # Prédiction
19
+ prediction = model.predict(features)[0]
20
+
21
+ return f"Prédiction de performance : {prediction:.2f}"
22
+
23
+ # Interface Gradio
24
+ interface = gr.Interface(
25
+ fn=predict,
26
+ inputs=[
27
+ gr.Number(label="Hours Studied"),
28
+ gr.Number(label="Previous Scores"),
29
+ gr.Dropdown(choices=["Yes", "No"], label="Extracurricular Activities")
30
+ ],
31
+ outputs="text"
32
+ )
33
+
34
+ interface.launch()