A Python tool for analyzing champion winrate trends over game length in League of Legends, identifying patterns and correlations between different champions.
This tool extracts champion winrate vs. game length data from LoLalytics, processes the SVG path data into point coordinates, analyzes correlations between these game-length-dependent winrate trends, and generates visualizations of the results. The analysis helps identify which champions perform better in early, mid, or late game scenarios, and which champions have similar performance patterns.
- Data Acquisition:
- Extract SVG path data from LoLalytics champion pages using Playwright
- Collect champion metadata including names, roles, and win rates
- Data Processing:
- Parse SVG path data into point coordinates representing game time vs. winrate
- Pre-process data for correlation analysis and clustering
- Analysis:
- Multiple clustering strategies (Hierarchical, Threshold-based)
- Calculate correlations between champion winrate trends
- Group champions into clusters based on similar winrate patterns
- Find champions with similar performance patterns to a target champion
- Visualization:
- Generate static and interactive cluster visualizations
- Create correlation network graphs
- Plot winrate curves for individual champions and cluster profiles
- Compare multiple champions' performance patterns
winrates/
├── data/ # Data files
│ ├── champion_svg_paths.json # SVG paths for champion win rate curves
│ ├── champions.json # Champion metadata
│ └── outputs # Generated visualizations and analysis results
├── src/ # Source code
│ ├── acquisition/ # Data acquisition modules
│ │ └── svg_extractor.py # SVG path extraction from LoLalytics
│ ├── processing/ # Data processing modules
│ │ └── svg_parser.py # SVG path parsing utilities
│ ├── analysis/ # Analysis modules
│ │ ├── champion_path_clustering/ # Champion clustering
│ │ │ ├── clusterer.py # Core clustering implementation
│ │ │ ├── factory.py # Strategy factory pattern
│ │ │ ├── strategies/ # Different clustering algorithms
│ │ │ └── types.py # Type definitions
│ │ └── graph_correlation.py # Correlation utilities
│ ├── visualization/ # Visualization modules
│ │ └── cluster_visualizer.py # Visualization for results
│ ├── utils/ # Utility functions
│ │ └── logger.py # Logging utilities
│ ├── examples/ # Example scripts
│ └── main.py # Main entry point
├── tests/ # Test files
├── docs/ # Documentation
├── pyproject.toml # Project configuration and dependencies
-
Clone the repository:
git clone https://github.com/yourusername/winrates.git cd winrates -
This project uses Rye for dependency management. Install Rye if you don't have it:
curl -sSf https://rye-up.com/get | bash -
Set up the project with Rye:
rye sync
-
Install Playwright browsers:
rye run install-playwright
To scrape champion data from LoLalytics:
# Scrape all champions
rye run dev acquire --all
# Scrape specific champions
rye run dev acquire --champions Aatrox Ahri Akali
# Customize patch, tier, or region
rye run dev acquire --all --patch 30 --tier platinum_plus --region naTo analyze champion clusters using different strategies:
# Using threshold-based clustering (default)
rye run dev cluster --clustering-method threshold
# Using hierarchical clustering
rye run dev cluster --clustering-method hierarchical
# Customize clustering parameters
rye run dev cluster --clustering-method threshold --correlation-threshold 0.85 --interactiveTo find champions with similar win rate patterns:
rye run dev cluster --champion AatroxThe tool automatically generates visualizations during analysis. Output files are saved to the data/outputs/ directory and include:
- Static cluster visualizations (PNG)
- Interactive cluster visualizations (HTML, when using the --interactive flag)
- Correlation network graphs
- Individual cluster profile visualizations
The project includes several useful commands configured in the pyproject.toml file:
- Run tests:
rye run test - Run tests with coverage:
rye run test-cov - Check code quality:
rye run lint - Format code:
rye run format - Type checking:
rye run typecheck - Run the application:
rye run dev
Python 3.12 or higher is required. Key dependencies include:
- numpy, scipy, pandas for data processing
- matplotlib, seaborn, plotly for visualization
- networkx for graph analysis
- scikit-learn for clustering algorithms
- playwright for web automation
- rich for console output
This project is licensed under the MIT License.