A comprehensive machine learning system for predicting Go player ranks (1D-9D) from game move sequences. This project implements a multi-model ensemble approach combining traditional ML and deep learning techniques to achieve state-of-the-art performance.
- Features
- Quick Start
- Installation
- Project Structure
- Usage
- Model Architecture
- Feature Engineering
- Performance
- Advanced Usage
- Troubleshooting
- Contributing
- License
- 9 different model architectures ranging from traditional ML to cutting-edge deep learning
- Automatic ensemble with probability averaging for robust predictions
- Support for both tabular and sequence-based approaches
- ~389 base features with statistical aggregations
- ~48 enhanced features with domain-specific Go metrics
- ~437 combined features for maximum model capacity
- Temporal dynamics, phase-specific patterns, and strategic indicators
- Automatic model training if artifacts are missing
- Progress tracking with tqdm progress bars
- Cross-validation and early stopping
- GPU acceleration with automatic fallback to CPU
- Handles variable-length sequences (50-8000+ moves)
- Long-sequence support with S4, PatchTST, and BigBird
- Multiple chunking strategies for memory efficiency
- Data augmentation with overlapping sub-games
# Clone the repository
git clone https://github.com/solitude6060/Go-Rank-Prediction.git
cd Go-Rank-Prediction
# Install dependencies
pip install -r requirements.txt
# Train a baseline model
python training.py --model xgboost_v2 --feature-mode combined
# Generate submission file
python Q5.py --model auto
# Output: submission.csv and submission_meta.jsonNote: Training data (train_set/) and test data (test_set/) are not included in this repository due to size constraints. Place them in the project root directory before running.
- Python 3.10 or higher
- CUDA-compatible GPU (optional, for faster training)
- 8GB+ RAM recommended
# Core dependencies
pip install numpy pandas scikit-learn xgboost torch tqdm
# Optional: For long-sequence models
pip install einops transformersOr install all at once:
pip install -r requirements.txtGo-Rank-Prediction/
βββ README.md # This file
βββ README.txt # Plain text documentation backup
βββ LICENSE # MIT License
βββ requirements.txt # Python dependencies
βββ .gitignore # Git ignore rules
β
βββ Q5.py # Main inference script
βββ training.py # Main training script
β
βββ src/ # Core source modules
β βββ __init__.py
β βββ data.py # Data parsing & loading
β βββ features.py # Base feature engineering (~389 features)
β βββ features_enhanced.py # Enhanced features (~48 features)
β βββ augmentation.py # Data augmentation utilities
β βββ models_sklearn.py # Sklearn models (Logistic Regression)
β βββ models_xgb.py # XGBoost (base)
β βββ models_xgb_enhanced.py # XGBoost v2 (with enhanced features)
β βββ models_torch.py # PyTorch models (MLP/GRU/Transformer)
β βββ models_longseq.py # Long-sequence models (S4/PatchTST/BigBird)
β
βββ submissions/ # Generated submission files
β βββ submission_*.csv
β βββ submission_meta.json
β
βββ tests/ # Test and debug scripts
β βββ debug_device.py
β βββ test_gpu.py
β βββ test_game_split.sh
β
βββ utils/ # Utility scripts
β βββ check_data_stats.py # Dataset statistics
β βββ compare_results.py # Compare submission files
β βββ diagnose_features.py # Feature distribution analysis
β βββ data_utils_spilt.py # Game splitting utilities
β
βββ scripts/ # Experiment automation
β βββ run_all_experiments_with_game_split.sh
β βββ run_key_experiments_game_split.sh
β
βββ docs/ # Additional documentation
β βββ EXPERIMENTS_README.md # Experiment tracking guide
β βββ QUICK_START.md # Quick start tutorial
β
βββ submission_sample.csv # Sample submission format
β
βββ train_set/ # Training data (not in repo - too large)
βββ test_set/ # Test data (not in repo - too large)
βββ models/ # Trained models (not in repo - too large)
The training.py script provides a unified CLI for training all supported models.
# Logistic Regression baseline
python training.py --model sklearn
# XGBoost (base features)
python training.py --model xgboost
# XGBoost v2 (enhanced features - recommended)
python training.py --model xgboost_v2 --feature-mode combined# Multi-Layer Perceptron on aggregated features
python training.py --model mlp --epochs 50 --batch-size 32
# GRU sequence model
python training.py --model gru --max-len 512 --epochs 20
# Transformer sequence model
python training.py --model transformer --batch-size 8 --epochs 15For games with 1000+ moves:
# S4 with Multi-Instance Learning
python training.py --model s4_mil --max-len 2048 --batch-size 16
# PatchTST encoder + XGBoost head
python training.py --model patchtst_xgb --max-len 2048
# BigBird hierarchical attention
python training.py --model bigbird_hier --max-len 8192 --batch-size 4# With data augmentation
python training.py --model gru --augment-data
# With game splitting
python training.py --model xgboost_v2 --use-game-split
# With cross-validation
python training.py --model xgboost_v2 --xgb-use-cv --xgb-n-splits 5
# Custom hyperparameters
python training.py --model transformer \
--max-len 1024 \
--batch-size 16 \
--epochs 30 \
--lr 1e-3 \
--weight-decay 1e-4The Q5.py script generates Kaggle-ready submission files.
Automatically uses all available trained models:
python Q5.py --model autoThis will:
- Load all trained models from
models/ - Generate predictions from each model
- Average probability distributions
- Output
submission.csvandsubmission_meta.json
Use a specific model for inference:
# Use XGBoost v2
python Q5.py --model xgboost_v2
# Use Transformer
python Q5.py --model transformer
# Use GRU
python Q5.py --model grupython Q5.py \
--data-dir /path/to/data \
--models-dir /path/to/models \
--submission my_submission.csv| Model | Description | Training Time | Features Used |
|---|---|---|---|
| sklearn | Logistic Regression baseline | ~1 min | ~389 |
| xgboost | Gradient Boosting (base) | ~5 min | ~389 |
| xgboost_v2 | Enhanced XGBoost | ~10 min | 389/48/437 |
| Model | Description | Training Time | Input |
|---|---|---|---|
| mlp | 3-layer MLP | ~5 min | ~389 features |
| Model | Description | Training Time | Max Length |
|---|---|---|---|
| gru | Bidirectional GRU + Attention | ~15 min | 512-1024 |
| transformer | Multi-head Self-Attention | ~20 min | 512-1024 |
| Model | Description | Training Time | Max Length |
|---|---|---|---|
| s4_mil | Structured State Space + MIL | ~30 min | 2048-4096 |
| patchtst_xgb | Patch-based TST + XGB head | ~25 min | 2048-4096 |
| bigbird_hier | Sparse Attention (hierarchical) | ~40 min | 4096-8192 |
Each move in a Go game is represented by:
-
Basic move info (9 features)
- Color (black/white)
- Coordinates (x, y)
- Is pass move
- Move fraction (position in game)
- Strength, winrate, lead, uncertainty
-
Policy distribution (9 values)
- Predicted rank probabilities for this move
-
Value estimates (9 values)
- Win probability estimates per rank
-
Rank probabilities (9 values)
- Neural network rank predictions
Generated by features.py:
- Global statistics: num_moves, white_fraction
- Coordinate stats: mean, std, min, max, median, IQR for x/y
- Per-feature aggregations: 376 features Γ 6 stats each
- Temporal trends: winrate_trend, lead_trend, strength_trend
- Phase-specific: opening/endgame statistics
- Volatility metrics: move quality variation
Generated by features_enhanced.py:
- Opening phase (first 20 moves): pattern recognition
- Middle game (moves 21-100): dynamic analysis
- Endgame (last 20 moves): precision metrics
- Consistency metrics: move quality stability
- Strategic indicators: aggressive/defensive indices
Base + Enhanced for maximum model capacity.
# Base features only (~389)
python training.py --model xgboost_v2 --feature-mode base
# Enhanced features only (~48)
python training.py --model xgboost_v2 --feature-mode enhanced
# All features (~437) - recommended
python training.py --model xgboost_v2 --feature-mode combined| Model | Accuracy | Training Time | GPU Required |
|---|---|---|---|
| sklearn | 65-70% | 1 min | No |
| xgboost | 70-75% | 5 min | No |
| xgboost_v2 | 75-80% | 10 min | No |
| mlp | 68-72% | 5 min | Optional |
| gru | 72-76% | 15 min | Recommended |
| transformer | 74-78% | 20 min | Recommended |
| s4_mil | 76-80% | 30 min | Recommended |
| patchtst_xgb | 77-81% | 25 min | Recommended |
| bigbird_hier | 78-82% | 40 min | Required |
| auto (ensemble) | 80-85% | - | - |
- π Quick baseline:
sklearnorxgboost - π― Best single model:
xgboost_v2(combined mode) - π Long sequences (>1000 moves):
s4_milorbigbird_hier - π Competition submission:
auto(ensemble all models) - π» GPU available:
transformerorgru - β‘ Limited compute:
sklearnormlp
Extract overlapping sub-games to increase training samples:
python training.py --model gru --augment-dataSplit concatenated multi-game records into individual games:
python training.py --model xgboost_v2 --use-game-splitHandle long sequences with different strategies:
# Take first N moves only
python training.py --model gru --chunk-strategy truncate
# Uniform sampling across sequence
python training.py --model gru --chunk-strategy sample --num-chunks 10
# Take last N moves only
python training.py --model gru --chunk-strategy tailRun multiple experiments automatically:
# Run key experiments
bash scripts/run_key_experiments_game_split.sh
# Run all experiments
bash scripts/run_all_experiments_with_game_split.sh# Check dataset statistics
python utils/check_data_stats.py
# Compare submission files
python utils/compare_results.py submissions/submission_*.csv
# Analyze feature distributions
python utils/diagnose_features.pyProblem: RuntimeError: CUDA out of memory
Solutions:
# Reduce batch size
python training.py --model transformer --batch-size 4
# Reduce max sequence length
python training.py --model gru --max-len 256
# Use CPU instead
python training.py --model gru --device cpuProblem: FileNotFoundError: Failed to prepare model artifact
Solutions:
# Train the model first
python training.py --model gru
# Or use auto mode to skip missing models
python Q5.py --model autoProblem: ValueError: Feature dimension mismatch
Solution: Ensure consistent feature mode for XGBoost v2
# Check .feature_names.json for the feature mode used during training
cat models/xgboost_v2_model.feature_names.jsonProblem: Training takes too long
Solutions:
# Use smaller model
python training.py --model mlp --epochs 10
# Reduce epochs
python training.py --model gru --epochs 10
# Use base features only
python training.py --model xgboost_v2 --feature-mode baseProblem: Model accuracy is too low
Solutions:
# Try data augmentation
python training.py --model xgboost --augment-data
# Try game splitting
python training.py --model xgboost_v2 --use-game-split
# Use ensemble
python Q5.py --model autoContributions are welcome! Here are some ways you can contribute:
- Report bugs - Open an issue describing the bug and how to reproduce it
- Suggest features - Propose new features or improvements
- Submit pull requests - Fix bugs or implement new features
- Improve documentation - Help make the docs clearer and more comprehensive
# Clone the repository
git clone https://github.com/solitude6060/Go-Rank-Prediction.git
cd Go-Rank-Prediction
# Install development dependencies
pip install -r requirements.txt
# Run tests
bash tests/test_game_split.sh
python tests/test_gpu.pyThis project is licensed under the MIT License - see the LICENSE file for details.
- KataGo - Neural Go engine used for feature extraction
- PyTorch Team - Deep learning framework
- XGBoost Team - Gradient boosting library
- scikit-learn Team - Machine learning utilities
For questions, issues, or collaboration opportunities:
- GitHub Issues: https://github.com/solitude6060/Go-Rank-Prediction/issues
- Repository: https://github.com/solitude6060/Go-Rank-Prediction
β If you find this project helpful, please consider giving it a star! β
Made with β€οΈ for the Go and Machine Learning communities