Using the Pi Camera and a Raspberry Pi board, expand and replicate interesting machine learning (ML) experiments.
This book provides a solid overview of ML and a myriad of underlying topics to further explore. Non-technical discussions temper complex technical explanations to make the hottest and most complex topic in the hobbyist world of computing understandable and approachable.
Machine learning, also commonly referred to as deep learning (DL), is currently being integrated into a multitude of commercial products as well as widely being used in industrial, medical, and military applications. It is hard to find any modern human activity, which has not been "touched" by artificial intelligence (AI) applications. Building on the concepts first presented in Beginning Artificial Intelligence with the Raspberry Pi, you’ll go beyond simply understanding the concepts of AI into working with real machine learning experiments and applying practical deep learning concepts to experiments with the Pi board and computer vision.
What you learn with Machine Learning with the Raspberry Pi can then be moved on to other platforms to go even further in the world of AI and ML to better your hobbyist or commercial projects.
What You'll Learn
• Acquire a working knowledge of current ML
• Use the Raspberry Pi to implement ML techniques and algorithms
• Apply AI and ML tools and techniques to your own work projects and studies
Who This Book Is For
Engineers and scientists but also experienced makers and hobbyists. Motivated high school students who desire to learn about ML can benefit from this material with determination.
Author(s): Donald J. Norris
Series: Technology in Action
Edition: 1
Publisher: Apress
Year: 2019
Language: English
Commentary: True PDF
Pages: 568
City: New York, NY
Tags: Machine Learning; Deep Learning; Reinforcement Learning; OpenCV; Python; Convolutional Neural Networks; Keras; Raspberry Pi; Q-Learning; Markov Decision Process
Table of Contents
About the Author
About the Technical Reviewer
Chapter 1: Introduction to machine learning (ML) with the Raspberry Pi (RasPi)
RasPi introduction
Writing the Raspbian Image to a micro SD card
Mandatory configurations
Optional configurations
Updating and upgrading the Raspbian distribution
Python virtual environment
Installing a Python virtual environment
Installing dependencies
ML facts
ML basics
Linear prediction and classification
Iris demonstration – Part 1
Iris demonstration – Part 2
Iris demonstration – Part 3
Chapter 2: Exploration of ML data models: Part 1
Installing OpenCV 4
Download OpenCV 4 source code
Building the OpenCV software
Seaborn data visualization library
Scatter plot
Facet grid plot
Box plot
Strip plot
Violin plot
KDE plot
Pair plots
Underlying big principle
Linear regression
LR demonstration
Logistic regression
LogR model development
LogR demonstration
Naive Bayes
Brief review of the Bayes’ theorem
Preparing data for use by the Naive Bayes model
Naive Bayes model example
Pros and cons
Gaussian Naive Bayes
Gaussian Naive Bayes (GNB) demonstration
k-nearest neighbor (k-NN) model
KNN demonstration
Decision tree classifier
Decision tree algorithm
Information gain
Split criterion
Measuring information
Properties of entropy
Information gain example
Gini index
Simple Gini index example
Gain ratio
Intrinsic information
Definition of gain ratio
Decision tree classifier demonstration with scikit-learn
Visualizing the decision tree
Optimizing a decision tree
Pros and cons for decision trees
Pros
Cons
Chapter 3: Exploration of ML data models: Part 2
Principal component analysis
PCA script discussion
PCA demonstration
When to use PCA
Linear discriminant analysis
LDA script discussion
LDA demonstration
Comparison of PCA and LDA
Support vector machines
SVM demonstration – Part 1
SVM demonstration – Part 2
Learning vector quantization
LVQ basic concepts
Euclidean distance
Best matching unit
Training codebook vectors
LVQ demonstration
Bagging and random forests
Introduction to bagging and random forest
Bootstrap aggregation (bagging)
Random forest
Performance estimation and variable importance
Bootstrap resampling demonstration
Bagging demonstration
Random forest demonstration
Chapter 4: Preparation for deep learning
DL basics
Machine learning from data patterns
Linear classifier
Loss functions
Different types of loss functions
Optimizer algorithm
Deep dive into the gradient descent algorithm
Artificial neural network
How ANNs are trained and function
Practical ANN example
Complex ANN example
Modifying weight values
Practical ANN weight modification example
Some issues with ANN learning
ANN Python demonstration – Part 1
ANN Python demonstration – Part 2
Chapter 5: Practical deep learning ANN demonstrations
Parts list
Recognizing handwritten number demonstration
Project history and preparatory details
Adjusting the input datasets
Interpreting ANN output data values
Creating an ANN that does handwritten number recognition
Initial ANN training script demonstration
ANN test script demonstration
ANN test script demonstration using the full training dataset
Recognizing your own handwritten numbers
Installing the Pi Camera
Installing the Pi Camera software
Handwritten number recognition demonstration
Handwritten number recognition using Keras
Introduction to Keras
Installing Keras
Downloading the dataset and creating a model
Chapter 6: CNN demonstrations
Parts list
Introduction to the CNN model
History and evolution of the CNN
Fashion MNIST demonstration
More complex Fashion MNIST demonstration
VGG Fashion MNIST demonstration
Jason’s Fashion MNIST demonstration
Chapter 7: Predictions using ANNs and CNNs
Pima Indian Diabetes demonstration
Background for the Pima Indian Diabetes study
Preparing the data
Using the scikit-learn library with Keras
Grid search with Keras and scikit-learn
Housing price regression predictor demonstration
Preprocessing the data
The baseline model
Improved baseline model
Another improved baseline model
Predictions using CNNs
Univariate time series CNN model
Preprocessing the dataset
Create a CNN model
Multivariate time series CNN model
Multiple input series
Preprocessing the dataset
Chapter 8: Predictions using CNNs and MLPs for medical research
Parts list
Downloading the breast cancer histology Image dataset
Preparing the project environment
Configuration script
Building the dataset
Running the build dataset script
The CNN model
Training and testing script
Running the training and testing script
Evaluating the results with a discussion of sensitivity, specificity, and AUROC curves
What is sensitivity?
What is specificity?
What are the differences between sensitivity and specificity and how are they used?
Using a MLP model for breast cancer prediction
Running the MLP script
Chapter 9: Reinforcement learning
Markov decision process
Discounted future reward
Q-learning
Q-learning example
Manual Q-learning experiments
Q-learning demonstration with a Python script
Running the script
Q-learning in a hostile environment demonstration
Running the script and evaluating the results
Q-learning in a hostile environment with a priori knowledge demonstration
Running the script and evaluating the results
Q-learning and neural networks
Index