## 6 Adaptation
### Adaptation Algorithm  
Using likelihood distributions we can derive a new optimization criteria: the _yes_ answer likelihoods should be chi-square distributed with \(q\) degrees of freedom _after_ the adaptation (this was the definition of numerator in Equation (8)). In addition, to reduce the amount of incorrect classification results, the _no_ answer likelihoods should be far away (towards \(+\infty\)) from this distribution.  
In this paper we use the following optimization criterion: modify the distribution parameters so that the function  
\[f=\frac{|A|}{N(yes)}+\frac{|B|}{N(no)} \tag{10}\]  
is minimized. It should be noted that it is possible to use other suitable adaptation functions, for example, the one proposed in [3]. Function in the paper was chosen somewhat heuristically. In our function symbols \(N(yes)\) and \(N(no)\) denote the total numbers of _yes_ and _no_ answers and \(|A|\) and \(|B|\) denote the number of items in the set \(A\) and \(B\), respectively. The sets are defined as  
\[A=\{L_{i}(yes)|L_{i}(yes)>\chi_{95}\} \tag{11}\]  
and  
\[B=\{L_{i}(no)|L_{i}(no)<\chi_{95}\} \tag{12}\]  
Here \(i\) is the index of the current class and \(L_{i}(yes)\) and \(L_{i}(no)\) are the set of likelihood values corresponding to observations with a _yes_-label and a _no_-label, respectively, and \(\chi_{95}\) is the point where the cumulative Chi-square distribution and has a value of 0.95. The likelihood values are  
\[L_{i}=(\mathbf{z}-\boldsymbol{\mu}_{i})^{T}s_{i}\Sigma_{i}^{-1}(\mathbf{z}- \boldsymbol{\mu}_{i}) \tag{13}\]  
The parameters to be adapted are the scales \(s_{i}\) and the class means \(\boldsymbol{\mu}_{i}\). After the adaptation, the new covariance will be \(s_{i}\Sigma_{i}\).  
The motivation for the function Equation (10) is that it resembles the Neyman-Pearson type _false positive_, _false negative_ terminology [21; 22]. Minimization of the function \(f\) can be thought of as minimizing the false positive and false negative errors. However, the actual classification method is not taken into account here.  
In essence, the adaptation algorithm attempts to minimize the number of samples with a _yes_-label that do not fit the model distribution (in Equation (6)), meaning that they fall outside the 95% threshold. Furthermore, the algorithm attempts to minimize the number of samples with _no_-label that fit the model distribution well, meaning that they fall inside the 95% threshold. To minimize the function \(f\) in Equation (10), _i.e._, to find  
\[\underset{s_{i}\in\mathbb{R}^{+},\boldsymbol{\mu}\in\mathbb{R}^{N}}{\text{ argmin}}\ f \tag{14}\]  
We used the Matlab function _fminsearch_, which finds the minimum of the function using the simplex search method [23]. Functions \(f\) are implemented separately for activity and environment. The parameters to be adapted are the scale \(s\), so that the new covariance will be \(s\Sigma\), and the class means \(\boldsymbol{\mu}\). For _fminsearch_ the scale is represented as \(d=s-1\), so that the adaptation starts from the zero-vector. The result of _fminsearch_ then tells how the parameters need to be adapted. If the adaptation is successful, weshould obtain better classification results in the future. Furthermore, the likelihood distribution should approximately follow the model we have imposed - regardless of the original assumption of a Gaussian distribution.  
The information contained in the sample distribution (obtained using the Matlab function _ksdensity_, for example) of yes-likelihoods and no-likelihoods is very useful for classifier diagnostics. For example, if the real feature distribution is actually multimodal, the yes-likelihood distribution should not look like a Chi-squared distribution.