ebook img

Neural Network Projects with Python: The ultimate guide to using Python to explore the true power of neural networks through six projects PDF

301 Pages·2019·8.139 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Neural Network Projects with Python: The ultimate guide to using Python to explore the true power of neural networks through six projects

Neural Network Projects with Python The ultimate guide to using Python to explore the true power of neural networks through six projects James Loy BIRMINGHAM - MUMBAI Neural Network Projects with Python Copyright © 2019 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 author, 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: Pravin Dhandre Acquisition Editor: Nelson Morris Content Development Editor: Pratik Andrade Technical Editor: Jovita Alva Copy Editor: Safis Editing Project Coordinator: Namrata Swetta Proofreader: Safis Editing Indexer: Rekha Nair Graphics: Jisha Chirayil Production Coordinator: Arvindkumar Gupta First published: February 2019 Production reference: 1270219 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78913-890-0 www.packtpub.com To my wife Agnes Lim - my partner, soulmate, and cheerleader. Without her, this book would not have been possible. - James Loy mapt.io Mapt is an online digital library that gives you full access to over 5,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. Why subscribe? 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 Mapt is fully searchable Copy and paste, print, and bookmark content Packt.com 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. Contributors About the author James Loy has more than five years, expert experience in data science in the finance and healthcare industries. He has worked with the largest bank in Singapore to drive innovation and improve customer loyalty through predictive analytics. He has also experience in the healthcare sector, where he applied data analytics to improve decision- making in hospitals. He has a master's degree in computer science from Georgia Tech, with a specialization in machine learning. His research interest includes deep learning and applied machine learning, as well as developing computer-vision-based AI agents for automation in industry. He writes on Towards Data Science, a popular machine learning website with more than 3 million views per month. About the reviewer Mike Thompson has worked as a software engineer in a variety of roles involving data engineering, service development, and distributed systems design over the past 8 years. Mike worked for Bungie and helped ship game titles in the Destiny franchise. His credits include Destiny in 2014 and Destiny 2 in 2017, including many expansions in between for both titles. His contributions were integral to scaling Bungie's backend data infrastructure and allowing millions of players to enjoy the Destiny games. Mike now works for ProbablyMonsters, a growing family of game studios, where he focuses on data services and infrastructure, along with many other duties that are required to get a new business off the ground. Packt is searching for authors like you 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. Table of Contents Preface 1 Chapter 1: Machine Learning and Neural Networks 101 6 What is machine learning? 7 Machine learning algorithms 8 The machine learning workflow 10 Setting up your computer for machine learning 12 Neural networks 14 Why neural networks? 15 The basic architecture of neural networks 16 Training a neural network from scratch in Python 17 Feedforward 18 The loss function 19 Backpropagation 19 Putting it all together 21 Deep learning and neural networks 22 pandas – a powerful data analysis toolkit in Python 24 pandas DataFrames 24 Data visualization in pandas 27 Data preprocessing in pandas 30 Encoding categorical variables 31 Imputing missing values 33 Using pandas in neural network projects 35 TensorFlow and Keras – open source deep learning libraries 35 The fundamental building blocks in Keras 36 Layers – the atom of neural networks in Keras 36 Models – a collection of layers 37 Loss function – error metric for neural network training 37 Optimizers – training algorithm for neural networks 38 Creating neural networks in Keras 38 Other Python libraries 41 Summary 41 Chapter 2: Predicting Diabetes with Multilayer Perceptrons 42 Technical requirements 43 Diabetes – understanding the problem 44 AI in healthcare 45 Automated diagnosis 46 The diabetes mellitus dataset 47 Exploratory data analysis 47 Data preprocessing 54 Table of Contents Handling missing values 54 Data standardization 58 Splitting the data into training, testing, and validation sets 59 MLPs 61 Model architecture 61 Input layer 62 Hidden layers 62 Activation functions 62 ReLU 63 Sigmoid activation function 64 Model building in Python using Keras 65 Model building 65 Model compilation 66 Model training 66 Results analysis 68 Testing accuracy 68 Confusion matrix 69 ROC curve 71 Further improvements 73 Summary 74 Questions 74 Chapter 3: Predicting Taxi Fares with Deep Feedforward Networks 77 Technical requirements 78 Predicting taxi fares in New York City 79 The NYC taxi fares dataset 80 Exploratory data analysis 80 Visualizing geolocation data 81 Ridership by day and hour 86 Data preprocessing 88 Handling missing values and data anomalies 88 Feature engineering 94 Temporal features 94 Geolocation features 95 Feature scaling 99 Deep feedforward networks 100 Model architecture 100 Loss functions for regression problems 101 Model building in Python using Keras 102 Results analysis 104 Putting it all together 108 Summary 111 Questions 111 Chapter 4: Cats Versus Dogs - Image Classification Using CNNs 113 [ ii ] Table of Contents Technical requirements 114 Computer vision and object recognition 115 Types of object recognition tasks 116 Digital images as neural network input 118 Building blocks of CNNs 120 Filtering and convolution 120 Max pooling 124 Basic architecture of CNNs 125 A review of modern CNNs 126 LeNet (1998) 126 AlexNet (2012) 126 VGG16 (2014) 127 Inception (2014) 127 ResNet (2015) 127 Where we stand today 128 The cats and dogs dataset 128 Managing image data for Keras 130 Image augmentation 132 Model building 134 Building a simple CNN 135 Leveraging on pre-trained models using transfer learning 140 Results analysis 143 Summary 147 Questions 148 Chapter 5: Removing Noise from Images Using Autoencoders 150 Technical requirements 150 What are autoencoders? 152 Latent representation 153 Autoencoders for data compression 155 The MNIST handwritten digits dataset 155 Building a simple autoencoder 157 Building autoencoders in Keras 158 Effect of hidden layer size on autoencoder performance 162 Denoising autoencoders 165 Deep convolutional denoising autoencoder 168 Denoising documents with autoencoders 172 Basic convolutional autoencoder 176 Deep convolutional autoencoder 179 Summary 183 Questions 184 Chapter 6: Sentiment Analysis of Movie Reviews Using LSTM 185 Technical requirements 186 [ iii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.