# Surveying Human Habit Modeling and Mining Techniques in Smart Spaces
## 6 Model Construction
Patterns are mined by iteratively compressing the sensor log. The data mining method used for activity discovery is completely unsupervised without the need of manually segmenting the dataset or choosing windows and allows to discover interwoven activities as well. Starting from singleton patterns, at each step, the proposed technique compresses the logs by exploiting them and iteratively reprocesses the compressed log for recognizing new patterns and further compress the log. When it is difficult to further compress the log, each remaining pattern represents an activity class. Discovered labels are employed to train HMM, BN and SVM models following the same approach as in the supervised works of the same group. In casas-ham[15], the sensor log is considered completely unlabeled. Here temporal patterns (patterns with the addition of temporal information) are discovered similarly as in casas-discore[11; 12; 13] and are used for structuring a tree of Markov Chains. Different activations in different timestamps generate new paths in the tree. Depending to temporal constraints, a sub-tree containing Markov Chains at the leafs that model activities is generated. A technique to update the model is also proposed. Here the goal of the model is the actuation of target devices more than recognition. Authors in stik-misvm[27] introduce a weakly supervised approach where two strategies are proposed for assigning labels to unlabeled data. The first strategy is based on the miSVM algorithm. miSVM is a SVM with two levels, the first for assigning labels to unlabeled data, the second one for applying recognition to the activities logs. The second strategy is instead called graph-based label propagation, where the nodes of the graphs are vectors of features. The nodes are connected by weighted edges, the weights represent similarity between nodes. When the entire training set is labeled, an SVM is trained for activity recognition. In aug-apubs[10], the system generates ECA rules by considering the typology of the sensors involved in the measurements and the time relations between their activations. APUBS makes clear the difference between different categories of sensors:  
* **Type O** sensors installed in objects, thus, providing direct information about the actions of the users. * **Type C** sensors providing information about the environment (e.g., temperature, day of the week). * **Type M** sensors providing information about the position of the user inside the house (e.g., in the bedroom). Events in the _event_ part of the ECA rule always come from sets O and M. Conditions are usually expressed in terms of the values provided by Type C sensors. Finally, the _action_ part contains only Type O sensors. The set of Type O sensor is called _mainSeT_. The first step of the APUBS method consists of discovering, for each sensor in the _mainSeT_, the set _associatedSeT_ of potential O and M sensors that can be potentially related to it as triggering events. The method employed is APriori for association rules [36]; the only difference is that possible association rules \(X\Rightarrow Y\) are limited to those where cardinality of both \(X\) and \(Y\) is unitary and \(Y\) only contains events contained in _mainSeT_. Obviously, this step requires a window size value to be specified in order to create transactions. As a second step, the technique discovers the temporal relationships between the events in _associatedSeT_ and those in _mainSeT_. During this step, non-significant relations are pruned. As a third step, the conditions for the ECA rules are mined with a JRip classifier [48]. In wang-hier[23], starting from the raw log, the authors use a K-Medoids clustering method to discover template gestures. This method finds the \(k\) representative instances which best represent the clusters. Based on these templates, gestures are identified applying a template matching algorithm: Dynamic Time Warping is a classic dynamic programming based algorithm to match two time series with temporal dynamics.