UPDATE 2020-12-27: Chapter 10 about anomaly detection has been added!

Thanks for your support!! The book is now in the list of Most Shared Last Week in KDnuggets.

This is the free html version of the book. The pdf e-book version can be purchased at

This book aims to provide an introduction to machine learning concepts and algorithms applied to a diverse set of behavior analysis problems. It focuses on the practical aspects of solving such problems based on data collected from sensors or stored in electronic records. The included examples demonstrate how to perform several of the tasks involved during a data analysis pipeline such as: data exploration, visualization, preprocessing, representation, model training/validation, and so on. All of this, using the R programming language and real-life datasets.

Some of the content that you will find here includes, How To:

  • Build supervised machine learning models to predict indoor locations based on WiFi signals, recognize physical activities from smartphone sensors and 3D skeleton data, detect hand gestures from accelerometer signals, and so on.
  • 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.
  • Train deep learning models such as neural networks to classify muscle activity from electromyography signals and CNNs 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!

The accompanying source code for all examples is available at https://github.com/enriquegit/behavior-code. The book itself was written in R with the bookdown package1 developed by Yihui Xie. The front cover and summary-comics were illustrated by Vance Capley.

The front cover depicts two brothers (Biås and Biranz) in what seems to be a typical weekend. They are exploring and enjoying nature as usual. What they don’t know is that their lives are about to change and there is no turning back. Suddenly, Biranz spots a strange object approaching them. As it makes its way out of the rocks, its entire figure is revealed. The brothers have never seen anything like that before. The closest similar image they have in their brains is a hand-sized carnivorous plant they saw at the botanical garden during a school visit several years ago. Without any warning, the creature releases a load of spores into the air. Today, the breeze is not on the brothers’ side and the spores quickly enclose them. After seconds of being exposed, their bodies start to paralyze. Moments later, they can barely move their pupils. The creature’s multiple stems begin to inflate and all of a sudden, multiple thorns are shot. Horrified and incapable, the brothers can only witness how the thorns approach their bodies and they can even hear how the air is being cut by the sharp thorns. At this point, they are only waiting for the worst. …they haven’t felt any impact. Has time just stopped? No—the thorns were repelled by what appears to be a bionic dolphin emitting some type of ultrasonic waves. One of the projectiles managed to dodge the sound defense and is heading directly to Biås. While flying almost one mile above sea level, an eagle aims for the elusive thorn and destroys it with surgical precision. However, the creature is being persistent with its attacks. Will the brothers escape from this crossfire battle?

About me. My name is Enrique and I am a researcher at SINTEF. Please feel free to e-mail me with any questions/comments/feedback, etc.



website: http://www.enriquegc.com

This is a live document and I will keep updating it and adding new content.

The html version of this book is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License