28,14 €
Explore and implement deep learning to solve various real-world problems using modern R libraries such as TensorFlow, MXNet, H2O, and Deepnet
Key Features
Book Description
Deep learning enables efficient and accurate learning from a massive amount of data. This book will help you overcome a number of challenges using various deep learning algorithms and architectures with R programming.
This book starts with a brief overview of machine learning and deep learning and how to build your first neural network. You'll understand the architecture of various deep learning algorithms and their applicable fields, learn how to build deep learning models, optimize hyperparameters, and evaluate model performance. Various deep learning applications in image processing, natural language processing (NLP), recommendation systems, and predictive analytics will also be covered. Later chapters will show you how to tackle recognition problems such as image recognition and signal detection, programmatically summarize documents, conduct topic modeling, and forecast stock market prices. Toward the end of the book, you will learn the common applications of GANs and how to build a face generation model using them. Finally, you'll get to grips with using reinforcement learning and deep reinforcement learning to solve various real-world problems.
By the end of this deep learning book, you will be able to build and deploy your own deep learning applications using appropriate frameworks and algorithms.
What you will learn
Who this book is for
This book is for data scientists, machine learning engineers, and deep learning developers who are familiar with machine learning and are looking to enhance their knowledge of deep learning using practical examples. Anyone interested in increasing the efficiency of their machine learning applications and exploring various options in R will also find this book useful. Basic knowledge of machine learning techniques and working knowledge of the R programming language is expected.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 357
Veröffentlichungsjahr: 2020
Copyright © 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Veena PagareAcquisition Editor:Ali AbidiContent Development Editor: Joseph SunilSenior Editor: Roshan KumarTechnical Editor: Manikandan KurupCopy Editor: Safis EditingProject Coordinator: Aishwarya MohanProofreader: Safis EditingIndexer:Priyanka DhadkeProduction Designer:Aparna Bhagat
First published: April 2020
Production reference: 1230420
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78899-683-9
www.packt.com
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Michael Pawlus is a data scientist at The Ohio State University, where he is currently part of the team responsible for building the data science infrastructure for the advancement department, while also heading up the implementation of innovative projects there. Prior to this, Michael was a data scientist at the University of Southern California. In addition to this work, Michael has chaired data science education conferences, published articles on the role of data science within fundraising, and currently serves on committees where he is focused on providing a wider variety of educational offerings as well as increasing the diversity of content creators in this space. He holds degrees from Grand Valley State University and the University of Sheffield.
Rodger Devine is the Associate Dean of External Affairs for Strategy and Innovation at the USC Dornsife College of Letters, Arts, and Sciences. Rodger's portfolio includes advancement operations, BI, leadership annual giving, program innovation, prospect development, and strategic information management. Prior to USC, Rodger served as the Director of Information, Analytics, and Annual Giving at the Michigan Ross School of Business. He brings with him nearly 20 years of experience in software engineering, IT operations, BI, project management, organizational development, and leadership. Rodger completed his masters in data science at the University of Michigan and is a doctoral student in the OCL program at the USC Rossier School of Education.
Over the last 12 years, Sray Agrawal has been working as a data scientist and acquiring experience in a variety of domains. He has had experience of working in BFSI, e-commerce, retail, telecommunications, hospitality, travel, education, real estate, entertainment, and in many others sectors besides. He is currently working for Publicis Sapient as a data scientist, based in London. His expertise lies in predictive modeling, forecasting, and advanced machine learning. He possesses a deep understanding of algorithms and advanced statistics. He has a background in management and economics and has undertaken a masters-equivalent program in data science and analytics. He is also a certified predictive modeler from SAS. His current areas of interest are fair and explainable machine learning.
Oleg Okun is a machine learning expert and an author/editor of four books and numerous journal articles and conference papers. During his more than 25+ years in work, he has been employed in both academia and industry, in his mother country, Belarus, and abroad (Finland, Sweden, and Germany). His work experience includes document image analysis, fingerprint biometrics, bioinformatics, online/offline marketing analytics, and credit scoring analytics. He is interested in all aspects of distributed machine learning and the Internet of Things. He currently lives and works in Hamburg, Germany, and is about to start a new job as a chief architect of intelligent systems. His favorite programming languages are Python, R, and Scala.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Hands-On Deep Learning with R
Dedication
About Packt
Why subscribe?
Contributors
About the authors
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Section 1: Deep Learning Basics
Machine Learning Basics
An overview of machine learning
Preparing data for modeling
Handling missing values
Training a model on prepared data
Train and test data
Choosing an algorithm
Evaluating model results
Machine learning metrics
Improving model results
Reviewing different algorithms
Summary
Setting Up R for Deep Learning
Technical requirements
Installing the packages
Installing ReinforcementLearning
Installing RBM
Installing Keras
Installing H2O
Installing MXNet
Preparing a sample dataset
Exploring Keras
Available functions
A Keras example
Exploring MXNet
Available functions
Getting started with MXNet
Exploring H2O
Available functions
An H2O example
Exploring ReinforcementLearning and RBM
Reinforcement learning example
An RBM example
Comparing the deep learning libraries
Summary
Artificial Neural Networks
Technical requirements
Contrasting deep learning with machine learning
Comparing neural networks and the human brain
Utilizing bias and activation functions within hidden layers
Surveying activation functions
Exploring the sigmoid function
Investigating the hyperbolic tangent function
Plotting the rectified linear units activation function
Calculating the Leaky ReLU activation function
Defining the swish activation function
Predicting class likelihood with softmax
Creating a feedforward network
Writing a neural network with Base R
Creating a model with Wisconsin cancer data
Augmenting our neural network with backpropagation
Summary
Section 2: Deep Learning Applications
CNNs for Image Recognition
Technical requirements
Image recognition with shallow nets
Image recognition with convolutional neural networks
Optimizers
Loss functions
Evaluation metrics
Enhancing the model with additional layers
Choosing the most appropriate activation function
Selecting optimal epochs using dropout and early stopping
Summary
Multilayer Perceptron for Signal Detection
Technical requirements
Understanding multilayer perceptrons
Preparing and preprocessing data
Deciding on the hidden layers and neurons
Training and evaluating the model
Summary
Neural Collaborative Filtering Using Embeddings
Technical requirements
Introducing recommender systems
Collaborative filtering with neural networks
Exploring embeddings
Preparing, preprocessing, and exploring data
Performing exploratory data analysis
Creating user and item embeddings
Building and training a neural recommender system
Evaluating results and tuning hyperparameters
Hyperparameter tuning
Adding dropout layers 
Adjusting for user-item bias
Summary
Deep Learning for Natural Language Processing
Formatting data using tokenization
Cleaning text to remove noise
Applying word embeddings to increase usable data
Clustering data into topic groups
Summarizing documents using model results
Creating an RBM
Defining the Gibbs sampling rate
Speeding up sampling with contrastive divergence
Computing free energy for model evaluation
Stacking RBMs to create a deep belief network
Summary
Long Short-Term Memory Networks for Stock Forecasting
Technical requirements
Understanding common methods for stock market prediction
Preparing and preprocessing data
Configuring a data generator
Training and evaluating the model
Tuning hyperparameters to improve performance
Summary
Generative Adversarial Networks for Faces
Technical requirements
An overview of GANs
Defining the generator model
Defining the discriminator model
Preparing and preprocessing a dataset
Loading the libraries and data files
Resizing our images
Merging arrays
Training and evaluating the model
Defining the GAN model
Passing data to the GAN model
Training the GAN model
Generating random images
Selecting real images
Combining real and fake images
Creating target labels
Passing input to the discriminator model
Updating the row selector
Evaluating the model
Summary
Section 3: Reinforcement Learning
Reinforcement Learning for Gaming
Technical requirements
Understanding the concept of reinforcement learning
Preparing and processing data
Configuring the reinforcement agent
Tuning hyperparameters
Summary
Deep Q-Learning for Maze Solving
Technical requirements
Creating an environment for reinforcement learning
Defining an agent to perform actions
Building a deep Q-learning model 
Running the experiment
Improving performance with policy functions
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Deep learning enables efficient and accurate learning from massive amounts of data. Deep learning is being adopted by numerous industries at an increasing pace since it can help solve a number of challenges that cannot easily be solved by means of traditional machine learning techniques.
Developers working with R will be able to put their knowledge to work with this practical guide to deep learning. This book provides a hands-on approach to implementation and associated methodologies that will have you up and running and productive in no time. Complete with step-by-step explanations of essential concepts and practical examples, you will begin by exploring deep learning in general, including an overview of deep learning advantages and architecture. You will explore the architecture of various deep learning algorithms and understand their applicable fields. You will also learn how to build deep learning models, optimize hyperparameters, and evaluate model performance.
By the end of this book, you will be able to build and deploy your own deep learning models and applications using deep learning frameworks and algorithms specific to your problem.
The target audience of this book is data analysts, machine learning engineers, and data scientists who are familiar with machine learning and want to consolidate their knowledge of deep learning or make their machine learning applications more efficient using R. We assume that the reader has a programming background with at least some common machine learning techniques and previous experience or familiarity with R.
Chapter 1, Machine Learning Basics, reviews all the essential elements of machine learning. This quick refresher is important as we move into deep learning, a subset of machine learning, which shares a number of common terms and methods.
Chapter 2, Setting Up R for Deep Learning, summarizes the common frameworks and algorithms for deep learning and reinforced deep learning in R. You will become familiar with the common libraries, including MXNet, H2O, and Keras, and learn how to install each library in R.
Chapter 3, Artificial Neural Networks, teaches you about artificial neural networks, which make up the base building block for all deep learning. You will build a simple artificial neural network and learn how all of its components combine to solve complex problems.
Chapter 4, CNNs for Image Recognition, demonstrates how to use convolutional neural networks for image recognition. We will briefly cover why these deep learning networks are superior to shallow nets. The remainder of the chapter will cover the components of a convolutional neural network with considerations for making the most appropriate choice.
Chapter 5, Multilayer Perceptron Neural Networks for Signal Detection, shows how to build a multilayer perceptron neural network for signal detection. You will learn the architecture of multilayer perceptron neural networks, and also learn how to prepare data, define hidden layers and neurons, and train a model using a backpropagation algorithm in R.
Chapter 6, Neural Collaborative Filtering Using Embeddings, explains how to build a neural collaborative filtering recommender system using layered embeddings. You will learn how to use the custom Keras API, construct an architecture with user-item embedding layers, and train a practical recommender system using implicit ratings.
Chapter 7, Deep Learning for Natural Language Processing, explains how to create document summaries. The chapter begins with removing parts of documents that should not be considered and tokenizing the remaining text. Afterward, embeddings are applied and clusters are created. These clusters are then used to make document summaries. We will also learn to code a Restricted Boltzmann Machine (RBM) along with defining Gibbs Sampling, Contrastive Divergence, and Free Energy for the algorithm. The chapter will conclude with compiling multiple RBMs to create a deep belief network.
Chapter 8, Long Short-Term Memory Networks for Stock Forecasting, shows how to use long short-term memory (LSTM) RNN networks for predictive analytics. You will learn how to prepare sequence data for LSTM and how to build a predictive model with LSTM.
Chapter 9, Generative Adversarial Networks for Faces, describes the main components and applications of generative adversarial networks (GANs). You will learn the common applications of generative adversarial networks and how to build a face generation model with GANs.
Chapter 10, Reinforcement Learning for Gaming, demonstrates the reinforcement learning method on a tic-tac-toe game. You will learn the concept and implementation of reinforcement learning in a highly customizable framework. Moreover, you will also learn how to create an agent that plays the best action for each game step and how to implement reinforcement learning in R.
Chapter 11, Deep Q-Learning for Maze Solving, shows us how to use R to implement reinforcement learning techniques within a maze environment. In particular, we will create an agent to solve a maze by training an agent to perform actions and to learn from failed attempts.
We assume you are comfortable and have a working familiarity with downloading and installing software on your computer, including R and additional R library packages from CRAN or GitHub. We also assume some baseline familiarity with independently troubleshooting and resolving packaging dependencies (as needed) based on R Studio console output. You will need a version of R and R Studio installed on your computer—the latest version, if possible.
All code examples have been tested using R version 3.6.3 on macOS X 10.11 (El Capitan) and higher. This code should work with future version releases, too, although this may require some of the deep learning R software packages listed in Chapter 2, Setting Up R for Deep Learning, to be updated.
Hardware/software covered in the book
OS requirements
64-bit for Intel Mac
macOS X 10.11 (El Capitan) and higher
R version 3.6.3
macOS X 10.11 (El Capitan) and higher
R Studio Desktop 1.2.5033 (Orange Blossom 330255dd)
R version 3.0.1+
Once you have installed R (https://www.r-project.org) and R Studio Desktop (https://rstudio.com/products/rstudio/download/) on your computer, you should be ready to install the additional deep learning software packages outlined in Chapter 2, Setting Up R for Deep Learning.
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packt.com
.
Select the
Support
tab.
Click on
Code Downloads
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-on-Deep-Learning-with-R. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781788996839_ColorImages.pdf
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at Packt can understand what you think about our products and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.
This section provides a brief overview of deep learning as it relates to machine learning. In this section of the book, you will learn how to get set up to do deep learning in R and build your first neural network, which is the building block of all the deep learning to follow.
This section comprises the following chapters:
Chapter 1
,
Machine Learning Basics
Chapter 2
,
Setting Up R for Deep Learning
Chapter 3
,
Artificial Neural Networks
Welcome to Hands-On Deep Learning with R! This book will take you through all of the steps that are necessary to code deep learning models using the R statistical programming language. It begins with simple examples as the first step for those just getting started, along with a review of the foundational elements of deep learning for those with more experience. As you progress through this book, you will learn how to code increasingly complex deep learning solutions for a wide variety of tasks. However, regardless of the complexity, each chapter will carefully detail each step. This is so that all topics and concepts can be fully comprehended and the reason for every line of code is completely explained.
In this chapter, we will go through a quick overview of the machine learning process as it will form a base for the subsequent chapters of this book. We will look at processing a dataset to review techniques such as handling outliers and missing values. We will learn how to model data to brush up on the process of predicting an outcomeand evaluating the results, and we will also review the most suitable metrics for various problems.We will look at improving a model using parameter tuning, feature engineering, and ensembling, and we will learn when to use different machine learning algorithms based on the task to solve.
This chapter will cover the following topics:
An overview of machine learning
Preparing data for modeling
Training a model on prepared data
Evaluating model results
Improving model results
Reviewing different algorithms
All deep learning is machine learning, but not all machine learning is deep learning. Throughout this book, we will focus on processes and techniques that are specific to deep learning in R. However, all the core principles of machine learning are essential to understand before we can move on to explore deep learning.
Deep learning is marked as a special subset of machine learning based on the use of neural networks that mimic brain activity behavior. The learning is referred to as being deep because, during the modeling process, the data is manipulated by a number of hidden layers. In this type of modeling, specific information is gathered from each layer. For example, one layer may find the edges of images while another finds particular hues.
Notable applications for this type of machine learning include the following:
Image recognition (including facial recognition)
Signal detection
Recommendation systems
Document summarization
Topic modeling
Forecasting
Solving games
Moving an object through space, for example, self-driving cars
All of these topics will be covered throughout the course of this book. All of these topics implement deep learning and neural networks, which are primarily used for classification and regression.
