Implementation of a perceptron algorithm that trains a binary classifier to classify points inside and outside an ellipse using Python + NumPy, Numba, Matplotlib, and SciPy.
Check out the following Medium stories to know more about this project:
You need Python 3.12 and pipenv. Then, create a virtual environment and install the needed dependencies:
pipenv shell
pipenv install
Alternatively, you can use venv or any other virtual environment tool and install the following packages:
- numpy 2.0
- numba 0.60
- matplotlib 3.9
- scipy 1.14 (required for Numba to solve systems of linear equations)
Run the script __main__.py
:
python .
You should see a GUI that allows you to add your own points and train the classifier. Controls:
- Left-click to add a point inside the ellipse;
- Right-click to add a point outside the ellipse;
- Enter the number of training iterations and click "Train" to train the classifier with a custom number of iterations.
Also, Matplotlib provides a toolbar with position and zoom controls.