Skip to content

This code generates FEN code according to the location of chess pieces, using the SGDClassifier machine learning model.

Notifications You must be signed in to change notification settings

strumer69/sgd_classifier_OpenCV_

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

SGD_classifier_OpenCV

This code generates FEN code according to the location of chess pieces, using the SGDClassifier machine learning model.

chess peice detection

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

Libraries Used

  • cv2
  • numpy
  • pandas
  • glob
  • os
  • re
  • tqdm
  • matplotlib

Functions

normalizeBoardName(boardName):

this function normalizes the FEN code.

Process

  • 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.

Exploratory Data Analysis (EDA) and Data Cleaning.

  • Convert categorical features to numerical.
  • Split the data into training and testing sets.

train a model and prediction

  • after trainig a SGDClassifier model we can simply predict the fen codes of each chess board

Credits

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

About

This code generates FEN code according to the location of chess pieces, using the SGDClassifier machine learning model.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published