Session Ready
Exercise

Implementing logistic regression

This is very similar to the earlier exercise where you implemented linear regression "from scratch" using scipy.optimize.minimize. However, this time we'll minimize the logistic loss and compare with scikit-learn's LogisticRegression (we've set C to a large value to disable regularization; more on this in Chapter 3!).

The log_loss() function from the previous exercise is already defined in your environment, and the sklearn breast cancer prediction dataset (first 10 features, standardized) is loaded into the variables X and y.

Instructions
100 XP
  • Input the number of training examples into range().
  • Fill in the loss function for logistic regression.
  • Compare the coefficients to sklearn's LogisticRegression.