Binary Classification with Logistic Regression Using ML.NET

I’ve been poking around the ML.NET code library. ML.NET is a C# library that can do classical machine learning (but not neural systems). ML.NET is a very large library and just like most things, it can only be learned by practice.

I tackled a simple binary classification problem where the goal is to predict if a person is Male or not based on their Age, Job (mgmt, tech, sale), Income, and job Satisfaction (low, medium, high). I created a small synthetic set of training data with 40 items. I used Visual Studio to create a C# console application that calls into the ML.NET library’s L-BFGS logistic regression functionality.

Logistic regression is one of the simplest techniques for binary classification. The L-BFGS algorithm is one of several techniques that can be used to train a logistic regression model.

After training the model, I made a prediction for a person with Age = 35, Job = tech, Income = $49,000.00, Satisfaction = medium. The prediction is that isMale = True.

One thing that stands out in my mind is that using the ML.NET library has a very different feel to it than using alternatives such as raw Python, scikit-learn, or PyTorch. Anyway, good fun.

Four images by artist Bill Presing. Presing worked on several well-known animated films including “Ratatouille”, and “Up”.