Empirical evidence · 07 / 09

Handwritten digits

A classic ten-class image task where all models perform well. The logic replicant reaches 98.21% and cuts the MLP's error by 29%.

A classic image task. The logic replicant scores 98.2% and makes about 29% fewer mistakes than the best rival.

For dummiesPlain-language view: everyday words, no equations. The full version is one click away.

What happened

Recognising handwritten digits is a classic task that modern methods handle well, so this is a sanity check. Digits written by different people vary a lot, and some are ambiguous even for a person. The small neural network reached 97.5%. The logic replicant reached 98.2%, about 29% fewer mistakes, using an eight-dimensional map that gives each digit at most two islands.

The digits, drawn

Digits on the learned map: ten coloured clusters, digit 1 forming two. Ten irregular territories on the map, with a few small isolated islands.
Figure 9. Left: the digits on a two-dimensional map, one colour per digit. Most digits form one island; the digit 1 forms two, because people write it in two different ways. Right: the territories, with irregular borders where digits are easy to confuse.

Numbers

ModelAccur. (train)Accur. (test)Precis. (test)Recall (test)Configuration
Replicant99.99%98.21%98.21%98.21%\(S=4, R=4, D=8, |V|=20\)
RF100.00%89.22%93.38%89.47%100 estim., all features
MLP100.00%97.49%97.49%97.55%50 neurons, 1 hidden layer
SOM93.83%93.23%92.28%93.36%10 000 neurons (100×100)
XGBoost99.64%93.70%93.71%93.89%100 estim., max depth 11

Analysis

As an image multiclass problem, high accuracies are unsurprising. The RF has the lowest test accuracy, 89.22%, despite 100% in training, the largest drop of the group. The SOM, with 10 000 neurons, reaches 93.23% with the smallest drop, 0.60 points, its best result across all datasets. XGBoost sits in the middle at 93.70%. The two best are the MLP, 97.49%, and the logic replicant, 98.21%. The replicant exploits its internal logic representation in an 8-dimensional \(Q\) that splits the instances into no more than two groups per class. Both accuracies are high, but the replicant reduces the error relative to the MLP by 28.69%.

The logic, made visible

Handwritten digit instances in a 2-D Q-space: ten coloured clusters, digit 1 forming two groups. Vortex regions of the digits replicant: ten irregular territories across the plane, with some isolated small regions.
Figure 9. Handwritten digits projected to a two-dimensional \(Q\) by a replicant restricted to \(S=10, R=10, D=2, |V|=50\). (a) Instances. (b) Vortices.

The leietanic function discriminates the majority of instances into well-delimited groups, despite clear irregularities in their shape and size. Digit 1 forms a pair of groups while the rest have one; a few outliers of digits 4 and 9 appear as isolated instances. The vortices in (b) delimit the space each class takes: a large logic distributed over the whole plane, with a clear irregularity in the borders between classes. Digit 1 requires two main groups, and some of its vortices are completely isolated from the others, meaning there are general exceptions in the found logic, sub-logics nested in the main one.