Applied Deep Learning with Keras
eBook - ePub

Applied Deep Learning with Keras

Solve complex real-life problems with the simplicity of Keras

Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme

  1. 412 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Applied Deep Learning with Keras

Solve complex real-life problems with the simplicity of Keras

Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Take your neural networks to a whole new level with the simplicity and modularity of Keras, the most commonly used high-level neural networks API.

Key Features

  • Solve complex machine learning problems with precision
  • Evaluate, tweak, and improve your deep learning models and solutions
  • Use different types of neural networks to solve real-world problems

Book Description

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.

What you will learn

  • 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

Who this book is for

If you have basic knowledge of data science and machine learning and want to develop your skills and learn about artificial neural networks and deep learning, you will find this book useful. Prior experience of Python programming and experience with statistics and logistic regression will help you get the most out of this book. Although not necessary, some familiarity with the scikit-learn library will be an added bonus.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Applied Deep Learning with Keras est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Applied Deep Learning with Keras par Ritesh Bhagwat, Mahla Abdolahnejad, Matthew Moocarme en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in Python. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2019
ISBN
9781838554545

Chapter 1

Introduction to Machine Learning with Keras

Learning Objectives

By the end of this chapter, you will be able to:
  • Present data for use in machine learning models
  • Explain how to preprocess data for a machine learning model
  • Build a logistic regression model with scikit-learn
  • Use regularization in machine learning models
  • Evaluate model performance with model evaluation metrics
In this chapter, we will learn how to preprocess data for machine learning models. We will learn how to develop logistic regression models with scikit-learn. Lastly, we will evaluate model performance with model evaluation metrics.

Introduction

Machine learning is the science of utilizing machines to emulate human tasks and to have the machine improve their performance of that task over time. By feeding machines data in the form of observations of real-world events, they can develop patterns and relationships that will optimize an objective function, such as the accuracy of a binary classification task or the error in a regression task. In general, the usefulness of machine learning is in the ability to learn highly complex and non-linear relationships in large datasets and to replicate the results of that learning many times.
Take, for example, the classification of a dataset of pictures of either dogs or cats into classes of their respective type. For a human, this is trivial, and the accuracy would likely be very high. However, it may take around a second to categorize each picture, and scaling the task can only be achieved by increasing the number of humans, which may be infeasible. While it may be difficult, though certainly not impossible, for machines to reach the same level of accuracy as humans for this task, machines can classify many images per second, and scaling can be easily done by increasing the processing power of single machine, or making the algorithm more efficient.
Figure 1.1: A trivial classification task for humans, but quite difficult for machines
Figure 1.1: A trivial classification task for humans, but quite difficult for machines
While the trivial task of classifying dogs and cats may be simple for us humans, the same principles that are used to create a machine learning model classify dogs and cats can be applied to other classification tasks that humans may struggle with. An example of this is identifying tumors in Magnetic Resonance Images (MRIs). For humans, this task requires a medical professional with years of experience, whereas a machine may only need a dataset of labeled images.
Figure 1.2: A non-trivial classification task for humans. Are you able to spot the tumors?
Figure 1.2: A non-trivial classification task for humans. Are you able to spot the tumors?

Data Representation

We build models so that we can learn something about the data we are training on and about the relationships between the features of the dataset. This learning can inform us when we encounter new observations. However, we must realize that the observations we interact with in the real world and the format of data needed to train machine learning models are very different. Working with text data is a prime example of this. When we read text, we are able to understand each word and apply context given each word in relation to the surrounding words -- not a trivial task.However, machines are unable to interpret this contextual information. Unless it specifically encoded, they have no idea how to convert text into something that can be an input numerical. Therefore, we must represent the data appropriately, often by converting non-numerical data types, for example, converting text, dates, and categorical variables into numerical ones.

Tables of Data

Much of the data fed into machine learning problems is two-dimensional, and can be represented as rows or columns. Images are a good example of a dataset that may be three-or even four-dimensional. The shape of each image will be two-dimensional (a height and a width), the number of images together will add a third dimension, and a color channel (red, green, blue) will add a fourth.
Figure 1.3: A color image and its representation as red, green, and blue images
Figure 1.3: A color image and its representation as red, green, and blue images

Note

We have used datasets from this repository: Dua, D. and Graff, C. (2019). UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science.
The following figure shows a few rows from a marketing dataset taken from the UCI repository. The dataset presents marketing campaign results of a Portuguese banking institution. The columns of the table show various details about each customer, while the final column, y, shows whether or not the customer subscribed to the product that was featured in the marketing campaign.
One objective of analyzing the dataset could be to try and use the information given to predict whether a given customer subscribed to the product (that is, to try and predict what is in column y for each row). We can then check whether we were correct by comparing our predictions to column y. The longer-term benefit of this is that we could then use our model to predict whether new customers will subscribe to the product, or whether existing customers will subscribe to another product after a different campaign.
Figure 1.4: An image showing the first 20 instances of the marketing dataset
Figure 1.4: An image showing the first 20 instances of the marketing dataset

Loading Data

Data can be in different forms and can be available in many places. Datasets for beginners are often given in a flat format, which means that they are two-dimensional, with rows and columns. Other common forms of data may include images, JSON objects, and text documents. Each type of data format has to be loaded in specific ways. For example, numerical data can be loaded into memory using the NumPy library, which is an efficient library for working with matrices in Python. However, we would not be able to load our marketing data .csv into memory using the NumPy library because the dataset contains string values. For our dataset, we will use the pandas library becauseof its ability to easily work with various data types, such as strings, integers, floats, and binary values. In fact, pandas is dependent on NumPy for operations on numerical data types. pandas is also able to read JSON, Excel documents, and databases using SQL queries, which makes the library common amongst practitioners for loading and manipulating data in Python.
Here is an example of how to load a CSV file using the NumPy library. We use the skiprows argument in case is there is a header, which usually contains column names:
import numpy as np
data = np.loadtxt(filename, delimiter=",", skiprows=1)
Here's an example of loading data using the pandas library:
import pandas as pd
data = pd.read_csv(filename, delimiter=",")
Here we are loading in a CSV file. The default delimiter is a comma, and so passing this as an argument is not necessary, but is useful to see. The pandas library can also handle non-numeric datatypes, which makes the library more flexible:
import pandas as pd
data = pd.read_json(filename)
The pandas library will flatten out the JSON and return a DataFrame.
The library can even connect to a database, and queries can be fed directly into the function, and the table returned will be loaded as a pandas DataFrame:
import pandas as pd
data = pd.read_sql(con, "SELECT * FROM table")
We have to pass a database connection to the function in order for this to work. There are a myriad of ways for this to be achieved, depending on the database flavor.
Other forms of data that are common in deep learning, such as images and text, can also be loaded in and will be discussed later in the book.

Note

You can find all the documentation for pandas at the following link: https://pandas.pydata.org/pandas-docs/stable/. The documentation for NumPy can be found at the following link: https://docs.sci...

Table des matiĂšres

  1. Preface
  2. Chapter 1
  3. Introduction to Machine Learning with Keras
  4. Chapter 2
  5. Machine Learning versus Deep Learning
  6. Chapter 3
  7. Deep Learning with Keras
  8. Chapter 4
  9. Evaluate Your Model with Cross-Validation using Keras Wrappers
  10. Chapter 5
  11. Improving Model Accuracy
  12. Chapter 6
  13. Model Evaluation
  14. Chapter 7
  15. Computer Vision with Convolutional Neural Networks
  16. Chapter 8
  17. Transfer Learning and Pre-Trained Models
  18. Chapter 9
  19. Sequential Modeling with Recurrent Neural Networks
  20. Appendix
Normes de citation pour Applied Deep Learning with Keras

APA 6 Citation

Bhagwat, R., Abdolahnejad, M., & Moocarme, M. (2019). Applied Deep Learning with Keras (1st ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/960448/applied-deep-learning-with-keras-solve-complex-reallife-problems-with-the-simplicity-of-keras-pdf (Original work published 2019)

Chicago Citation

Bhagwat, Ritesh, Mahla Abdolahnejad, and Matthew Moocarme. (2019) 2019. Applied Deep Learning with Keras. 1st ed. Packt Publishing. https://www.perlego.com/book/960448/applied-deep-learning-with-keras-solve-complex-reallife-problems-with-the-simplicity-of-keras-pdf.

Harvard Citation

Bhagwat, R., Abdolahnejad, M. and Moocarme, M. (2019) Applied Deep Learning with Keras. 1st edn. Packt Publishing. Available at: https://www.perlego.com/book/960448/applied-deep-learning-with-keras-solve-complex-reallife-problems-with-the-simplicity-of-keras-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Bhagwat, Ritesh, Mahla Abdolahnejad, and Matthew Moocarme. Applied Deep Learning with Keras. 1st ed. Packt Publishing, 2019. Web. 14 Oct. 2022.