# Adaptive Learning Approach for Human Activity Recognition Using Data from Smartphone Sensors
## 2 Adaptive Activity Recognition
### Proposed System Architecture
#### 2.1.3 Algorithm for Classification  
The recognition of human activities in a real-life setting is an important engineering and scientific problem. Several probability-based methods have been developed to build models to study it. HMM is a highly popular modeling technique for the analysis of stochastic processes by representing probability distributions over samples of observation, connected via Markov chains (Figure 1). In this model, an observation \(X_{t}\) at time \(t\) is produced by a stochastic process in a certain state, although the state is considered as hidden. Thus, this hidden process is assumed to satisfy the Markov property, namely, state \(Z_{t}\) at time \(t\) depends only on the previous state, \(Z_{t-1}\) at time \(t-1\). Hidden Markov model parameters that are estimated with observations are used in further analysis. The Expectation-Maximization algorithm can be used to learn HMM parameters (emission probabilities B and transition probabilities), given the observation sequence and the set of the possible states in the HMM. The EM algorithm allows for iterative learning of HMM parameters. It computes the initial estimate of the parameters, and then uses these estimates to compute an improved estimate of the parameters. The EM algorithm is performed in the following steps: calculation of the logarithmic likelihood function and maximization of the conditional mean of the likelihood function. It is well known that the maximum likelihood estimate for an HMM is a consistent and asymptotically normal estimator, and it converges to a stationary point of the sample likelihood. Various human activities can be modeled accurately as Markov chains [21; 22; 23; 24; 34; 35]. Observing signals stemming from complex or unfamiliar activities can be utilized to indirectly build an HMM of the activity. There are two main ways an activity can be modeled with an HMM. The first one is to model one activity as a separate HMM. If it is denoted that one activity (for example, running) has a start, middle, and end, then this activity can be modeled with a minimum three-state HMM. The second one is to model several activities as one HMM. For example, if it is denoted that three activities (walking, running, and standing) are interconnected, and there are various possibilities to transition from one activity to another, then these activities can be modeled with one HMM. In this case, one state in HMM will represent one particular activity. Similar to the above-mentioned classification, HMM parameters can be estimated in batch or online mode as well, where the online estimation algorithm allows for real-time sequential and re-evalative parameter estimation. The model parameters are re-estimated on feed and processing with each new observation vector, without preserving previous observations data. In this paper, an RHMM parameter estimation algorithm is proposed for HAR using the likelihood maximization and maximum likelihood estimates with sequential refinement of HMM parameters in an online setting [36]. Let us consider an HMM of \(N\) states with a sequence of observations of length \(T\). Assume the HMM is stationary, i.e., its probabilistic properties do not change over time. Thus, denote the HMM state probability \(N\)-dimensional vector as \(\gamma\); the state transition probabil  
Figure 1: Hidden Markov model process; hidden states are shaded in gray. ity matrix as \(Q\); and the density function of the probability distribution of observation \(o\), generated from state \(s\), as  
\[b(\mu_{s},\sigma_{s})=\frac{1}{\sqrt{(2\pi)^{n}|\sigma_{s}|}}e^{-\frac{1}{2}(o- \mu_{s})^{T}\sigma_{s}^{-1}(o-\mu_{s})}, \tag{1}\]  
which is assumed to be normal with \(M\)-dimensional mean \(\mu_{s}\) and covariance matrix \(\sigma_{s}\) and \(1\leq s\leq N\).