Skip to content

About

Exploratory data analysis & ML applied to 40,000 chess games

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

30 Commits

Folders and files

Repository files navigation

Data Science & Machine learning Analysis of Chess Games

Files

  • Data:

    • games.csv: ~20,000 Lichess games
    • games2.csv: ~20,000 Grandmaster games
    • games3.csv AI-Generated Games via stockfish
  • main.ipynb: main data analysis project conducted. Polished & in-depth

  • ai_games.ipynb: processed of generating games (optimized for Mac M3, parallelized, very heavy)

  • experimental: experimental, advanced, but unpolished drafts of future work (training GPT chessbot, in-depth analysis of selected chess openings, analysis of chess moves in latent space)

Project Overview

This analysis examines three distinct chess datasets to understand how factors like player ratings influence game outcomes, length, and strategies. The project compares:

  • Modern online games from Lichess.org
  • Historical grandmaster games
  • AI games generated by Stockfish

Key Findings

  • Player skill level strongly correlates with:

    • Game length (higher-rated games tend to be longer)
    • Victory conditions (higher-rated players resign more often vs. getting checkmated)
    • Draw frequency (increases with player rating)
    • Opening move selection (d4 and Nf3 become more common at higher ratings)
  • White maintains advantage across skill levels:

    • 49.86% win rate for white
    • 45.40% win rate for black
    • 4.74% draw rate
  • Opening preferences:

    • e4: 62.81% of games
    • d4: 22.54%
    • Nf3: 3.61%
    • c4: 3.57%

Data Sources

Models

Implemented a K-Nearest Neighbors model to predict player ratings based on:

  • Opening moves
  • Game outcomes
  • Opponent ratings
  • Victory conditions

Model Performance:

  • 69.9% accuracy within 100 rating points
  • 85.2% accuracy within 200 rating points
  • 92.7% accuracy within 300 rating points
  • Median absolute error: 8.2 rating points

Technologies Used

  • Python
  • Libraries: pandas, plotly, numpy, scipy.stats
  • Stockfish Chess Engine API

Additional Resources

About

Exploratory data analysis & ML applied to 40,000 chess games

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages