“Tsetlin Machine Binary Classification Using C#” in Visual Studio Magazine

I wrote an article titled “Tsetlin Machine Binary Classification Using C#” in the October 2025 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2025/10/15/tsetlin-machine-binary-classification-using-c.aspx.

A Tsetlin Machine system performs binary classification — predicting a variable that has exactly two possible outcomes. For example, you might want to predict the sex of an employee (male = 0, female = 1) based on salary, height, years of education, and so on.

The technique is named after a Soviet mathematician who studied some of the underlying ideas in the 1950s. And it was common i the early days of machine learning to call prediction systems “machines” (for example, support vector machines, gradient boosting machines, and so on).

The article presents a demo of Tsetlin Machine binary classification, implemented from scratch, using the C# language. In addition to binary classification, Tsetlin Machine systems can also be used for multi-class classification and for regression problems, but the article addresses only binary classification.

The output of the demo is:

Begin Tsetlin Machine binary classification demo

Loading Iris binarized-features two-class train (80)
 and test (20) from file
Done

First three train X items:
0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,

First three y target (0-1) values:
0
0
0

Setting nClauses = 20
Setting nFeatures = 16
Setting nStates = 50
Setting s (random update inverse frequency) = 3.0
Setting threshold (voting max/min clip) = 10
Creating Tsetlin Machine binary classifier
Done

Setting training maxEpochs = 100
Starting training
Epoch    0 |  Accuracy = 0.5000
Epoch   20 |  Accuracy = 0.8375
Epoch   40 |  Accuracy = 0.8750
Epoch   60 |  Accuracy = 0.9125
Epoch   80 |  Accuracy = 0.9125
Done

Accuracy (train) = 0.9125
Accuracy (test) = 0.9500

Predicting class for trainX[0]
Predicted y = 0

End Tsetlin demo

The demo program begins by loading a two-class subset of the well-known Iris Dataset into memory. The goal is to predict the species of an Iris flower based on four features: sepal length, sepal width, petal length, petal width.

There are 17 values on each line of data. The first 16 are predictor values that have been binary encoded. The last value is the target species to predict, setosa = 0, versicolor = 1. There are 80 training items and 20 test items. A simultaneous strength and weakness of Tsetlin Machine systems is that predictor values must be binary encoded.

The diagram above is a high-level illustration of some of the key ideas used by Tsetlin Machine systems. The diagram shows half of a Tsetlin Machine classifier (for class 0) with four clauses (nClauses in the demo). Each of the four clauses has five finite state automata (in general, one per predictor, nFeatures in the demo) that have integer values that are either less than nStates (set to 20 in the demo) or greater than nStates.

Each clause votes for the output to be 0 or 1. Voting sums are clipped between -10 and +10 (the threshold value in the demo). The sum of the clipped clause votes is computed and if the sum is positive, the predicted class is 1, and if the sum is negative, the predicted class is 0.

Tsetlin Machine systems are relatively new and have a small but very enthusiastic group of advocates. They argue that the Tsetlin Machine paradigm is computationally efficient, and hypothetically, advanced AI systems based on Tsetlin Machine designs could use orders of magnitude less energy than current systems based on neural network technologies.

In my opinion, one of the biggest challenges facing the widespread adoption of Tsetlin Machines is not technical — rather, it is the huge existing momentum of neural systems that are the foundations of large language models.



The Iris Dataset is one of the most famous datasets in machine learning. I worked with machine learning for quite a long time before I knew what an iris flower looks like. In science fiction, there are other flowers that aren’t famous.

Left: The flower-women on this 1949 magazine are vampires, but they are preyed upon by lizard creatures. A wizard comes along and eliminates all the lizard creatures.

Center: The cover of this magazine from September 1927 illustrates the story “The Malignant Flower”. Sir William Armstrong, an explorer in the Himalayas, runs across this species and is grabbed. His assistant, John Bannister, saves him, but Armstrong is never the same.

Right: “The Green Girl” was first published in two parts in the March and April 1930 issues of Amazing Stories, and then as a book in 1950. A cosmic event plunges the Earth into darkness. Melvin and Dr. Walden discover Xenora, the Green Girl, and they save the Earth.


This entry was posted in Machine Learning. Bookmark the permalink.

3 Responses to “Tsetlin Machine Binary Classification Using C#” in Visual Studio Magazine

  1. saurabh dasgupta's avatar saurabh dasgupta says:

    I did not know such a thing called Tsetlin existed.

    Thank you so much.

  2. saurabh dasgupta's avatar saurabh dasgupta says:

    Hello James,
    Could you recommend any introductory books/papers which explains the Tsetlin algorithm ?

  3. saurabh dasgupta's avatar saurabh dasgupta says:

    The Tsetlin algorithm looks very interesting. Are there any real world examples where this algorithm has proven itself ?

Leave a Reply