Since I created an account on chess.com in 2020, I have played an unhealthy amount of games on the website and all my games are saved in their database. The trail of data I have created over the years should contain huge secrets of my own gameplay, but the stats I see on my profile are too basic and do not offer useful plans to improve. If I could to decipher more from the data of my games, I could get potential insights into my strengths and weaknesses. This could help me reach new heights in my own gameplay as I seem to have reached a plateau. This was an opportunity to use my workplace analytics knowledge, in something from my personal life.
Firstly, I am a ruby enthusiast. So, I will use Ruby despite it not being the most suited for the job.
Chess.com provides a free API to read their data. I wanted to do what the analysts do, so I used a jupyter notebook (and installed ruby in it). The closest thing to pandas for python was Daru gem for ruby. Once both of these were setup in a Jupyter Notebook all I had to do next, is invoke a Net::http method to read the games data into a dataframe.
While reading the data, I figured that there is a lot of data and I need to decide which information looks useful for processing. I arrived at the below list of data points.
[“date_time”,“game_type”,“my_color”,“opponent_id”,“my_elo”,“opponent_elo”,“result”,“result_type”,“game_url”,“pgn”]
The data captured the elo ratings of each player at the time of the game, so I had to add the current ratings for myself and my opponent to see how both have progressed since that game. I also added a few columns by splitting the pgn of the game and creating dedicated columns for the first few moves. The aforementioned columns were added.
[“opponent_curr_elo”,“my_curr_elo”,“moves_3”,“moves_4”,“moves_5”,“moves_6”,“moves_9”]
Now that I had all the data, it was time to produce insights. The first set of values I prepared, represent the basics stats from a given time period (2023)
Category Number of Games Wins Loss Draw Start Elo Net Wins
bullet 1638 813 796 29 1275 +17
blitz 1389 691 660 38 1271 +31
rapid 409 198 192 19 1711 +6
daily 5 5 0 0 1380 +5
blitz_chess960 2 1 1 0 1293 0
I am interested in looking at games I played as a rematch.
Category Opponent Games Wins White wins Black wins Net Result Opp Then Opp Now Me Now Opp Growth
bullet Pranavnar0 18 9 6/9 3/9 +9 -9 =0 1273 1354 1312 +81
bullet LuckyJAL 8 4 2/4 2/4 +4 -4 =0 1279 1390 1312 +111
bullet archit12345archit 8 5 2/4 3/4 +5 -3 =0 1335 1253 1312 -82
bullet TamerKartal 7 2 2/3 0/4 +2 -3 =2 1241 1343 1312 +102
bullet Sonoftheking 7 1 1/4 0/3 +1 -6 =0 1313 1248 1312 -65
rapid xan51311 6 1 0/3 1/3 +1 -4 =1 1786 1782 1741 -4
rapid Tricko3 6 1 1/3 0/3 +1 -5 =0 1600 1415 1741 -185
bullet 4fitplz 6 2 2/3 0/3 +2 -4 =0 1257 1375 1312 +118
bullet xRoland22 5 1 0/3 1/2 +1 -4 =0 1419 1317 1312 -102
bullet liebrelenta 5 1 0/2 1/3 +1 -3 =1 1202 771 1312 -431
I would like to classify a game as interesting if my opponent has gone on to much higher ratings after losing to me.
Category Opponent My Color Opp Then Opp Now Result Game
rapid iqraathemanuel BLACK 1758 2111 checkmate https://www.chess.com/game/live/72291672333
rapid Kingabhinav1 WHITE 1590 2049 resignation https://www.chess.com/game/live/73532351367
rapid Stalinguard WHITE 1676 2035 checkmate https://www.chess.com/game/live/73669440277
blitz kvvkxo WHITE 1295 2047 checkmate https://www.chess.com/game/live/93628825705
blitz tonybn7 WHITE 1437 1924 time https://www.chess.com/game/live/71864135259
blitz Iudexxx WHITE 1431 1901 resignation https://www.chess.com/game/live/67380230147
I would also classify a game as interesting if my opponent has gone on to much lower ratings after defeating me.
Category Opponent My Color Opp Then Opp Now Game
rapid daviduzbek BLACK 1452 1268 https://www.chess.com/game/live/79365901871
rapid Cesare1976 BLACK 1555 1270 https://www.chess.com/game/live/76364542191
rapid Rustam_Chelyabinsk WHITE 1482 1311 https://www.chess.com/game/live/79383088219
blitz Hwem WHITE 1496 462 https://www.chess.com/game/live/78403338519
blitz lts_Mee BLACK 1495 981 https://www.chess.com/game/live/95637537755
blitz WayTooFried BLACK 1212 1046 https://www.chess.com/game/live/66298861847
Now, I want to look at my opening moves in each side. So, first of all pulling the number of games for each color.
games
BLACK 1716
WHITE 1727
Looks like a healthy amount of data. Now, I can check my most frequented opening lines from each side.
As White
moves_3 total WIN LOSE DRAW
e4 e5 Nf3 Nc6 Bc4 368 190 169 9
e4 c6 Nf3 d5 Nc3 254 132 118 4
e4 c5 Nf3 Nc6 Bc4 115 64 49 2
e4 e6 Nf3 d5 Nc3 98 54 42 2
e4 c5 Nf3 d6 Bc4 95 46 45 4
As Black
moves_3 total WIN LOSE DRAW
e4 d6 d4 Nf6 Nc3 336 177 144 15
e4 d6 Nf3 Nf6 Nc3 186 98 85 3
e4 d6 d4 Nf6 Bd3 97 48 43 6
d4 Nf6 c4 e6 Nc3 68 24 42 2
d4 d6 c4 Nf6 Nc3 63 35 27 1
Lastly, I wanted to check my performance in each opening.
Caro : +130-118=4 [12]
Stafford : +14-12=0 [2]
Scandinavian : +18-10=1 [8]
Sicilian : +184-182=8 [2]
Italian : +188-169=9 [19]
Pirc : +264-225=24 [39]
Indian Game : +29-21=1 [8]
Nimzo-Indian Game : +34-57=2 [-23]
Looks like i need to study the Nimzo Indian before I play it again.
This already looks like an interesting result from an analytics exercise point of view. I am preparing new lines and noticing patterns in my openings which led to more loses. There is a scope to improve the script further, but I would like to focus now on using the script and improving my chess further.