Go to file
azertop 9054ed7470 init 2024-07-09 13:46:03 +02:00
Dockerfile init Dockerfile 2024-07-09 13:42:50 +02:00
README.md Actualiser README.md 2024-07-09 11:42:21 +00:00
app.py init 2024-07-09 13:41:08 +02:00
pipeline_xgb.pkl init 2024-07-09 13:41:08 +02:00
requirements.txt init 2024-07-09 13:41:08 +02:00
start.sh init 2024-07-09 13:41:08 +02:00

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

  1. Clonez ce dépôt sur votre machine locale :

    git clone https://gitea.mortreau.net/aslane/Tennis-AI.git
    cd Tennis-AI
    
  2. Placez votre modèle pipeline_xgb.pkl dans le répertoire du projet.

  3. Assurez-vous que votre fichier requirements.txt contient les dépendances nécessaires, y compris fastapi, uvicorn, gunicorn, numpy, pydantic, etc.

Construction et Exécution du Conteneur Docker

  1. Construisez l'image Docker :

    docker build -t tennis-prediction-app .
    
  2. 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.