Software
Tutorials
Three demonstration notebooks accompany the Open-AML-Engine. This page describes what each notebook does, what it needs, and which pages of this wiki it illustrates. The wiki on Algebraic Machine Learning (AML) does not host the notebooks or reproduce their code; the links below lead to the places where they are maintained.
Descriptions last checked against the notebook files in the engine snapshot AMLEngine_Neurips2026, commit cb462b4 (5 May 2026). The Colab copies linked from the engine README may differ from these files.
Where to find them
| Notebook | Colab copy, as linked from the engine README | Notebook file |
|---|---|---|
| Vertical Bar tutorial | Vertical Bars Demo | AML Vertical Bar Tutorial.ipynb |
| MNIST tutorial | MNIST Demo | AML MNIST Tutorial.ipynb |
| Hamiltonian Graph tutorial | Hamiltonian Graphs Demo | AML Hamiltonian Graph Tutorial.ipynb |
Google Colab requires a Google account. The notebook files can be read on GitHub without one.
To run the notebook files locally, the engine README lists the packages needed in addition to the engine itself: a Jupyter environment, numpy, matplotlib, scikit-learn, networkx and mnists.
Vertical Bar tutorial
Despite its title, this notebook works through the running example of AML: black-and-white images of 4×4 pixels, where an image is positive if its first column is black and every other column has at least one white pixel. The notebook counts 3,375 positive images among the 65,536 possible ones; 3,375 is the number of images in the published example.1
- What it does. The notebook generates all the images, embeds them with one constant per pixel position and colour and a single label constant \(v\), and trains a model with Sparse Crossing on a random sample with equal numbers of positive and negative examples. Classification is purely algebraic: an image is positive when the duple \((v, I)\) holds in the model. The notebook plots accuracy during training, a confusion matrix, and the atoms of the trained model, and sets them beside the atoms of the exact solution. It notes that training recovers the exact solution only some of the time, because the selection of examples and Sparse Crossing are both stochastic.
- Also in the notebook. A section titled “A brief explanation of AML” introduces constants, duples, atoms and the two crossing algorithms.
- Start here. The other two notebooks recommend reading this one first.
- Illustrates. The 4×4 image example, Encoding a task and Sparse Crossing.
MNIST tutorial
- What it does. The notebook reduces the MNIST images of handwritten digits to black and white, and embeds each image with one constant per pixel position and colour, 2 × 784 in all, together with one constant per digit class. It trains in mini-batches with the engine’s Sparse Crossing embedder, which also maintains a union model. It then selects a subset of atoms, which the notebook says is done “as explained in the paper”, classifies test images by fewest misses, reports the results with a confusion matrix, and plots a sample of atoms.
- What it needs.
numpy,scikit-learnandmnists, in addition to the engine. - Illustrates. MNIST and other image datasets.
Hamiltonian Graph tutorial
- What it does. The notebook shows learning from formal knowledge alone. It gives the engine a description of a graph and of what a Hamiltonian cycle is, written as an algebraic embedding, and the engine finds such a cycle. The embedding has constants for vertices and for edges, a constant \(P\) for the path under consideration, constants that record whether each edge is or is not on that path, and a constant, named
WRONGPATHin the notebook, that stores paths found earlier that could not be extended to a full cycle. The notebook states that the embedding is more complex than the part it shows. - Graphs. Generalized Petersen graphs \(G(n, k)\), Sheehan graphs \(H(n)\), which have exactly one Hamiltonian cycle, and randomly connected cycle graphs. The notebook chooses graphs that have few Hamiltonian cycles.
- Training. The training loop differs from the one used for data: the path found so far is used to decide what is presented in later iterations. The notebook then plots the atoms of the model over the graph.
- Illustrates. Hamiltonian cycles and Sudoku and Encoding a task. The embedding for Hamiltonian cycles has been published,2 and an embedding for the Hamiltonian path problem is studied in Semantic embeddings in semilattices, section “Hamiltonian Path”.
How the notebooks’ wording differs from this wiki
The notebooks use some words differently from the papers. This wiki follows the papers.
| In the notebooks | In the papers and on this wiki |
|---|---|
| “product”, or “join in the semilattice language” | idempotent summation, the operation \(\odot\) |
| \(v < I\) for the order between regular elements, in places | \(v \leq I\); \(<\) is kept for an atom below an element |
| “(embedding) constants” | constants |
| “epochs” | batches, or iterations |
| “trivial atom”: an atom that contains the black and the white constant of the same pixel | no special name |
WRONGPATH | the constant \(W\) |
| “sentences” of an embedding | duples |
The Vertical Bar and MNIST notebooks set aside a validation set and plot accuracy on it during training. This is monitoring only: the validation set plays no part in building the model or in choosing it. The published statement about validation data is that none “is needed to determine hyperparameters or to stop training before overfitting”.3
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.
- Martin-Maroto and de Polavieja (2022), Semantic embeddings in semilattices, arXiv:2205.12618.
- The three notebook files at the commit given above, and the README of the Open-AML-Engine repository at commit
3bd70d7.