篮球MLOps分析平台

BasketCoach MCP是一款专为篮球分析和教练设计的MLOps平台,集成了球员分析、战术建议、训练推荐和实时数据跟踪功能。

  • by Otienta
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Otienta/basketcoach-mcp-demo

使用说明

🏀 篮球教练MCP-职业篮球MLOPS平台(2025年)

具有MLOPS、MCP和IA的智能篮球分析、教练和侦察系统

MLOps • Analyse Joueur • Scouting • Classement LFB • Actualités • Recommandations d'entraînement • LLM Orchestration (MCP) • RAG

NBA级UI•MCP•RAG•MLF•气流•CI/CD•Docker•LLM代理

🚀 本地演示(30秒)

git clone [https://github.com/Otienta/basketcoach-mcp-demo.git](https://github.com/Otienta/basketcoach-mcp-demo.git)
cd basketcoach-mcp-demo/docker
docker compose up -d

# Puis ouvre ton navigateur :
# → http://localhost:8501      ← Interface Streamlit complète
# → http://localhost:8000/docs ← API MCP (Swagger)

唯一一个在单一患者界面中进行辅导、侦察、培训和MLOPS的平台。


现场功能(2025)

功能 状态 技术
NBA直播+LFB直播 直播 铲球+MCP
IA战术分析 LIVE LLM+MCP
侦察完成+得分 现场 侦察代理
培训计划 现场 TrainingAgent
Rapport赛后IA 直播 MCP+RAG
RAG医疗指南
玩家影响预测 r²=0.995 随机森林+MLFlow
CI/CD自动 实时 GitHub操作→GHCR
Docker Multi-Image Live 独立API+StreamLit

一键部署(2025年)

# Option 1 : Local (Méthode recommandée)
cd docker && docker compose up -d

# Option 2 : Cloud (Render, Railway, Fly.io, etc.)
git push origin main  # → CI/CD rebuild & push les images automatiquement sur GHCR

🏷️ 徽章

<p align=“center”> <img src=“https://img.shields.io/badge/Python-3.11-blue" /> <img src=“https://img.shields.io/badge/MCP-Enabled-purple" /> <img src=“https://img.shields.io/badge/MLflow-Tracking-orange" /> <img src=“https://img.shields.io/badge/Airflow-Orchestration-red" /> <img src=“https://img.shields.io/badge/Streamlit-UI-brightgreen" /> <img src=“https://img.shields.io/badge/Docker-Containerized-cyan" /> <img src=“https://img.shields.io/badge/CI%2FCD-GHCR成功“/> <img src=“https://img.shields.io/badge/License-MIT-yellow" /> p


📚 目录

  1. 引言
  2. 功能
  3. 架构MLOps
  4. 安装速度快
  5. 使用
  6. API MCP
  7. 配置
  8. 码头工人
  9. ML模型
  10. 贡献者
  11. 许可证
  12. 致谢

🎯 引言

篮球教练MCP 是一个先进的MLOps平台,结合了:

  • MLOps :使用MLflow进行模型生命周期管理,使用气流进行管道编排,CI/CD
  • 本地数据LFB (JSON 2021-2024)和外部数据(抓取)
  • 人工智能 (玩家冲击模型)和 LLM 通过 模型上下文协议
  • 发动机RAG 对于医疗和技术指南
  • 专业代理人 (教练、侦察、培训)

一切都在 只有一个智能界面 中央集权 教练, 侦察, 培训 和 团队分析 采用MLOPS方法。


✨ 功能

🔍 球员和团队分析

  • 影响ML :通过随机森林模型预测玩家的影响
  • 历史多游戏 玩家与玩家的比较
  • LFB排名 实时和高级统计
  • 新闻,伤害,网络文章

🤖 智能代理(LLM+MCP)

  • 教练代理 :战略分析、游戏计划、不利趋势
  • 侦察代理 :深入分析球员、比较、招聘建议
  • 培训代理 :个性化培训计划、伤害预防

📚 RAG指南

  • 医学和技术文档中的语义搜索
  • 使用SentenceTransformers和FAIS搜索嵌入

🛠️ MCP(模型上下文协议)

  • 9 MCP工具 可用:比赛分析、球员影响、NBA排名、新闻等。
  • Streamlit中集成的实时日志和测试

🚀 MLOps

  • MLFlow :经验跟踪、模型注册、生命周期管理
  • 气流 :数据和培训管道的协调
  • CI/CD :测试、构建和部署自动化
  • 码头工人 :可重复环境的集装箱化
  • 监控 :性能指标、数据和概念导数

🏗️ 架构MLOps

📁 项目结构

basketcoach-mcp/
├── 🚀 app.py                          # Interface Streamlit
├── 🔧 basketcoach_mcp_server.py       # Serveur MCP principal
├── 📡 mcp_direct_client.py            # Client MCP avec logging
├── ⚙️ config.yaml                     # Configuration
├── 📋 requirements.txt                # Dépendances
├── 🏗️ setup.py
├── 📚 README.md
├── 🔐 .env
│
├── .github/workflows/
│   ├── cicd.yml        # Build & push API + Streamlit sur GHCR
│   └── ci.yml          # Tests + Ruff
│
├── 📊 data/
│   ├── raw/                          # JSON LFB bruts
│   ├── processed/                    # Données traitées
│   └── external/                     # Cache web scraping
│
├── 🤖 agents/
│   ├── __init__.py
│   ├── coaching_agent.py             # ✅ Analyse stratégique
│   ├── scouting_agent.py             # ✅ Recrutement et analyse
│   ├── smart_coaching_agent.py
│   └── training_agent.py             # ✅ Préparation physique
│
├──  airflow/
│   └──  dags/
│          └── basketcoach_mcp_pipeline.py  # DAG Airflow
│
├── 🧠 ml/
│   ├── __init__.py
│   ├── train.py                      # ✅ Entraînement modèle
│   ├── predict.py                    # ✅ Prédictions
│   └── model/                        # Modèles MLflow
│
├── 🔍 rag/
│   ├── __init__.py
│   ├── embed.py                      # ✅ Système RAG
│   ├── search.py                     # ✅ Recherche guidelines
│   └── guidelines/                   # Documents PDF
│
├──  tests/
│   ├── test_coaching_agent.py
│   ├── test_scouting_agent.py
│   ├── test_training_agent.py
│   ├── test_nba_scraping.py
│   └── test_mcp_tools.py
│
├── 🌐 utils/
│   ├── __init__.py
│   ├── data_processor.py             # ✅ Traitement JSON
│   ├── ollama_client.py 
│   ├── config.py
│   └── logger.py                     # ✅ Logging centralisé
│
├── 📦 scripts/
│   ├── __init__.py
│   ├── run_mcp_server.py             # Lancement serveur
│   ├── run_training.py               # ✅ Entraînement ML
│   └── setup_environment.py          # Configuration
│
└── 🐳 docker/
    ├── Dockerfile                     # Image du serveur MCP
    ├── Dockerfile.streamlit           # Image de l'interface Streamlit
    └── docker-compose.yml

🔥 全球架构图(ASCII)

                            ┌─────────────────────────┐
                            │        Streamlit         │
                            │      UI (app.py)         │
                            └─────────────┬───────────┘
                                          │
                                          ▼
                              ┌───────────────────────┐
                              │      MCP Client       │
                              │   (logging avancé)    │
                              └─────────────┬─────────┘
                                            │
                                            ▼
                              ┌────────────────────────┐
                              │      MCP Server        │
                              │  9 Outils disponibles  │
                              └──────┬────────┬────────┘
                                     │        │
         ┌───────────────────────────┘        └───────────────────────────┐
         ▼                                                                ▼
┌──────────────────────┐                                      ┌─────────────────────┐
│   Web Scraping        │                                      │   Modèle MLflow     │
│  (classement, news)   │                                      │  Impact Joueur      │
└──────────────────────┘                                      └─────────────────────┘
         │                                                                │
         ▼                                                                ▼
┌──────────────────────┐                                      ┌─────────────────────┐
│     Data Processor    │                                      │   Agents LLM (3)     │
│  JSON → CSV → Features│                                      │ coaching/scouting/...│
└──────────────────────┘                                      └─────────────────────┘
         │                                                                │
         ▼                                                                ▼
┌──────────────────────┐                                      ┌─────────────────────┐
│     Airflow DAGs      │                                      │   RAG Guidelines    │
│  (orchestration)      │                                      │  (recherche)        │
└──────────────────────┘                                      └─────────────────────┘

🔄 工作流MLOps

  1. 数据摄入 :气流协调LFB和外部数据的收集和预处理。
  2. 模型训练 :触发驱动管道,使用MLFlow跟踪度量和模型。
  3. 评估和验证 :对模型进行评估,如果指标令人满意,则将其推广到生产中。
  4. 部署 :模型通过CI/CD管道(Docker容器、API等)部署。
  5. 监控 :监控生产中的模型性能(数据漂移、业务指标)。

🚀 安装速度快

1.克隆项目

git clone <repository>
cd basketcoach-mcp

2.安装依赖项

pip install -r requirements.txt

3.准备数据

python -c "from utils.data_processor import process_data_pipeline; process_data_pipeline()"

4.Lancer les服务

# Serveur MCP
python scripts/run_mcp_server.py

# Interface Streamlit
streamlit run app.py

# MLflow (optionnel)
mlflow server --host localhost --port 5000

# Airflow (optionnel)
airflow webserver --port 8080
airflow scheduler

5.访问接口


📊 使用

界面流光

Streamlit界面提供对所有功能的访问:

  • 仪表盘 :功能和指标概述
  • NBA现场 :NBA排名和球员统计
  • 分析比赛 :LFB比赛的战略分析
  • 侦察玩家 :深入分析和比较玩家
  • 培训计划 :个性化计划和伤害预防
  • Rapport教练 :IA生成的详细赛后报告
  • MLOps仪表板 :监测MLOPS模型和指标
  • MCP工具 :MCP工具的直接测试
  • 篮球指南 :研究医疗和技术指南
  • 配置 :服务和配置法规

📡 API MCP

MCP服务器公开了几种工具:

from mcp_direct_client import direct_client

# Exemples d'utilisation
impact = direct_client.get_player_impact("2051529", "Marine Johannès")
ranking = direct_client.get_nba_live_ranking()
news = direct_client.get_player_news("Marine Johannès")
guidelines = direct_client.search_guidelines("entorse cheville")
coaching_report = direct_client.generate_coaching_report("2051529")

🔧 配置

文件 config.yaml 允许配置:

mcp:
  server:
    host: "localhost"
    port: 8000

ml:
  model:
    name: "player_impact_predictor"

web_sources:
  lfb_ranking: "[https://www.basketlfb.com/classement/](https://www.basketlfb.com/classement/)"

rag:
  guidelines_path: "rag/guidelines/"

🐳 码头工人

该项目采用多图像架构(API+Streamlit)进行容器化。

# Développement local
cd docker && docker compose up -d

# Production (avec images taguées GHCR)
cd docker && docker compose -f docker-compose.prod.yml up -d

图像将自动发布在 GitHub容器注册表(GHCR) 每次按下 main :

  • ghcr.io/otienta/basketcoach-mcp-demo:latest
  • ghcr.io/otienta/basketcoach-mcp-demo-streamlit:latest

📈 ML模型

玩家影响模型是基于LFB数据训练的随机森林。

  • 特性 :得分、篮板、传球、拦截、控球、失误、加减
  • 目标 :玩家影响(加权公式)
  • 演出 :R²~0.995

培训:

python scripts/run_training.py

跟踪工作流程: http://localhost:5000


🚀 CI/CD和部署

GitHub操作(当前和功能)

该项目包括一个完整的CI/CD管道(定义见 .github/workflows/) :

  • 自动测试 和 代码检查 (通过 ci.yml)
  • 构建Docker多镜像 (API+Streamlit)
  • Push-vers GitHub容器注册表 (GHCR)(通过) cicd.yml)
  • 自动部署 暂存
  • 手动部署 生产

🤝 贡献

欢迎捐款!

  1. 分叉项目
  2. 创建分支(git checkout -b feature/AmazingFeature)
  3. 提交您的更改(git commit -m 'Add some AmazingFeature')
  4. 推动分支(git push origin feature/AmazingFeature)
  5. 打开拉取请求

📝 许可证

根据MIT许可证分发。见 LICENSE 倒加上d’information。


🙏 致谢

  • 女子篮球联盟(LFB)数据
  • 用于模型跟踪的MLFlow
  • 阿帕奇气流组织
  • 用于用户界面的Streamlit
  • LLM集成的模型上下文协议(MCP)

🎯 用例

🏀 对于专业俱乐部

剧本 :LFB俱乐部希望招募一名球员来满足特定需求。

解决方案篮教练 :

  • 需求分析VIA ScoutingAgent.identify_recruitment_needs()
  • 可用玩家的比较 ScoutingAgent.compare_players()
  • 生成完整的侦察报告
  • 通过MLOps仪表板进行连续性能监控

🏥 对于医务人员

剧本 :伤害管理和预防。

解决方案篮教练 :

  • 通过以下方式咨询指导方针 search_guidelines("prévention blessures cheville")
  • 个性化预防计划通过 TrainingAgent
  • 通过指标监控进行恢复监控

📊 对于体育分析师

剧本 :为重要比赛做战术准备。

解决方案篮教练 :

  • 通过分析不利趋势 CoachingAgent.analyze_opponent_tendencies()
  • 生成自定义游戏计划
  • 使用IA的自动赛后报告

🔬 Pourles数据科学家

剧本 :ML模型的开发和监控。

解决方案篮教练 :

  • 带气流和MLflow的完整MLOPS管道
  • 跟踪经验和模型版本控制
  • 监测数据和概念的漂移
  • 实时监控仪表板

🚀 MLOps与DevOps的区别

方面 DevOps MLOps
生命周期 代码+基础设施 代码+数据+模型
部署 应用程序 模型+应用程序
监控 技术性能 模型性能+数据漂移
再现性 部署环境 数据+培训+环境
测试 单元测试/集成 数据+模型+基础设施测试

篮球教练MCP 通过以下方式实施MLOPS最佳实践:

  • ✅ CI/CD 用于自动化
  • ✅ MLW 为了再现性
  • ✅ 气流 为我编排
  • ✅ 监控 pour la监视继续
  • ✅ 轮廓化 为了便携性

📞 支持

如果您有任何问题,请在GitHub存储库中打开问题。


篮球教练MCP - 通过AI和MLOps彻底改变您的篮球方式 🏀✨