Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help with all parts. done in python. label each step please. will give a thumbs up blem 2) [Python] The MNIST dataset is divided into

help with all parts. done in python. label each step please. will give a thumbs up
image text in transcribed
blem 2) [Python] The MNIST dataset is divided into training and test sets. Each set comprises eries of images ( 2828-pixel images of handwritten digits) and their respective labels (values n09, 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, ytest. Print the following: The number of images in each training and testing set 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 xtrain_01 and ytrain_01) as the validation set and name them \( x_{\text {_valid_01 and }}^{y_{-}} \)valid_01, respectively. Name the remaining training images and their labels as xtrain_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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

Students also viewed these Databases questions