Binary Classification Using Linear Regression With C#

One afternoon, I was sitting in my chair at home, and I was wondering what the simplest possible technique for binary classification is. I decided that using linear regression is maybe the simplest.

The idea is that the target variable to predict in the training data is 0 or 1. If you use standard linear regression the output will be a single numeric value from negative infinity to positive infinity. If the predicted output is less than 0.5 (close to 0), the predicted class is 0. If the predicted output is greater than or equal to 0.5 (close to 1), the predicted class is 1.

I put together a demo. For my demo data I used one of my standard synthetic datasets. The raw data looks like:

F, 24, michigan, 29500.00, liberal
M, 39, oklahoma, 51200.00, moderate
F, 63, nebraska, 75800.00, conservative
M, 36, michigan, 44500.00, moderate
. . .

The fields are sex, age, State (just three), income, political leaning. The goal is to predict sex (male = 0) from age, State, income, and politics.

The normalized and encoded data is:

1, 0.24, 1,0,0, 0.2950, 0,0,1
0, 0.39, 0,0,1, 0.5120, 0,1,0
1, 0.63, 0,1,0, 0.7580, 1,0,0
0, 0.36, 1,0,0, 0.4450, 0,1,0
. . .

There are 200 training items and 40 test items. The output of my demo is:

Linear regression binary classification with coordinate
 descent training
Predict sex (male=0) from age, State, income, politics

Loading people train (200) and test (40) data
Done

First three train X:
  0.2400  1.00  0.00  0.00  0.2950  0.00  0.00  1.00
  0.3900  0.00  0.00  1.00  0.5120  0.00  1.00  0.00
  0.6300  0.00  1.00  0.00  0.7580  1.00  0.00  0.00

First three train y:
  1.0000
  0.0000
  1.0000

Creating and training model
Done

Weights/coefficients:
9.6983 0.1280 0.1162 -0.0615 -9.5697  0.4659  0.1692 -0.1195
Bias/constant: 1.1020

Confusion matrix:
 actual   0 |     16    10  | 0.6154
 actual   1 |      0    14  | 1.0000
----------
predicted:         0     1  | 0.7500

Computing precision recall
precision = 0.7907
recall =    0.9623
F1 score =  0.8681

End demo

There are many ways (at least a dozen) to train a linear regression model. I used coordinate descent training. Alternatives include stochastic gradient descent, and several types of closed-form solutions such as QR decomposition with back-substitution solve, and Gauss-Jordan elimination.

To evaluate the trained model, I computed and displayed a confusion matrix. It shows an overall accuracy of 75% (30 out of 40 correct) on the test data. But the model is much better at predicting class = 1 (female) than class = 0 (male).

I computed and displayed the model precision, recall, and F1 score. Binary classification precision and recall are useful when you have imbalanced datasets or when the impact of different types of errors (false positives vs. false negatives) is different. The F1 score is just the harmonic mean of precision and recall.

Good fun.



I know very little about art, and I know even less about Japanese art. I went to Tokyo a few month ago. Before going, I read a bit about things Japanese. Japanese bijinga is an art genre that translates to “pictures of beautiful women”. Within that genre, different artists have very different styles. Here are three examples of modern bijinga art. Left: By artist Ayana Otake. Center: By artist Ichiro Tsuruta. Right: By artist Yasunari Ikenaga.


Demo program. Replace “lt” (less than), “gt”, “lte”, “gte” with Boolean operator symbols (my blog editor chokes on symbols).

using System;
using System.IO;
using System.Collections.Generic;

namespace LinearRegressionBinaryCoordinate
{
  internal class LinearRegressionProgram
  {
    static void Main(string[] args)
    {
      Console.WriteLine("\nLinear regression" +
        " binary classification with coordinate" +
        " descent training ");

      // sex age State income politics
      // 1, 0.24, 1,0,0, 0.2950, 0,0,1
      // 0, 0.39, 0,0,1, 0.5120, 0,1,0
      // 0    1   2 3 4     5    6 7 8
      //
      // predict sex from age State income politics
      Console.WriteLine("Predict sex (male=0) from age," +
        " State, income, politics ");

      // 1. load data
      Console.WriteLine("\nLoading people train" +
        " (200) and test (40) data");
      string trainFile =
        "..\\..\\..\\Data\\people_train_200.txt";
      int[] colsX = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
      double[][] trainX =
        MatLoad(trainFile, colsX, ',', "#");
      double[] trainY =
        MatToVec(MatLoad(trainFile,
        new int[] { 0 }, ',', "#"));

      string testFile =
        "..\\..\\..\\Data\\people_test_40.txt";
      double[][] testX =
        MatLoad(testFile, colsX, ',', "#");
      double[] testY =
        MatToVec(MatLoad(testFile,
        new int[] { 0 }, ',', "#"));
      Console.WriteLine("Done ");

      Console.WriteLine("\nFirst three train X: ");
      for (int i = 0; i "lt" 3; ++i)
        VecShow(trainX[i], 4, 8);

      Console.WriteLine("\nFirst three train y: ");
      for (int i = 0; i "lt" 3; ++i)
        Console.WriteLine(trainY[i].ToString("F4").
          PadLeft(8));

      // 2. create and train model
      Console.WriteLine("\nCreating and training model");
      LinearRegressor model = new LinearRegressor();
      model.Train(trainX, trainY);
      Console.WriteLine("Done ");

      // 2b.show model parameters
      Console.WriteLine("\nWeights/coefficients: ");
      for (int i = 0; i "lt" model.weights.Length; ++i)
        Console.Write(model.weights[i].ToString("F4") + "  ");
      Console.WriteLine("\nBias/constant: " +
        model.bias.ToString("F4"));

      // 3. evaluate model
      int[][] cm = model.ConfusionMatrix(testX, testY);
      Console.WriteLine("\nConfusion matrix: ");
      model.ShowConfusion(cm);

      Console.WriteLine("\nComputing precision recall ");
      PrecisionRecall(model, trainX, trainY);

      Console.WriteLine("\nEnd demo ");
      Console.ReadLine();
    } // Main

    // ------------------------------------------------------
    // helpers for Main()
    // ------------------------------------------------------

    static double[][] MatLoad(string fn, int[] usecols,
      char sep, string comment)
    {
      List"lt"double[]"gt" result = new List"lt"double[]"gt"();
      string line = "";
      FileStream ifs = new FileStream(fn, FileMode.Open);
      StreamReader sr = new StreamReader(ifs);
      while ((line = sr.ReadLine()) != null)
      {
        if (line.StartsWith(comment) == true)
          continue;
        string[] tokens = line.Split(sep);
        List"lt"double"gt" lst = new List"lt"double"gt"();
        for (int j = 0; j "lt" usecols.Length; ++j)
          lst.Add(double.Parse(tokens[usecols[j]]));
        double[] row = lst.ToArray();
        result.Add(row);
      }
      sr.Close(); ifs.Close();
      return result.ToArray();
    }

    static double[] MatToVec(double[][] M)
    {
      int nRows = M.Length;
      int nCols = M[0].Length;
      double[] result = new double[nRows * nCols];
      int k = 0;
      for (int i = 0; i "lt" nRows; ++i)
        for (int j = 0; j "lt" nCols; ++j)
          result[k++] = M[i][j];
      return result;
    }

    static void VecShow(double[] vec, int dec, int wid)
    {
      for (int i = 0; i "lt" vec.Length; ++i)
        Console.Write(vec[i].ToString("F" + dec).
          PadLeft(wid));
      Console.WriteLine("");
    }

    // ------------------------------------------------------

    static void PrecisionRecall(dynamic model, 
      double[][] dataX, double[] dataY)
    {
      // compute and display precision, recall, F1
      // for a binary classifer
      // assumes a Predict() method for model
      // A false positive occurs when the model predicts
      // the positive class (1), but the true actual label
      // is the negative class (0) -- Wikipedia
      int TP = 0; // correctly predicted as positive (1)
      int TN = 0;
      int FP = 0;  // falsely predicted as positive (1)
      int FN = 0;  
      int n = dataX.Length;
      for (int i = 0; i "lt" n; ++i)
      {
        double[] x = dataX[i];
        double actY = (int)(dataY[i]);
        int predY = model.Predict(x);
        
        if (actY == 0 && predY == 0)
          ++TN;
        else if (actY == 1 && predY == 1)
          ++TP;
        else if (actY == 0 && predY == 1)
          ++FP;
        else if (actY == 1 && predY == 0)
          ++FN;
      }
      double precision = (TP * 1.0) / (TP + FP);
      double recall = (TP * 1.0) / (TP + FN);
      
      double F1 = 2.0 * (precision * recall) / 
        (precision + recall);
      // double F1 = (2.0 * TP) /
      //   ((2 * TP) + FP + FN);
      // double F1 = 1.0 /
      //   (((1.0 / precision) + (1.0 / recall)) / 2.0);

      Console.WriteLine("precision = " +
        precision.ToString("F4"));
      Console.WriteLine("recall =    " +
        recall.ToString("F4"));
      Console.WriteLine("F1 score =  " +
        F1.ToString("F4"));
    }

    // ------------------------------------------------------

  } // class Program

  public class LinearRegressor
  {
    public double[] weights;
    public double bias;

    public LinearRegressor()
    {
      this.weights = new double[0]; // keep compiler happy
      this.bias = 0;
    }
    // Compute coefficients through a fixed number of
    // coordinate-descent passes, updating each coefficient
    // to minimize the squared prediction error while
    // holding the other coefficients constant. After each
    // pass, the coefficients increasingly account for
    // relationships between features, typically producing
    // a more accurate model than the initial covariance
    // estimates alone. Finally, the algorithm calculates
    // the bias, yielding an efficient approximation of
    // ordinary least-squares regression without matrix
    // inversion, QR decomposition, or a learning rate.

    public void Train(double[][] trainX, double[] trainY)
    {
      //  coordinate descent
      int n = trainX.Length;
      int dim = trainX[0].Length;
      this.weights = new double[dim];

      // 1. compute predictor means and target mean
      double[] xMean = new double[dim];
      double yMean = 0.0;
      for (int i = 0; i "lt" n; ++i)
      {
        yMean += trainY[i];
        for (int j = 0; j "lt" dim; ++j)
          xMean[j] += trainX[i][j];
      }
      yMean /= n;
      for (int j = 0; j "lt" dim; ++j)
        xMean[j] /= n;

      // 3. coordinate descent
      int maxPasses = n * 50;  //10000;
      double exitTol = 1.0e-8;

      for (int pass = 0; pass "lt" maxPasses; ++pass)
      {
        double maxChange = 0.0;

        for (int j = 0; j "lt" dim; ++j)
        {
          double numerator = 0.0;
          double denominator = 0.0;

          for (int i = 0; i "lt" n; ++i)
          {
            // residual excluding feature j
            double residual = trainY[i] - yMean;

            for (int k = 0; k "lt" dim; ++k)
            {
              if (k != j)
                residual -= this.weights[k] *
                  (trainX[i][k] - xMean[k]);
            }

            double dx = trainX[i][j] - xMean[j];

            numerator += dx * residual;
            denominator += dx * dx;
          }

          double oldWeight = this.weights[j];

          if (denominator "gt" 0.0)
            this.weights[j] = numerator / denominator;
          else
            this.weights[j] = 0.0;

          double change = Math.Abs(
            this.weights[j] - oldWeight);

          if (change "gt" maxChange)
            maxChange = change;
        }

        // stop if a pass barely changes the weights
        if (maxChange "lt" exitTol)
          break;
      }

      // 4. compute bias
      this.bias = yMean;
      for (int j = 0; j "lt" dim; ++j)
        this.bias -= this.weights[j] * xMean[j];

    } // Train

    // ------------------------------------------------------

    public int Predict(double[] x)
    {
      double result = 0.0;
      for (int j = 0; j "lt" x.Length; ++j)
        result += x[j] * this.weights[j];
      result += this.bias;
      if (result "lt" 0.5)
        return 0;
      else
        return 1;
    }

    // ------------------------------------------------------

    public int[][] ConfusionMatrix(double[][] dataX,
      double[] dataY)
    {
      // assumes binary classification
      int[][] result = new int[2][];  // 2x2
      result[0] = new int[2];
      result[1] = new int[2];
      int n = dataX.Length;
      for (int i = 0; i "lt" n; ++i) // each data item
      {
        int predY = this.Predict(dataX[i]); // 0 or 1
        int actualY = (int)(dataY[i]);  // 0 or 1

        ++result[actualY][predY];

        //if (actualY == 0 && predY == 0)
        //  ++result[0][0];
        //else if (actualY == 0 && predY == 1)
        //  ++result[0][1];
        //else if (actualY == 1 && predY == 0)
        //  ++result[1][0];
        //else if (actualY == 1 && predY == 1)
        //  ++result[1][1];
      }
      return result;
    }

    public void ShowConfusion(int[][] cm)
    {
      int n = cm.Length; // number classes
      double[] accuracies = new double[n];
      for (int i = 0; i "lt" n; ++i)
      {
        int rowSum = 0;
        for (int j = 0; j "lt" n; ++j)
          rowSum += cm[i][j];
        accuracies[i] = (cm[i][i] * 1.0) / rowSum;
      }

      // assume binary classification
      int numCorrect = cm[0][0] + cm[1][1];
      int numItems =
        cm[0][0] + cm[0][1] + cm[1][0] + cm[1][1];
      double overallAcc = (numCorrect * 1.0) / numItems;

      for (int i = 0; i "lt" n; ++i)
      {
        Console.Write(" actual " +
          i.ToString().PadLeft(3) + " | ");
        for (int j = 0; j "lt" n; ++j)
          Console.Write(cm[i][j].ToString().PadLeft(6));
        Console.WriteLine("  | " +
          accuracies[i].ToString("F4"));
      }
      Console.WriteLine("----------");
      Console.Write("predicted:    ");
      for (int j = 0; j "lt" cm[0].Length; ++j)
        Console.Write(j.ToString().PadLeft(6));
      Console.Write("  | " + overallAcc.ToString("F4"));
      Console.WriteLine("");
    }

    // ------------------------------------------------------

  } // class LinearRegressor

} // ns

Training data:

# people_train.txt
# sex (0 = male, 1 = female)
# age, state (michigan, nebraska, oklahoma), income,
# politics type (conservative, moderate, liberal)
#
1, 0.24, 1, 0, 0, 0.2950, 0, 0, 1
0, 0.39, 0, 0, 1, 0.5120, 0, 1, 0
1, 0.63, 0, 1, 0, 0.7580, 1, 0, 0
0, 0.36, 1, 0, 0, 0.4450, 0, 1, 0
1, 0.27, 0, 1, 0, 0.2860, 0, 0, 1
1, 0.50, 0, 1, 0, 0.5650, 0, 1, 0
1, 0.50, 0, 0, 1, 0.5500, 0, 1, 0
0, 0.19, 0, 0, 1, 0.3270, 1, 0, 0
1, 0.22, 0, 1, 0, 0.2770, 0, 1, 0
0, 0.39, 0, 0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0.5890, 0, 1, 0
1, 0.68, 1, 0, 0, 0.7260, 0, 0, 1
1, 0.31, 0, 0, 1, 0.3600, 0, 1, 0
1, 0.61, 0, 1, 0, 0.6250, 0, 0, 1
1, 0.19, 0, 1, 0, 0.2150, 0, 0, 1
1, 0.38, 0, 0, 1, 0.4300, 0, 1, 0
0, 0.26, 1, 0, 0, 0.4230, 1, 0, 0
1, 0.61, 0, 1, 0, 0.6740, 1, 0, 0
1, 0.40, 1, 0, 0, 0.4650, 0, 1, 0
0, 0.49, 1, 0, 0, 0.6520, 0, 1, 0
1, 0.56, 1, 0, 0, 0.6750, 1, 0, 0
0, 0.48, 0, 1, 0, 0.6600, 0, 1, 0
1, 0.52, 1, 0, 0, 0.5630, 0, 0, 1
0, 0.18, 1, 0, 0, 0.2980, 1, 0, 0
0, 0.56, 0, 0, 1, 0.5930, 0, 0, 1
0, 0.52, 0, 1, 0, 0.6440, 0, 1, 0
0, 0.18, 0, 1, 0, 0.2860, 0, 1, 0
0, 0.58, 1, 0, 0, 0.6620, 0, 0, 1
0, 0.39, 0, 1, 0, 0.5510, 0, 1, 0
0, 0.46, 1, 0, 0, 0.6290, 0, 1, 0
0, 0.40, 0, 1, 0, 0.4620, 0, 1, 0
0, 0.60, 1, 0, 0, 0.7270, 0, 0, 1
1, 0.36, 0, 1, 0, 0.4070, 0, 0, 1
1, 0.44, 1, 0, 0, 0.5230, 0, 1, 0
1, 0.28, 1, 0, 0, 0.3130, 0, 0, 1
1, 0.54, 0, 0, 1, 0.6260, 1, 0, 0

Test data:

# people_test_40.txt
#
0, 0.51, 1, 0, 0, 0.6120, 0, 1, 0
0, 0.32, 0, 1, 0, 0.4610, 0, 1, 0
1, 0.55, 1, 0, 0, 0.6270, 1, 0, 0
1, 0.25, 0, 0, 1, 0.2620, 0, 0, 1
1, 0.33, 0, 0, 1, 0.3730, 0, 0, 1
0, 0.29, 0, 1, 0, 0.4620, 1, 0, 0
1, 0.65, 1, 0, 0, 0.7270, 1, 0, 0
0, 0.43, 0, 1, 0, 0.5140, 0, 1, 0
0, 0.54, 0, 1, 0, 0.6480, 0, 0, 1
1, 0.61, 0, 1, 0, 0.7270, 1, 0, 0
1, 0.52, 0, 1, 0, 0.6360, 1, 0, 0
1, 0.30, 0, 1, 0, 0.3350, 0, 0, 1
1, 0.29, 1, 0, 0, 0.3140, 0, 0, 1
0, 0.47, 0, 0, 1, 0.5940, 0, 1, 0
1, 0.39, 0, 1, 0, 0.4780, 0, 1, 0
1, 0.47, 0, 0, 1, 0.5200, 0, 1, 0
0, 0.49, 1, 0, 0, 0.5860, 0, 1, 0
0, 0.63, 0, 0, 1, 0.6740, 0, 0, 1
0, 0.30, 1, 0, 0, 0.3920, 1, 0, 0
0, 0.61, 0, 0, 1, 0.6960, 0, 0, 1
0, 0.47, 0, 0, 1, 0.5870, 0, 1, 0
1, 0.30, 0, 0, 1, 0.3450, 0, 0, 1
0, 0.51, 0, 0, 1, 0.5800, 0, 1, 0
0, 0.24, 1, 0, 0, 0.3880, 0, 1, 0
0, 0.49, 1, 0, 0, 0.6450, 0, 1, 0
1, 0.66, 0, 0, 1, 0.7450, 1, 0, 0
0, 0.65, 1, 0, 0, 0.7690, 1, 0, 0
0, 0.46, 0, 1, 0, 0.5800, 1, 0, 0
0, 0.45, 0, 0, 1, 0.5180, 0, 1, 0
0, 0.47, 1, 0, 0, 0.6360, 1, 0, 0
0, 0.29, 1, 0, 0, 0.4480, 1, 0, 0
0, 0.57, 0, 0, 1, 0.6930, 0, 0, 1
0, 0.20, 1, 0, 0, 0.2870, 0, 0, 1
0, 0.35, 1, 0, 0, 0.4340, 0, 1, 0
0, 0.61, 0, 0, 1, 0.6700, 0, 0, 1
0, 0.31, 0, 0, 1, 0.3730, 0, 1, 0
1, 0.18, 1, 0, 0, 0.2080, 0, 0, 1
1, 0.26, 0, 0, 1, 0.2920, 0, 0, 1
0, 0.28, 1, 0, 0, 0.3640, 0, 0, 1
0, 0.59, 0, 0, 1, 0.6940, 0, 0, 1
This entry was posted in Machine Learning. Bookmark the permalink.

Leave a Reply