How to draw the decision boundary

·

1 min read

Case: There are two features:

  1. First, train your logistic regression model on your training data.

  2. After that, you need to find the coefficients or weights, w1 and w2, for your features x1 and x2. These coefficients or weights will be learned by your logistic regression model during the training phase.

  3. Once you have the coefficients or weights for your features, you can calculate the slope and intercept of the decision boundary using the following formula:

    0= w1*x1+w2*x2+b

    0= (w1/w2)*x1+x2+(b/w2)

    -x2=(w1/w2)*x1+(b/w2)

    x2=-(w1/w2)*x1-(b/w2)

    slope = -w1/w2

    intercept = -b/w2

    where b is the bias term of your logistic regression model.

  4. Finally, plot the decision boundary using the slope and intercept calculated above. This will divide your feature space into two regions, one for each class of your binary classification problem.