Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

oblem 2) [Python] The MNIST dataset is divided into training and test sets. Each set comprises series of images ( 2828-pixel images of handwritten digits)

image text in transcribed

oblem 2) [Python] The MNIST dataset is divided into training and test sets. Each set comprises series of images ( 2828-pixel images of handwritten digits) and their respective labels (values om 09, representing which digit the image corresponds to). a) Use mnist function in keras.datasets to load and split the MNIST dataset into the training and testing sets. Name the sets as xtrain,ytrain, and xtest, and the image width and height. b) Write a function that takes two inputs: 1) images of ten digits and 2) their corresponding labels and plots a figure with 10 subplots for each 09 digits. Each subplot has the number of the handwritten digit in its title. c) Create a loop to call the function in (b) and plot images from the training set to create a figure that includes all the 10 digits ( 09). d) Select the 0 and 8 digits from the training and testing sets and name them: x_train_01, y_train_01 and xtest_01, y_test_01. e) In machine learning, we typically divide the training set into two training and validation sets to adjust the machine learning model parameters. In your code, randomly select 500 training images and their corresponding labels (from x_train_01 and y_train_01) as the validation set and name them x_valid_01 and y_valid_01, respectively. Name the remaining training images and their labels as x train_01 and y _train_01, respectively. Note: that there are no overlaps between the two sets. f) Print the number of images in each training, validation, and testing set. g) Use the function created in part (b) to plot 10 images from the validation set. h) Convert each image in the three training, validation and testing sets to one attribute by calculating the average of all the pixel values in the center 44 grid of the image. i) Plot the attribute values of the 500 images in the validation set that you calculated in part (h). Use different colors and shapes for 0 's and 8 's. The x-axis in your figure is the image number (1 to 500), and the y-axis is the calculated attribute. Label the axes and add legends appropriately. j) Based on your observation from the plot (i.e., validation set), guess a threshold on the attribute you think would differentiate the two classes with the highest accuracy. k) Calculate the training, validation, and testing accuracies based on the selected threshold on the corresponding sets and print them

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

sec ^ 2 ( x ) - tan ^ 2 ( x )

Answered: 1 week ago

Question

Choose an appropriate organizational pattern for your speech

Answered: 1 week ago

Question

Writing a Strong Conclusion

Answered: 1 week ago