In this post we will analyze some of my bullet games on Lichess. I love playing chess, and I try to play bullet games almost every day, at least 3-4 games. I thought, it is time to analyze some of my games with Python. To be able to do it, we need to use the Lichess API to export my games. There is already a client package implemented in Python3 called Berserk, so I will be using it.
We will use pandas to manipulate the data and matplotlib to plot some charts (hopefully we will get some meaning based on them).
I have more than 5000 games as of the data 16th Oct 2023. We will be analyzing last 1000 games.
Let’s begin.
I got help from ChatGPT while creating this notebook.
# Count the occurrences of each categorycategory_counts=df['winner'].value_counts()# Plot a bar chart with counts displayed on top of each barplt.figure(figsize=(8,6))bars=plt.bar(category_counts.index,category_counts.values,color='skyblue')# Add counts as labels on top of the barsforbarinbars:yval=bar.get_height()plt.text(bar.get_x()+bar.get_width()/2,yval,int(yval),ha='center',va='bottom')plt.xlabel('Player')plt.ylabel('Count')plt.title('Winner Counts Based on Color')plt.xticks(rotation=0)# Rotate x-axis labels if necessaryplt.show()
Let’s create a new column to check if I won that game. To get the value
# Count the occurrences of each categorycategory_counts=df['did_i_win'].value_counts()# Plot a bar chart with counts displayed on top of each barplt.figure(figsize=(8,6))bars=plt.bar(category_counts.index.values,category_counts.values,color='skyblue')# Add counts as labels on top of the barsforbarinbars:yval=bar.get_height()plt.text(bar.get_x()+bar.get_width()/2,yval,int(yval),ha='center',va='bottom')plt.xlabel('Is the Game a Win')plt.ylabel('Count')plt.title('Did I Win the Game')plt.xticks(range(len(category_counts.index)),category_counts.index)# Set x-tick labelsplt.show()
It seems like I lost 505 games whereas I won the 495 games, it is almost 50/50. No improvement at all 😄