Book Image

Applied Deep Learning with Keras

By : Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme
Book Image

Applied Deep Learning with Keras

By: Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme

Overview of this book

Though designing neural networks is a sought-after skill, it is not easy to master. With Keras, you can apply complex machine learning algorithms with minimum code. Applied Deep Learning with Keras starts by taking you through the basics of machine learning and Python all the way to gaining an in-depth understanding of applying Keras to develop efficient deep learning solutions. To help you grasp the difference between machine and deep learning, the book guides you on how to build a logistic regression model, first with scikit-learn and then with Keras. You will delve into Keras and its many models by creating prediction models for various real-world scenarios, such as disease prediction and customer churning. You’ll gain knowledge on how to evaluate, optimize, and improve your models to achieve maximum information. Next, you’ll learn to evaluate your model by cross-validating it using Keras Wrapper and scikit-learn. Following this, you’ll proceed to understand how to apply L1, L2, and dropout regularization techniques to improve the accuracy of your model. To help maintain accuracy, you’ll get to grips with applying techniques including null accuracy, precision, and AUC-ROC score techniques for fine tuning your model. By the end of this book, you will have the skills you need to use Keras when building high-level deep neural networks.
Table of Contents (12 chapters)
Applied Deep Learning with Keras
Preface
Preface

Preface

Note

About

This section briefly introduces the author, the coverage of this book, the technical skills you'll need to get started, and the hardware and software requirements required to complete all of the included activities and exercises.

About the Book

Applied Deep Learning with Keras takes you from a basic level of knowledge of machine learning and Python to an expert understanding of applying Keras to develop efficient deep learning solutions. To understand the difference between machine and deep learning, you will build a logistic regression model with scikit-learn and then with Keras. By building prediction models for several real-world scenarios, such as disease prediction and customer churn prediction, you will dive deep into Keras and its many models. You will also gain knowledge about how to evaluate, optimize, and improve your models to gain maximum information. You will learn how to use Keras wrappers with scikit-learn and implement cross-validation techniques on your findings, and apply L1, L2, and dropout regularization techniques to improve the accuracy of your model. To improve accuracy, you will learn how to apply the null accuracy, precision, sensitivity, specificity, and AUC-ROC score techniques to fine-tune your model. Then, you will explore convolutional and recurrent neural networks in detail.

By the end of this book, you will have all the skills you need to use Keras to your advantage and build superlative deep neural networks.

About the Authors

Ritesh Bhagwat has a master's degree in applied mathematics with a specialization in computer science. He has over 14 years of experience in data-driven technologies and has led and been a part of complex projects ranging from data warehousing and business intelligence to machine learning and artificial intelligence. He has worked with top-tier global consulting firms as well as large multinational financial institutions. Currently, he works as a data scientist. Besides work, he enjoys playing and watching cricket and loves to travel. He is also deeply interested in Bayesian statistics.

Mahla Abdolahnejad is a Ph.D. candidate in systems and computer engineering with Carleton University, Canada. She also holds a bachelor's degree and a master's degree in biomedical engineering, which first exposed her to the field of artificial intelligence and artificial neural networks, in particular. Her Ph.D. research is focused on deep unsupervised learning for computer vision applications. She is particularly interested in exploring the differences between a human's way of learning from the visual world and a machine's way of learning from the visual world, and how to push machine learning algorithms toward learning and thinking like humans.

Matthew Moocarme is a director and senior data scientist in Viacom’s Advertising Science team. As a data scientist at Viacom, he designs data-driven solutions to help Viacom gain insights, streamline workflows, and solve complex problems using data science and machine learning.

Matthew lives in New York City and outside of work enjoys combining deep learning with music theory. He is a classically-trained physicist, holding a Ph.D. in Physics from The Graduate Center of CUNY and is an active Artificial Intelligence developer, researcher, practitioner, and educator.

Learning Objectives

In this book, you will be able to:

  • Understand the difference between single-layer and multi-layer neural network models

  • Use Keras to build simple logistic regression models, deep neural networks, recurrent neural networks, and convolutional neural networks

  • Apply L1, L2, and dropout regularization to improve the accuracy of your model

  • Implement cross-validate using Keras wrappers with scikit-learn

  • Understand the limitations of model accuracy

Audience

If you have basic knowledge about data science and machine learning and want to upgrade your skills to learn about artificial neural networks and deep learning, you can accomplish a lot with this book. Prior experience of programming in Python and familiarity with statistics and logistic regression will help you get the most out of this book. Though not necessary, it will be an added bonus if you are familiar with the scikit-learn library.

Approach

Applied Deep Learning with Keras takes a practical approach to equip beginners with the most essential data analysis tools in the shortest possible time. The book contains multiple activities that use real-life business scenarios for you to practice and apply your new skills in a highly relevant context.

Hardware Requirements

For the optimal experience, we recommend the following hardware configuration:

  • Any entry-level PC/Mac with Windows, Linux, or macOS is sufficient

  • Processor: Intel Core i5 or equivalent

  • Memory: 4 GB RAM

  • Storage: 35 GB available space

Software Requirements

You'll also need the following software installed in advance:

  • Operating system: Windows 7 SP1 64-bit, Windows 8.1 64-bit or Windows 10 64-bit, Ubuntu Linux, or the latest version of macOS

  • Browser: Google Chrome/Mozilla Firefox (latest version)

  • Notepad++/Sublime Text as IDE

  • Python 3.4+ (latest is Python 3.7) installed (from https://python.org)

  • Python libraries as needed (Jupyter, NumPy, pandas, Matplotlib, and others)

Conventions

Code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We use the skiprows argument if there is a header that usually contains column names."

A block of code is set as follows:

import numpy as np
data = np.loadtxt(filename, delimiter=",", skiprows=1)

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The printed output should look as follows, showing that DataFrame has 4521 rows and 17 columns."

Installation and Setup

Before you start this book, we'll install Python 3.6, pip, scikit-learn, and the other libraries used throughout this book. You will find the steps to install them here:

Installing Python

Install Python 3.6 by following the instructions at this link: https://realpython.com/installing-python/.

Installing the Jupyter Notebook

Install the Jupyter Notebook by following the instructions at this link: https://jupyter.org/install.

Installing pip

  1. To install pip, go to this link and download the get-pip.py file: https://pip.pypa.io/en/stable/installing/.

  2. Then, use the following command to install it:

    python get-pip.py

    You might need to use the python3 get-pip.py command, due to previous versions of Python on your computer that already use the Python command.

Installing libraries

Using the pip command, install the following libraries:

python -m pip install --user numpy scipy matplotlib jupyter pandas 

Installing scikit-learn

Install scikit-learn by using the following command:

pip install -U scikit-learn

Installing Keras

Install Keras by following the instructions in this link: https://keras.io/#installation.

Installing the Code Bundle

Copy the code bundle for the class to the C:/Code folder.

Additional Resources

The code bundle for this book is also hosted on GitHub at https://github.com/TrainingByPackt/Applied-Deep-Learning-with-Keras.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!