I wrote an article titled, “How to Do Naive Bayes with Numeric Data Using C#” in the November 2019 edition of Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2019/11/12/naive-bayes-csharp.aspx.

The Naive Bayes technique can be used for binary classification, for example predicting if a person is male or female based on predictors such as age, height, weight, and so on), or for multiclass classification, for example predicting if a person is politically conservative, moderate or liberal based on predictors such as annual income, sex, and so on. Naive Bayes classification can be used with numeric predictor values, such as a height of 5.75 feet, or with categorical predictor values such as a color of “red”.

In the article I explain how to create a naive Bayes classification system when the predictor values are numeric, using the C# language without any special code libraries. In particular, the goal of the demo program was to predict the gender of a person (male = 0, female = 1) based on their height, weight, and foot length. After creating a prediction model, the demo set up a new data item to classify, with predictor values of height = 5.60, weight = 150, foot = 8.

The probability that the unknown person is male was 0.62 and the probability of female was 0.38, therefore the conclusion was the unknown person is most likely male.

The naive Bayes classification technique has “naive” in its name because it assumes that each predictor value is mathematically independent. Naive Bayes classification with numeric data makes the additional assumption that all predictor variables are Gaussian distributed. This assumption is sometimes not true. For example, the ages of people in a particular profession could be significantly skewed or even bimodal. In spite of these assumptions, naive Bayes classification often works quite well.

*From an Internet search for naive characters in film. Princess Giselle in “Enchanted” (2007), Lorelei in “Gentlemen Prefer Blondes” (1953), Jade in “The Hangover” (2009), Cher in “Clueless” (1995).*