Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Automated Machine Learning with AutoKeras

You're reading from  Automated Machine Learning with AutoKeras

Product type Book
Published in May 2021
Publisher Packt
ISBN-13 9781800567641
Pages 194 pages
Edition 1st Edition
Languages
Author (1):
Luis Sobrecueva Luis Sobrecueva
Profile icon Luis Sobrecueva

Table of Contents (15) Chapters

Preface Section 1: AutoML Fundamentals
Chapter 1: Introduction to Automated Machine Learning Chapter 2: Getting Started with AutoKeras Chapter 3: Automating the Machine Learning Pipeline with AutoKeras Section 2: AutoKeras in Practice
Chapter 4: Image Classification and Regression Using AutoKeras Chapter 5: Text Classification and Regression Using AutoKeras Chapter 6: Working with Structured Data Using AutoKeras Chapter 7: Sentiment Analysis Using AutoKeras Chapter 8: Topic Classification Using AutoKeras Section 3: Advanced AutoKeras
Chapter 9: Working with Multimodal and Multitasking Data Chapter 10: Exporting and Visualizing the Models Other Books You May Enjoy

Creating the sentiment predictor

Now, we will use the AutoKeras TextClassifier to find the best classification model. Just for this example, we will set max_trials (the maximum number of different Keras models to try) to 2; we do not need to set the epochs parameter; instead, we must define an EarlyStopping callback of 2 epochs so that the training process stops if the validation loss does not improve in two consecutive epochs:

clf = ak.TextClassifier(max_trials=2)
cbs = [tf.keras.callbacks.EarlyStopping(patience=2)]

Let's run the training process and search for the optimal classifier for the training dataset:

clf.fit(x_train, y_train, callbacks=cbs)

Here is the output:

Figure 7.3 – Notebook output of text classifier training

Figure 7.3 – Notebook output of text classifier training

The previous output shows that the accuracy of the training dataset is increasing.

As we can see, we are getting a loss of 0.28 in the validation set. This isn't bad just for a few minutes of training...

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}