|
||
---|---|---|
Dockerfile | ||
README.md | ||
app.py | ||
pipeline_xgb.pkl | ||
requirements.txt | ||
start.sh |
README.md
Prédiction de Matchs de Tennis avec FastAPI
Ce projet utilise FastAPI pour fournir des prédictions de matchs de tennis basées sur un modèle de machine learning pré-entraîné. L'API permet de faire des prédictions en lot ou pour un seul match, en utilisant diverses caractéristiques des joueurs et des matchs.
Prérequis
Assurez-vous d'avoir Docker installé sur votre machine.
Installation
-
Clonez ce dépôt sur votre machine locale :
git clone https://gitea.mortreau.net/aslane/Tennis-AI.git cd Tennis-AI
-
Placez votre modèle
pipeline_xgb.pkl
dans le répertoire du projet. -
Assurez-vous que votre fichier
requirements.txt
contient les dépendances nécessaires, y comprisfastapi
,uvicorn
,gunicorn
,numpy
,pydantic
, etc.
Construction et Exécution du Conteneur Docker
-
Construisez l'image Docker :
docker build -t tennis-prediction-app .
-
Exécutez le conteneur :
docker run -p 8000:8000 tennis-prediction-app
Utilisation de l'API
Endpoint de Prédiction en Lot
-
URL :
/predict_batch
-
Méthode :
POST
-
Corps de la Requête :
{ "matches": [ { "match_id": 1, "player_id1": 101, "player_id2": 102, "p1_niveau_rank": 5.0, "p1_niveau_win_total": 10.0, "p1_niveau_win_surface_total": 3.0, ... "idc_p2_historique_estimated": 0.5, "tournament_round": 2, "tournament_type": 1, "tournament_surface": 0 }, { "match_id": 2, "player_id1": 103, "player_id2": 104, ... } ] }
-
Réponse :
{ "predictions": [ { "match_id": 1, "win_probability_j1": 0.65, "win_probability_j2": 0.35 }, { "match_id": 2, ... } ] }
Endpoint de Prédiction pour un Seul Match
-
URL :
/predict
-
Méthode :
POST
-
Corps de la Requête :
{ "match_id": 1, "player_id1": 101, "player_id2": 102, "p1_niveau_rank": 5.0, "p1_niveau_win_total": 10.0, "p1_niveau_win_surface_total": 3.0, ... "idc_p2_historique_estimated": 0.5, "tournament_round": 2, "tournament_type": 1, "tournament_surface": 0 }
-
Réponse :
{ "match_id": 1, "win_probability_j1": 0.65, "win_probability_j2": 0.35 }
Structure du Projet
main.py
: Contient le code principal de l'application FastAPI.pipeline_xgb.pkl
: Fichier du modèle pré-entraîné.requirements.txt
: Liste des dépendances Python.Dockerfile
: Fichier de configuration pour Docker.start.sh
: Script pour démarrer l'application avec Gunicorn.