Building a logistic regression model
In this exercise, you will build a logistic regression model using all features in the diabetes_df
dataset. The model will be used to predict the probability of individuals in the test set having a diabetes diagnosis.
The diabetes_df
dataset has been split into X_train
, X_test
, y_train
, and y_test
, and preloaded for you.
This exercise is part of the course
Supervised Learning with scikit-learn
Exercise instructions
- Import
LogisticRegression
. - Instantiate a logistic regression model,
logreg
. - Fit the model to the training data.
- Predict the probabilities of each individual in the test set having a diabetes diagnosis, storing the array of positive probabilities as
y_pred_probs
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import LogisticRegression
____
# Instantiate the model
logreg = ____
# Fit the model
____
# Predict probabilities
y_pred_probs = logreg.____(____)[____, ____]
print(y_pred_probs[:10])