This code generates FEN code according to the location of chess pieces, using the SGDClassifier machine learning model.
Original file is located at colab
- This code generates FEN code according to the location of chess pieces, using the SGDClassifier machine learning model.
- The method is similar to the famous MNIST problem.
- The training data contains 18,000 chessboards.
- The code then creates 60,000 images from these chessboards, each containing 64 squares, with up to 32 pieces in the game.
- example: FEN code: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
- cv2
- numpy
- pandas
- glob
- os
- re
- tqdm
- matplotlib
normalizeBoardName(boardName):
this function normalizes the FEN code.
- Introduction of the folder that contains the images.
- Define a function to normalize the FEN code.
- Creation of 60,000 images from the chessboards, where each board contains 64 squares and at most 32 pieces.
- Save the 60,000 images in an Excel file.
- Read the data from the directory.
- Convert categorical features to numerical.
- Split the data into training and testing sets.
- after trainig a SGDClassifier model we can simply predict the fen codes of each chess board
Original file is located at colab
-
more info about fen: fen_wiki
-
the training data contains 18k chess board ( G_drive)
-
the data for trainig the mode(60k-peice)( G_drive )
-
the test data (the answers should be checked visually)( G_Drive)
Mnist data can load from google drive: MNIST