I wrote an article titled “Naive Bayes Regression Using C#” in the February 2025 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/Articles/2025/02/20/Naive-Bayes-Regression-Using-C.aspx.
Suppose you have a regression problem with two or more predictor variables. For example, you might want to predict a person’s income (y) from their age (x0), height (x1), and years of work experience (x2). In naive Bayes regression, you’d predict income from age, and predict income from height, and predict income from years of work experience. To generate the final predicted income, you’d compute the average of the three predicted income values.
The naive Bayes regression technique is called naive because each predictor variable is treated independently of the others, as opposed to taking into account interactions between predictors. The technique is called Bayes, meaning probabilistic, which isn’t entirely accurate because the technique does not directly rely on Bayesian principles.
Compared to other regression techniques, naive Bayes regression is simple, easy to implement, and results are easy to interpret. But in most problem scenarios, naive Bayes regression is less accurate than other techniques, and is therefore best used as a baseline for comparison with other techniques. However, in some problem scenarios, naive Bayes regression is surprisingly effective.
The article presents a complete demo of naive Bayes regression using the C# language. The demo program begins by loading a subset of the well-known Wine Dataset into memory. The data looks like:
7.4;0.7;0;1.9;0.076;11;34;0.9978;3.51;0.56;9.4;5 7.8;0.88;0;2.6;0.098;25;67;0.9968;3.2;0.68;9.8;5 7.8;0.76;0.04;2.3;0.092;15;54;0.997;3.26;0.65;9.8;5 11.2;0.28;0.56;1.9;0.075;17;60;0.998;3.16;0.58;9.8;6 . . .
There are 200 training items and 40 test items. Each line represents a glass of red wine. There are 12 semicolon-separated values on each line. The goal of the demo program is to predict the value in the first column from the values in the remaining 11 columns.
The demo train a naive Bayes regression model and then uses the model to predict the target y value for the first training item x = [0.7000, 0.0000, 1.9000, 0.0760, 11.0000, 34.0000, 0.9978, 3.5100, 0.5600, 9.4000, 5.0000]. The predictions for each of the 11 predictor variables, and the final overall prediction, are displayed as:
predictor[ 0] : pred y = 7.4869 predictor[ 1] : pred y = 7.0785 predictor[ 2] : pred y = 7.5916 predictor[ 3] : pred y = 7.5403 predictor[ 4] : pred y = 7.5417 predictor[ 5] : pred y = 7.5447 predictor[ 6] : pred y = 8.2576 predictor[ 7] : pred y = 6.8554 predictor[ 8] : pred y = 7.4776 predictor[ 9] : pred y = 7.7879 predictor[10] : pred y = 7.5722 Predicted y = 7.5213
The predicted y value of 7.5213 is reasonably close to the true y value of 7.4 in the training data.
Because naive Bayes regression doesn’t take into account interactions between predictor variables, the technique can only handle relatively simple data. One possible example of when naive Bayes regression can work well is when two of the predictor variables are mathematically correlated in such a way that they cancel each other out.

When I was a teenager, I loved the Mars novels by Edgar Rice Burroughs. Burroughs is better known for the Tarzan series, but I much preferred his Mars series. The stories are naively simple but enjoyable.
One of the last Mars novels published was “Llana of Gathol” (1948). I only learned years later that “Llana of Gathol” was a compilation of four stories that were originally published in “Amazing Stories” magazine in March, June, August, October of 1941: “The City of Mummies”, “Black Pirates of Barsoom”, “Yellow Men of Mars”, and “Invisible Men of Mars”.
The cover art for all four issues is by J. Allen St. John.


.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2026 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2026 G2E Conference
2026 iSC West Conference
You must be logged in to post a comment.