Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Labeling in Machine Learning with Python

You're reading from  Data Labeling in Machine Learning with Python

Product type Book
Published in Jan 2024
Publisher Packt
ISBN-13 9781804610541
Pages 398 pages
Edition 1st Edition
Languages
Author (1):
Vijaya Kumar Suda Vijaya Kumar Suda
Profile icon Vijaya Kumar Suda

Table of Contents (18) Chapters

Preface Part 1: Labeling Tabular Data
Chapter 1: Exploring Data for Machine Learning Chapter 2: Labeling Data for Classification Chapter 3: Labeling Data for Regression Part 2: Labeling Image Data
Chapter 4: Exploring Image Data Chapter 5: Labeling Image Data Using Rules Chapter 6: Labeling Image Data Using Data Augmentation Part 3: Labeling Text, Audio, and Video Data
Chapter 7: Labeling Text Data Chapter 8: Exploring Video Data Chapter 9: Labeling Video Data Chapter 10: Exploring Audio Data Chapter 11: Labeling Audio Data Chapter 12: Hands-On Exploring Data Labeling Tools Index Other Books You May Enjoy

Image classification using the SVM with data augmentation on the MNIST dataset

Let us see how we can apply data augmentation for image classification using an SVM with the MNIST dataset. All the steps are similar to the previous example with the CIFAR-10 dataset, except the dataset itself:

import tensorflow as tf
from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV
from keras.datasets import mnist
from keras.preprocessing.image import ImageDataGenerator
# load MNIST dataset
(x_train, y_train), (x_test, y_test) = mnist.load_data()
# normalize pixel values between 0 and 1
x_train = x_train / 255.0
x_test = x_test / 255.0
# convert labels to one-hot encoded vectors
y_train = tf.keras.utils.to_categorical(y_train)
y_test = tf.keras.utils.to_categorical(y_test)
# create image data generator for data augmentation
datagen = ImageDataGenerator(rotation_range=20, \
    width_shift_range=0.1, height_shift_range=0.1, zoom_range=0.2)
# fit image data...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}