Behavior Analysis with Machine Learning and R
Behavior Analysis with Machine Learning and R
A Sensors and Data Driven Approach
About the Book
This is the first version (leanpub) of the book. The most recent version is available for free in html at ttps://enriquegit.github.io/behavior-free/ and the print version can be pre-ordered here! In terms of content, all versions are very similar. The newer html and print versions include minor amendments and an additional comic illustration in the last chapter.
This book aims to provide an introduction to machine learning and deep learning concepts and algorithms applied to a diverse set of behavior analysis problems.
The book covers topics and practical aspects within the entire data analysis pipeline—from data collection, visualization, preprocessing, and encoding to model training and evaluation. No prior knowledge in machine learning is assumed. The book covers How To:
- Build supervised machine learning models to predict indoor locations based on Wi-Fi signals, recognize physical activities from smartphone sensors and 3D skeleton data, detect hand gestures from accelerometer signals, and much more.
- Apply some of the most common techniques to explore, visualize, encode, and preprocess behavioral data.
- Use unsupervised learning algorithms to discover criminal behavioral patterns.
- Program your own ensemble learning methods and use multi-view stacking to fuse signals from heterogeneous data sources.
- Encode your data using different representations, such as feature vectors, time series, images, bags of words, graphs, and so on.
- Train deep learning models with Keras and TensorFlow, including neural networks to classify muscle activity from electromyography signals and convolutional neural networks to detect smiles in images.
- Evaluate the performance of your models in traditional and multi-user settings.
- Train anomaly detection models such as Isolation Forests and autoencoders to detect abnormal fish trajectories.
- And much more!
About the Contributors
Vance Capley is responsible for the front cover and summary-comics illustrations. You can visit his website here.
Table of Contents
- Supplemental Material
- 1.1 What is Machine Learning?
- 1.2 Types of Machine Learning
- 1.3.1 Tables
- 1.3.2 Variable Types
- 1.3.3 Predictive Models
- 1.4 Data Analysis Pipeline
- 1.5 Evaluating Predictive Models
1.6 Simple Classification Example
- 1.6.1 K-fold Cross-Validation Example
- 1.7 Simple Regression Example
- 1.8 Underfitting and Overfitting
- 1.9 Bias and Variance
2. Predicting Behavior with Classification Models
2.1 k-nearest Neighbors
- 2.1.1 Indoor Location with Wi-Fi Signals
2.2 Performance Metrics
- 2.2.1 Confusion Matrix
2.3 Decision Trees
- 2.3.1 Activity Recognition with Smartphones
2.4 Naive Bayes
- 2.4.1 Activity Recognition with Naive Bayes
2.5 Dynamic Time Warping
- 2.5.1 Hand Gesture Recognition
2.6 Dummy Models
- 2.6.1 Most-frequent-class Classifier
- 2.6.2 Uniform Classifier
- 2.6.3 Frequecy-based Classifier
- 2.6.4 Other Dummy Classifiers
- 2.1 k-nearest Neighbors
3. Predicting Behavior with Ensemble Learning
- 3.1.1 Activity recognition with Bagging
- 3.2 Random Forest
- 3.3 Stacked Generalization
- 3.4 Multi-view Stacking for Home Tasks Recognition
- 3.1 Bagging
4. Exploring and Visualizing Behavioral Data
- 4.1 Talking with Field Experts
- 4.2 Summary Statistics
- 4.3 Class Distributions
- 4.4 User-Class Sparsity Matrix
- 4.5 Boxplots
4.6 Correlation Plots
- 4.6.1 Interactive Correlation Plots
- 4.7.1 Interactive Timeseries
- 4.8 Multidimensional Scaling (MDS)
- 4.9 Heatmaps
- 4.10 Automated EDA
5. Preprocessing Behavioral Data
5.1 Missing Values
- 5.1.1 Imputation
- 5.2 Smoothing
- 5.3 Normalization
5.4 Imbalanced Classes
- 5.4.1 Random Oversampling
- 5.4.2 SMOTE
- 5.5 Information Injection
- 5.6 One-hot Encoding
- 5.1 Missing Values
6. Discovering Behaviors with Unsupervised Learning
6.1 K-means Clustering
- 6.1.1 Grouping Student Responses
- 6.2 The Silhouette Index
6.3 Mining Association Rules
- 6.3.1 Finding Rules for Criminal Behavior
- 6.1 K-means Clustering
7. Encoding Behavioral Data
- 7.1 Feature Vectors
- 7.2 Timeseries
- 7.3 Transactions
- 7.4 Images
7.5 Recurrence Plots
- 7.5.1 Computing Recurence Plots
- 7.5.2 Recurrence Plots of Hand Gestures
- 7.6.1 BoW for Complex Activities
- 7.7.1 Complex Activities as Graphs
8. Predicting Behavior with Deep Learning
8.1 Introduction to Artificial Neural Networks
- 8.1.1 Sigmoid and ReLU Units
- 8.1.2 Assembling Units into Layers
- 8.1.3 Deep Neural Networks
- 8.1.4 Learning the Parameters
- 8.1.5 Parameter Learning Example in R
- 8.1.6 Stochastic Gradient Descent
8.2 Keras and TensorFlow with R
- 8.2.1 Keras Example
8.3 Classification with Neural Networks
- 8.3.1 Classification of Electromyography Signals
- 8.4.1 Early Stopping
- 8.4.2 Dropout
- 8.5 Fine-Tuning a Neural Network
8.6 Convolutional Neural Networks
- 8.6.1 Convolutions
- 8.6.2 Pooling Operations
8.7 CNNs with Keras
- 8.7.1 Example 1
- 8.7.2 Example 2
- 8.8 Smiles Detection with a CNN
- 8.1 Introduction to Artificial Neural Networks
9. Multi-User Validation
9.1 Mixed Models
- 9.1.1 Skeleton Action Recognition with Mixed Models
- 9.2 User-Independent Models
- 9.3 User-Dependent Models
9.4 User-Adaptive Models
- 9.4.1 Transfer Learning
- 9.4.2 A User-Adaptive Model for Activity Recognition
- 9.1 Mixed Models
10. Detecting Abnormal Behaviors
- 10.1 Isolation Forests
10.2 Detecting Abnormal Fish Behaviors
- 10.2.1 Explore and Visualize Trajectories
- 10.2.2 Preprocessing and Feature Extraction
- 10.2.3 Training the Model
- 10.2.4 ROC curve and AUC
- 10.3.1 Autoencoders for Anomaly Detection
- Appendix A: Setup your Environment
- Appendix B: Datasets
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them