Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Index Distribution | Recognizing Handwritten Digits
Recognizing Handwritten Digits

book
Index Distribution

How is the distribution of category records within the data matrix?

It's crucial to ascertain if the data entries linked to a specific category are randomly scattered across row indices or if they exhibit any form of clustering.

Oppgave

Swipe to start coding

Plot histograms for the distribution of indices for each digit (0-9) in the MNIST dataset. These histograms should be displayed on the individual subplots of the grid created.

Løsning

import numpy as np

# Create a 2x5 subplot grid, specify figure size, enable tight layout, and share the y-axis across subplots
f, ax = plt.subplots(2, 5, figsize=(12, 5), tight_layout=True, sharey=True)

# Iterate through digits 0-9 to plot their indices' distribution histograms on the subplots
for digit in range(10):
# Configure subplot title and xlabel; plot histogram for each digit's occurrence
sns.histplot(np.where(Y == digit)[0], bins=30, ax=ax[digit // 5, digit % 5], color='b').set(title=digit, xlabel='index')

Mark tasks as Completed
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 5
AVAILABLE TO ULTIMATE ONLY
We use cookies to make your experience better!
some-alt