Examples
MNIST and other image datasets
This page is a stub: a first draft that has not yet been reviewed.
Algebraic Machine Learning (AML) has been tested on standard image-classification datasets: handwritten digits (MNIST), clothing items (FashionMNIST), small colour photographs (CIFAR-10) and several sets of medical images (MedMNIST). The results are given in a table further down, beside those of a family of multilayer perceptrons trained for the comparison.
The MNIST embedding
There are \(2 \times 28 \times 28\) constants for the pixels and constants \(digit_i\), \(i = 0, 1, \dots, 9\), for the ten classes. The images are binarized by thresholding pixel values. The 50,000 training examples are each encoded as a positive duple \(digit_i \leq image_k\), and there are 450,000 negative duples of the form \(digit_{j \neq i} \not\leq image_k\). The model is computed with Sparse Crossing.1
Classifying a test image
A trained model can be read in three ways.
Direct assignment
A test image is classified as digit \(i\) when the atoms in the lower atomic segment of \(digit_i\) are a subset of the atoms in the lower atomic segment of the term that represents the image. After training, about 70% of the test images have a digit assigned in this way. The shortfall is attributed to a training set that is not large enough to give an assignment for every test example.
Fewest misses
The misses of a duple are the atoms in the lower atomic segment of its left-hand side that are not in the lower atomic segment of its right-hand side. A test image is classified as the digit with the fewest misses. For the query of whether a test image is a 7, the mean is 11 misses for test examples of the digit 7 and 1,192 for the other digits, with very small overlap between the two distributions.2
Logistic regression on the AML output
Each atom is given the value \(+1\) if it is in the lower atomic segment of the image term and \(-1\) if it is not. The resulting sequence is the input to a logistic regression with one softmax output per class, trained on the training dataset only, with the Adam optimizer and cross-entropy loss.3
Greyscale and colour images
For the other datasets each pixel and colour channel is embedded with two chains of constants ordered by intensity, as described on Encoding a task. The smallest MedMNIST datasets were kept at their original 256 grey levels. For the larger medical images, FashionMNIST and CIFAR-10, the intensity resolution was reduced to 20 levels to speed up computation.4
Training protocol
Each model was trained on its training set alone; no validation set was used, either to choose settings or to decide when to stop. All datasets were processed in the same way, with the hyperparameters given on Sparse Crossing. A single AML model was obtained for each dataset, and training stopped when the union model had zero error on the training set. Before evaluation the model was reduced to a tenth of its size by subset selection.4
Results
The table gives test accuracy. Under each dataset are the image size, the number of classes and the numbers of training, validation and test examples. The AML models used only the training data. Under each best MLP is the number of neurons in each of its hidden layers.5
| Dataset | AML, fewest misses | AML, logistic regression | MLP, best | MLP, mean ± std |
|---|---|---|---|---|
| MNIST 28 × 28, 10, 50000/10000/10000 | 97.63% | 98.43% | 98.46% (2048, 1024, 128) | 98.03% ± 0.21% |
| MNIST 28 × 28, 10, 1000/10000/10000 | 90.24% | 91.56% | 88.70% (4096, 256, 128) | 87.73% ± 1.54% |
| fashionMNIST 28 × 28, 10, 50000/10000/10000 | 87.27% | 89.47% | 89.52% (4096, 256) | 88.40% ± 0.45% |
| fashionMNIST 28 × 28, 10, 1000/10000/10000 | 79.62% | 81.89% | 80.73% (2048, 256) | 79.52% ± 1.57% |
| CIFAR-10 32 × 32, 10, 50000/5000/5000 | 48.56% | 53.60% | 54.58% (4096, 256) | 54.12% ± 0.79% |
| CIFAR-10 32 × 32, 10, 1000/5000/5000 | 36.33% | 38.49% | 36.23% (4096, 256, 512) | 35.58% ± 0.63% |
| dermaMNIST 28 × 28, 7, 7007/1003/2005 | 73.47% | 74.21% | 65.94% (4096, 2048, 128, 256) | 55.97% ± 3.28% |
| pneumoniaMNIST 28 × 28, 2, 4708/524/624 | 84.62% | 85.90% | 87.66% (2048, 256, 512) | 87.63% ± 1.19% |
| pneumoniaMNIST 64 × 64, 2, 4708/524/624 | 84.13% | 84.93% | 87.50% (512, 256, 256) | 87.35% ± 1.29% |
| organCMNIST 28 × 28, 11, 12975/2392/8216 | 81.28% | 86.75% | 76.44% (4096, 2048, 128) | 75.04% ± 1.33% |
| bloodMNIST 28 × 28, 8, 11959/1712/3421 | 85.26% | 90.93% | 85.30% (4096, 1024, 256) | 84.87% ± 1.56% |
| bloodMNIST 64 × 64, 8, 11959/1712/3421 | 87.55% | 92.90% | 89.16% (2048, 256, 256) | 86.76% ± 1.30% |
The authors’ reading of the table is that “the test accuracy of a single algebraic model using logistic regression on top is comparable to the best performing MLP”. The AML model is obtained from training data only, whereas for the MLPs validation data is also used, to select the best of 360 configurations and to stop training early.1
How the MLP baseline was built
Multilayer perceptrons were chosen because, like the embedding used for AML, they have no image-specific biases. The comparison used perceptrons with two, three and four hidden layers and ReLU activations, in 360 training runs: 90 with two layers, 180 with three and 90 with four. The sizes of the first two hidden layers were chosen by grid search with Ray Tune, with the goal of minimizing validation loss; the sizes of the third and fourth layers, the learning rate and the L2-regularization coefficient were sampled. Training ran for 240 iterations or until the validation loss had not improved for 10 iterations, with the Adam optimizer and cross-entropy loss. The validation dataset was used to stop training and to select the best model.6
Limitations
- About 70% of the MNIST test images are assigned a digit by the subset condition itself. The other figures in the table rest on the fewest-misses rule or on logistic regression.
- The intensity resolution of several datasets was reduced from 256 to 20 levels to reduce the computational load.
- The hyperparameters of Sparse Crossing were set manually, from experience with synthetic datasets and MNIST. The other datasets had no influence on the setting.
References
- Martin-Maroto, Abderrahaman, Méndez and de Polavieja (2025), Algebraic Machine Learning: Learning as computing an algebraic decomposition of a task, arXiv:2502.19944.
See also
The MNIST tutorial trains a model on binarized MNIST images with the Open-AML-Engine and classifies test images by fewest misses.
Footnotes
-
Martin-Maroto et al. (2025), section “Learning from data”. ↩ ↩2
-
Martin-Maroto et al. (2025), Figure 4a. ↩
-
Martin-Maroto et al. (2025), section “Learning from data”; Methods, “AML models”. ↩
-
Martin-Maroto et al. (2025), Table 3. ↩
-
Martin-Maroto et al. (2025), section “Learning from data”; Methods, “Multi-layer perceptrons”. ↩