CommencerCommencer gratuitement

Visualizing easy and difficult examples

In this exercise, you'll visualize the examples that the logistic regression model is most and least confident about by looking at the largest and smallest predicted probabilities.

The handwritten digits dataset is already loaded into the variables X and y. The show_digit function takes in an integer index and plots the corresponding image, with some extra information displayed above the image.

Cet exercice fait partie du cours

Linear Classifiers in Python

Afficher le cours

Instructions

  • Fill in the first blank with the index of the digit that the model is most confident about.
  • Fill in the second blank with the index of the digit that the model is least confident about.
  • Observe the images: do you agree that the first one is less ambiguous than the second?

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

lr = LogisticRegression()
lr.fit(X,y)

# Get predicted probabilities
proba = lr.predict_proba(X)

# Sort the example indices by their maximum probability
proba_inds = np.argsort(np.max(proba,axis=1))

# Show the most confident (least ambiguous) digit
show_digit(____, lr)

# Show the least confident (most ambiguous) digit
show_digit(____, lr)
Modifier et exécuter le code