Scikit-learn classifiers toolbox for morphological perceptrons.
- Scikit-learn classifiers:
- Linear Dilation-Erosion Perceptron (l-DEP)
- Dilation-Erosion Perceptron (DEP)
- Simple Dilation and Erosion Morphological Perceptrons
- Modular wrapper for DCCP optimization tasks with
cvxpy
File tree:
src/sklearn_morpho: contains the source code and a testsuite in itstestssubdirectory.tests: pytest testsuite.testing: standalone files that use this library. They are used internally for testing, but they are not tests nor part of the library.MREs: standalone jupyter notebooks to showcase some of this library's features.
Take a look at the Jupyter code examples in the MREs directory.
Install Python 3 and hatch. Then run one of these commands:
hatch run jupyter labto run the Jupyter notebookshatch run pytestfor testshatch shellto run testing files liketesting/display_boundary.pyin the right environment.
Special note for the estimators comparison testing files: they are split in two files to avoid training the estimators every time one wants to view the results.
As the project is open source, any help is greatly appreciated!
To keep code clean, this repository uses a CI/CD pipeline with tests and an enforced coding style, which can all be found in the project's configuration files.
Please adhere to these rules when contributing.
Regarding AI pull requests, they are generally discouraged as you should be able to understand and help maintaining any features you add to this repo.
The Python package is available in the
Arch User Repository as python-sklearn-morpho, as
are all its dependencies not already in the official packages, except for
dccp.
Since the latter is an optional dependency, you can either:
- Download
dccpthrough pip or usepip install sklearn-morpho[dccp]in a Python virtual environment. - Download
python-sklearn-morphofrom the AUR and usepip install dccp --user.
Perceptrons are the fundamental building blocks of many machine learning constructs, namely the well-known neural networks.
They fulfill this role because their simple yet effective activation function
(
In the equation above,
"Morphological" perceptrons are similar to the aforedescribed "classical"
perceptrons, but differ in the fact that they generally do not have a bias
While, as established above, a classical perceptron computes several
multiplications followed by a summation, a morphological perceptron performs
multiple additions, followed by a
This simple shift into a different semiring creates a more complex decision boundary, making these constructs a natural choice for designing binary classifiers.
This repository explores the behavior of such perceptrons, namely standalone ones, but also more complex structures, such as DEP and l-DEP.