Chapter 8State Inference
In Chapter 5 we saw that, in the HiTL control loop, the stage that follows data acquisition is state inference. Subsequently, we have also justified the use of artificial neural networks (ANNs) as our mood inference tool. In this chapter, we will approach the implementation and development of our neural network, as well as the user feedback mechanisms, both of which are cornerstones of state inference in our sample HappyWalk app. In this context, our objective is to implement a learning mechanism that will receive periodic feedback from the user and learn to associate emotions with sensory inputs. The frequency of these feedback requests will be dynamically adapted to the accuracy of the network.
We will first start, in Section 8.1, by explaining how to implement the neural network that will be used as an inference tool. Next, in Section 8.2, we will deal with the problem of requesting user feedback, following which we will present the solutions for processing user feedback, in Section 8.3.
8.1 Implementing a Neural Network
HappyWalk's neural network will be implemented using the Encog Machine Learning Framework [140].1 For this, we will perform the following steps:
- Reference the Encog library in our build dependencies.
- Declare and initialize a BasicNetwork object.
- Fetch input, feed it into the neural network, and collect the result.
During the first step identified above, the library must be referenced in the app/build.gradle file, similar to what ...
Get A Practical Introduction to Human-in-the-Loop Cyber-Physical Systems now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.