Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Machine learning question, use jupyter lab, no AI plz: Import this: import sys from packaging import version import sklearn import matplotlib.pyplot as plt import numpy
Machine learning question, use jupyter lab, no AI plz:
Import this:
import sys
from packaging import version
import sklearn
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from sklearn.preprocessing import adddummyfeature
from sklearn.datasets import makeblobs
from sklearn import metrics #Import scikitlearn metrics module for accuracy calculation
from sklearn.modelselection import traintestsplit
from sklearn.metrics import confusionmatrix, ConfusionMatrixDisplay
printSklearn package",sysversioninfo
printSklearn package",sklearn.version
printTensorFlow version:", tfversion
assert sysversioninfo
assert version.parsesklearnversion version.parse
pltrcfont size
pltrcaxes labelsize titlesize
pltrclegend fontsize
pltrcxtick labelsize
pltrcytick labelsize
Questions:
Load and prepare the MNIST dataset. The pixel values of the images range from through Scale these values to a range of to by dividing the values by
This also converts the sample data from integers to floatingpoint numbers:
tfrandom.setseed
mnist tfkeras.datasets.mnist
xtrain, ytrainxtest, ytest mnist.loaddata
printxtrain.shape,ytrain.shape,xtest.shape,ytest.shape
xtrain, xtest xtrain xtest
Q
Using the keras Sequential Model:
Construct a neural network classification model that has two layers, input layer, and an output later.
The first hidden layer has neurons and the second hidden layer has neuron.
The output layer has output units since we have classes.
Both the hidden layers use the 'relu' activation function.
Using a learning rate of epochs batchsize and 'adam' as the optimization algorithm
Print the accuracy of the model on the testing dataset, xtest
Accuracy will be around
#Write your code here..
#Do NOT CHANGE THIS CODE
#Testing some images
predictions modelxtest:numpy
ypred npargmaxpredictionsaxis
printPredicted Class Labels for some testing records"
printypred
printTrue Class Labels for some testing records"
printytest:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started