Machine learning application for game Rock-Paper-Scissors
Main purpose is to make algorithm to classify picture of hand to certain class, which is rock, paper or scissors. Alternatively application can be used for any set of pictures.
$ Python
$ joblib
$ matplotlib
$ numpy
$ pandas
$ Pillow
$ scikit-learn
It is best to use the python virtualenv tool to build locally:
$ git clone https://github.com/BartekStok/ML-rock-paper-scissors
$ cd 05_ml_rps_game
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
- First go to
settings.pyand set path to picture folders. Then set names for labels. Folders must be named just like the labels to recognize. Lastly choose size of picture. - Go to
preprocess.pyand run the program. Be aware that all pictures in given paths will be resized to chosen size! In data folder inside rps_model will appear files named after folder name. - Run file
model_train.py. There should appear plot with random samples like:
Plot with amounts of data to process:
And Confusion matrix with model data as is and in percentage:
Also in python console will be printed all model scores i.e. Accuracy, Precision, Recall, and F1 Score. - If You want to run full cross validation with various solvers,
then in
model_train.pyis a section with cross validation function, uncomment it and run file. Be aware that it takes long time to compute, depending from amount of data. - At the very bottom of the
model_train.pyfile, there is a section to train final model with all data available, and to export model to a file. Uncomment for execution. - Next step is
varia.py, where, after running the file, and with given results from cross validation, two plots should appear:
It is a comparison of data from cross validation with different solvers.
- Last step is to predict. File
predict.pyis for that, it loads saved model, then after setting up proper path to an image, prediction should be made.
This project is licensed under the MIT License
- Copyright 2020 © Bartłomiej Stokłosa