<jupyter_start><jupyter_text>Occupancy of Squares in Game of Chess Problem StatementLots of information is contained within a single chess game, let alone a full dataset of multiple games. It is primarily a game of patterns, and data science is all about detecting patterns in data, which is why chess has been one of the most invested in areas of AI in the past. The dataset 'games.csv' collects all of the information available from 20,000 games. The aim is to analyse the occupancy of each square on the chess board so as the predict the most important squares in the game of Chess which might help the player to win the game.  We will explore the problem in following stages:1. Data Exploration - checking which data is useful from the file2. Data Cleaning – imputing missing values in the data3. Feature Engineering – extract moves from each game4. Model Building – making predictive models on the data  Dataset description    Game ID;    Rated (T/F);    Start Time;    End Time;    Number of Turns;    Game Status;    Winner;    Time Increment;    White Player ID;    White Player Rating;    Black Player ID;    Black Player Rating;    All Moves in Standard Chess Notation;    Opening Eco;    Opening Name;    Opening Ply (Number of moves in the opening phase);  Steps involved :1. extract moves from each game2. turn move string into a new column3. extract occupied squares from moves in each game4. build a dictionary and store frequency of square occupied as values (normalized)5. draw a board and visualize data  Data Exploration  Import the necessary libraries<jupyter_code># import the necessary packages to process or plot the data
# i.e. pandas, numpy, matplotlib, matplotlib.pyplot, re, csv<jupyter_output><empty_output><jupyter_text>Read and see the csv file<jupyter_code># read the file using read_csv function
# using the head function see what is originlly present in the dataset<jupyter_output><empty_output><jupyter_text>Shape of the dataset<jupyter_code># check the shape of dataset using data.shape<jupyter_output><empty_output><jupyter_text>Size of the dataset<jupyter_code># check the shape of dataset using data.size<jupyter_output><empty_output><jupyter_text>Description of all particular column of the dataset<jupyter_code># use data.describe to get details of all the columns<jupyter_output><empty_output><jupyter_text>To see the  datatypes  or size of columns information of the dataset use .info()<jupyter_code># use data.info to get data type of each column<jupyter_output><empty_output><jupyter_text>Data Cleaning  To check the null values in the dataset<jupyter_code># use issnull function to check number of nulls in each column<jupyter_output><empty_output><jupyter_text>Feature Engineering  Extracting the moves column<jupyter_code># extract moves from each game and name the file<jupyter_output><empty_output><jupyter_text>Separating each move<jupyter_code># turn moves string into a new column 'each_move' saperated by comas<jupyter_output><empty_output><jupyter_text>Model Building   Looking for the Square Occupied in each move1. Defining a function squares2. Defining a array squares3. For each move (stored in m) we are extracting the square occupied4. Defining Squares Occupied during Casteling on both sides5. Defining the square for other special notation in Chess6. Finally storing the square in 'square' cloumn All the chess notations are provided in readme.md file<jupyter_code># extract occupied squares from moves in each game<jupyter_output><empty_output><jupyter_text>Storing the frequency of each square to sq_count<jupyter_code># build a dictionary and store frequency of square occupied as values (normalized)<jupyter_output><empty_output><jupyter_text>Normalising the frequency values in range of [0,1] for each square<jupyter_code># normalize value<jupyter_output><empty_output><jupyter_text>Making a list of all the square representation<jupyter_code># turn dictionary values into lists, for data visualization in next steps<jupyter_output><empty_output><jupyter_text>Visualising  the board with the freauency<jupyter_code># draw a board and visualize data


# We want to show all ticks...

# ... and label them with the respective list entries


# Rotate the tick labels and set their alignment.

# Loop over data dimensions and create text annotations.

# print<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05193014705882353, 'fraction_numerical': 0.00505514705882353, 'mean_word_length': 5.497014925373135, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '610416', 'license': 'MIT', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1188, 'n_words': 555, 'path': 'Chess_Square_Occupancy/chess_most_occupied_squares_template.ipynb', 'repo_name': 'abhisngh/Data-Science', 'size': '4352'}