# Surveying Human Habit Modeling and Mining Techniques in Smart Spaces
## 2 Background  
Figure 1 depicts the closed loops that characterize a running smart space [7]. The main closed loop, depicted using solid arrows and shapes, shows how the _knowledge_ of environment dynamics and of users behaviors and preferences is employed to interpret _sensors_ output in order to perform appropriate _actions_ on the environment. Sensor data is first analyzed to extract the current _context_, which is an internal abstraction of the state of the environment from the point of view of the AmI system. The extracted context is then employed to _make decisions_ on the actions to perform on the controlled space. Actions related to these decisions modify the environment (both physical and digital) by means of _actuators_ of different forms. Sensors can be roughly divided into _physical_ ones, which provide direct measurements about the environment (e.g., humidity, brightness, temperature), the devices and the users, and _cyber_ ones, which provide digital information, not directly related to physical phenomena, such as user calendars. A cyber sensor often provides information related to the presence of the user in the cyberspace (e.g., the calendar of an user, a tweet posted by him/her, etc.). The term _sensor data_ encompasses raw (or minimally processed) data retrieved from both physical sensors and cyber sensors. We can imagine a smart space producing, at runtime, a _sensor log_ containing raw measurements from available sensors. **Definition 1** (Sensor Log). : _Given a set \(S\) of sensors, a sensor log is a sequence of measurements of the kind \(\langle ts,s,v\rangle\) where ts is the timestamp of the measurement, \(s\in S\) is the source sensor and \(v\) the measured value, which can be either nominal (categorical) or numeric (quantitative)._  
Measurements can be produced by a sensor on a periodic base (e.g., temperature measurements) or whenever a particular event happens (e.g., door openings). As many of the algorithms proposed in the literature borrow the terminology of data mining, the sensor log could be conceived as a sequence of events instead of a sequence of measurements. **Definition 2** (Event Log). : _Given a set \(E=\{e_{1},\ldots,e_{n_{E}}\}\) of event types, an event sequence is a sequence of pairs \(\langle e,t\rangle\), where \(e\in E\) and \(t\) is an integer, the occurrence time of the event type \(e\)._  
Definition 2 is more restrictive than Definition 1. Translating a sensor log into an event log could cause a loss of information especially if discretization of periodic sensor measurements is required. Authors in the field of smart spaces uses, sometimes as synonyms, a variety of terms to refer to the state of the environment and the tasks humans perform in it. For the rest of the article, we will use the following terminology:  
* **Context:** The state of the environment including the human inhabitants. This includes the output of sensors and actuators, but also the state of human inhabitants including the action/activities/habits he/she is performing. In this very comprehensive meaning, the term _situation_ is sometimes used. * **Action:** Atomic interaction with the environment or a part of it (e.g., a device). Recognizing actions can be easy or difficult depending on the sensors installed. Certain methods only focuses on actions and they will not be part of our survey. In some cases methods to recognize activities and habits completely skip the action recognition phase, only relying on the raw measurements in the sensor log. * **Activity:** A sequence of actions (one in the extreme case) or sensor measurements/events with a final goal. In some cases an action can be an activity itself (e.g., ironing). Activities can be collaborative, including actions by multiple users and can interleave one each other. The granularity (i.e., the temporal extension and complexity) of considered activities cannot be precisely specified. According to the approach, tidying up a room can be an activity whereas others approaches may generically consider tidying up the entire house as an activity.