Search⌘ K
AI Features

Exercise: Obtaining Probabilities from Logistic Regression Model

Explore how logistic regression generates predicted probabilities and how to obtain them with scikit-learn's predict_proba method. Learn to interpret these probabilities, adjust classification thresholds, and visualize results with histograms and stacked plots to better evaluate model performance beyond binary predictions.

Discovering predicted probabilities

How does logistic regression make predictions? Now that we’re familiar with accuracy, true and false positives and negatives, and the confusion matrix, we can explore new ways of using logistic regression to learn about more advanced binary classification metrics. So far, we’ve only considered logistic regression as a “black box” that can learn from labeled training data and then make binary predictions on new features. While we will learn about the workings of logistic regression in detail later in the course, we can begin to peek inside the black box now.

One thing to understand about how logistic regression works is that the raw predictions—in other words, the direct outputs from the mathematical equation that defines logistic regression—are not binary labels. They are actually probabilities on a scale from 0 to 1 (although, technically, the equation never allows the ...