Detecting Anomaly and Its Sources in Activities of Daily Living

To support the independent living and improve the quality of life for the increasing ageing population, system for monitoring their daily routine and detecting anomalies in the routine is required. Existing anomaly detection systems are unable to identify the sources of the abnormalities, thereby hindering the development of adaptive monitoring systems with reduced false prediction rate. In this paper, an approach for identifying the sources of abnormalities in human activities of daily living is proposed. Anomalies are detected by modelling the existing activity data representing the usual behavioural routine of an individual to serve as a baseline model. Subsequent activities deviating from the baseline are then classified as outliers or anomalies. An ensemble of one-class support vector machine, isolation forest, robust covariance estimator and local outlier factor is utilised for the anomaly detection achieving an accuracy of 98%\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$98\%$$\end{document}. The proposed approach for identifying anomaly sources is based on the concept of similarity measure using distance functions. Two methods for measuring the pairwise distance of the features of the activity data termed as one vs one similarity measure and one vs all similarity measure are proposed. Experimental evaluation of the proposed approach on activities of daily living datasets has shown the credibility of the proposed approach for utilisation in an in-home monitoring system.


Introduction
In the context of ambient assisted living (AAL), to promote the independent living of older adults, it is essential to monitor their activities of daily living (ADL) such as mobility, eating, maintaining personal hygiene and continence. Detecting abnormality in these activities is of paramount importance, especially for older adults since it allows family and carers (formal or informal) to be aware of the need for intervention. Abnormality in individual activities can be termed as any significant change or deviation from the usual routine of that individual [7]. These changes can be an early indication of health decline, which may be detrimental to wellbeing. For example, studies have shown that early indicators of mild cognitive impairment (MCI) such as Dementia are identifiable through changes in behavioural routine such having a frequently interrupted sleep, having high activity level during the night and less activity during the day, forgetfulness and confusion in carrying out daily routines etc. [7].
Considering the rise in the population of older adults, increase in the cost of care and the desire of the older adults to stay in their homes for as long as possible (rather than being looked after in care homes), the most feasible approach to improve their quality of life and promote independent living is through an in-house monitoring system capable of detecting abnormalities in their daily activities [11,30,33,40].
Due to the variability of activity from one individual to another, there exists no standard dataset representing normal or abnormal behaviours. This makes abnormality detection a very difficult task. A data-driven approach seems promising as it involves modelling each individual's routine independently based on the individual's activity data. Researchers have taken the approach of modelling the usual behavioural routine of individuals to serve as a baseline model. Subsequent activities are compared to baseline and significant deviations are classified as outliers or anomalies [6,27,50]. This approach is also referred to as "Novelty Detection" or "One-Class Classification" [38].
The limitation of the existing anomaly detection models is their inability to identify the anomaly sources. The term "Source(s) of Anomaly" is used to refer to the feature of the data entry responsible for the classification of that entry as an outlier. For example, for activity-based anomaly, detection system for sleeping routine, different features of the sleeping activity such as the time, duration, day or week, interruptions, activity transitions, proceeding or succeeding activities can be the source of the abnormality. As an illustration, Fig. 1 shows a sample plot representing a sleeping activity pattern with two features (i.e. start time and duration) selected from several features for easy visualisation. The clusters "X1", "X2" and "X3" represent the normal activity routines while A, B, and C indicate abnormalities. Existing computational models can identify the anomalies but not the sources of the anomalies. The sources can be observed from Fig. 1 as follows: (1) the anomaly source for "A" is the duration feature indicating insufficient sleep or oversleeping, (2) the anomaly source for "B" is the start time feature indicating going to bed early or late while (3) the anomaly source for "C" is both the start time and duration features.
The main contribution of this paper is the proposal of a similarity measure approach for identifying the sources of anomalies in human activities. The proposed exploratory approach is based on a pairwise distance measure of the features extracted from the activity data. Two approaches for measuring the pairwise distance are presented and termed as one vs one similarity measure (OOSM) and one vs all similarity measure (OASM). Statistical measures are then applied to estimate the threshold of the extracted features with features exceeding the threshold predicted as the anomaly sources. An ensemble of novelty detection models consisting of one-class support vector machine (OS-SVM), isolation forest (iForest), local outlier factor (LOF) and robust covariance estimator (RCE) is applied for the detection of outliers in the data. The proposed similarity measure approach is then applied to the predicted outliers to identify their sources.
The rest of this paper is organised as follows: "Related work" provides a review of related studies, while "Anomaly detection in human activities" gives an overview of the anomaly detection models. In "Proposed similarity measure approach to identifyanomaly source", the similarity measure approach is presented. "Experimentation and discussion" contains experimental results. A conclusion of the work is then provided in "Conclusion".

Related Work
Research in the field of ambient intelligence (AmI) has been receiving tremendous attention, primarily due to the need to promote the independent living of the increasing ageing population [1]. The advent of miniaturised sensing devices allows for an easy collection of data for human activity recognition (HAR) and behaviour modelling. The work by Thapliyal et al. [45] took a close look at smart home technologies and their applications for improved wellbeing of the older adults. Activity recognition is primarily focused on interpreting the collected sensor data into a human-readable form [23]. Behaviour modelling deals with the utilisation of the activity data to build a profile of the monitored individual. Different methodologies have been applied for monitoring and recognition of human activities using ambient sensors, wearable sensors or both [3,9,19,31,39,41].
In ADL context, approaches for detecting abnormalities in human activities are broadly classified into three categories, namely: (1) score-based approach, (2) classification approach and (3) outlier detection approach.
The score-based approach involves clinical assessment of the older adults health by a clinical expert. Certain aspects of their daily routines (such as mobility, cognitive health, etc.) are assessed over some time (e.g. every 6 months) and a score is assigned for each of the categories during the assessment. A computation model (usually a regression model) is then trained to map the data collected from ambient sensors in the home environment during the period of the assessment to the assigned score. The aim is to have the trained model predict future health score from the future ADL data. The clinical assessments are carried out using a questionnaire or by mere observation of an expert. While this approach seems promising, it is subjective and highly dependent on the period in which the assessment is performed. For instance, a wrong score may be assigned to an individual which may not reflect the actual health status of the subject, especially if the evaluation is performed when the subject is not in a good state of mind.
Based on the above concept, the author in [16] proposed clinical assessment using activity behaviour (CAAB). The proposed approach is applied to ADL dataset collected for the duration of over 2 years from 18 different smart homes. To evaluate the approach, statistical correlation is established between the score assigned by the expert and the prediction of the CAAB regression model. Similar work is carried out by [5] using the same dataset. The only difference is that this clinical assessment encompasses more areas than CAAB, such as money and self-management, home daily living, travel and event memory, and social skills. This large set of activities is referred to as incremental activities of daily living-compensation (IADL-C). In addition to assigning a health score, a classifier is trained to predict changes in recurrent health scores. In the extended version of the paper, the author attempts to reduce the class imbalance problem by oversampling the minority class [2]. The results obtained show a correlation between the expert's assigned scores and the model's prediction. The classifier performs poorly in predicting changes in recurrent assessment.
In the classification approach, ADL anomaly detection is treated as a binary classification problem. Binary classification task requires training data for the two classes to be available. Due to the absence of training data representing normal and abnormal activities, the approach taken is to use the collected data as the training samples for the normal class, while synthetic data are the generated for the abnormal class. The synthetic data are generated to reflect common anomalies relating to MCI. For instance, since frequently interrupted sleep and confusion in the performance of daily activities are attributed to early symptoms of Dementia, the data is generated to mimic these symptoms. The authors in [7] used this approach. They artificially insert anomalous events into the collected data such as random events in between sleeping activity to reflect a disturbed sleep and altering the order of activity sequence to simulate confusion in the carrying out the activity, etc. A classifier is trained on the data to efficiently detect anomalies. The major drawback of this approach is that for the model to detect any anomaly, a synthetic data simulating that anomaly must be generated. Generate every variation of an anomaly is nearly impossible due to the variability of anomalies across individuals.
A combination of convolutional neural network (CNN) and long-short term memory (LSTM) is used to detect synthetic anomalies in [7]. The ADL data are converted into a 2D image map and fed into a CNN to learn data encoding while LSTM learns the activity sequence. In [22], an approach for early detection of anomalous behaviour in smart homes based on causal association rule is proposed. The identified causes are then utilised with Markov Logic network for identifying the risk of anomaly occurrence at a later time, and for recommending suitable actions to avoid future occurrences. In [51], the authors perform a comparative analysis of LSTM, CNN, CNN-LSTM and Autoencoder for accurate detection of ADL anomalies. The validation is performed on public datasets while employing an oversampling technique to alleviate the non-uniformity in the data distribution.
The outlier-based approach differs from the classification approach as only one set of training data is required. The collected ADL data are used as the training sample representing normal behaviour for building the baseline model. Subsequent activity data are compared to the baseline, and significant variations are classified as outliers. This concept is adopted due to its less prone to errors and versatility compared to the classification approach since there is no need to generate every variation of an anomaly. Similar to the scorebased and classification-based approaches, the collected data must reflect the usual behavioural routine of the individual. Data that is contaminated with outliers could lead to poor performance by the model.
The authors in [25] utilised ADL data collected with ambient sensors to detect abnormal activity instances using different entropy measures. Activities with entropy value exceeding a certain range are predicted as outliers. Abnormality detection algorithms based on hidden state conditional random field (HCRF) are proposed in [47]. Data collected using ambient sensors are utilised for the validation of the proposed approach, and a comparison with SVM is carried out. Similarly, the authors in [4] proposed a system for promoting the safety of autistic children indoor. This system is based on a 3D-CNN and LSTM applied to a video stream to predict activities with physical irregularities. This system applies to older adults monitoring. A Kinect depth sensor is used in [37] for identifying deviating activities that could constitute an abnormality in a smart home environment. A data-driven technique is used to define fuzzy sets over attributes of the occupant's behaviour and a fuzzy inference engine with a membership function is used to identify an abnormal pattern.
In [27,49], OC-SVM is used to detect ADL anomalies. An approach for creating an ensemble of outlier detection models is proposed and applied for the detection of anomalies in ADL dataset in [50]. Density-based spatial clustering of applications with noise (DBSCAN) is used for the detection of ADL anomalies in [18] by clustering the duration, time and number of triggered sensor events of the activities. Activities with irregular durations, time, and the number of triggered events are classified as anomalous. DBSCAN is also used in [24] by classifying activities that fall outside the cluster as abnormal. Researchers have also utilised temporal models for identification of ADL anomalies for activities that are temporal in nature.
An approach is proposed for detecting temporal relation between activities and detecting abnormality in them [28]. Modelling the sequential pattern of activities can allow for the detection of anomalies since anomalies are novel patterns. In [6], recurrent neural network (RNN) is utilised while Hidden Markov Model (HMM) is used in combination with a Fuzzy rule-based system (FRBS) for the detection of anomalies in human activities in [20]. Anomalies relating to room occupancy is detected using Self Organising Map (SOM) in [35], while echo state network (ESN) is used in [30].
The existing system for anomaly detection in ADL often operate in an offline manner. To address this limitation, Meng et al. [32] proposed online daily habit modelling and anomaly detection (ODHMAD) model capable of performing real-time activity recognition and anomaly detection from ambient sensors data. Computational models for anomaly detection have been applied in a non-ADL context as well. In [44], anomalies in human activity is detected from a video stream using a CNN with an adaptive compression technique. Similarly, CNN-based approach for anomaly detection in images is proposed in [21].
Outlier detection models are based on different methodologies. Some of the models are based on a distance measure that involves estimating the nearest neighbours of the data points. The data points with close neighbours are classified as normal and vice versa. One of the drawbacks of this approach is that it is computationally expensive in high dimensional space [38]. In [15], this distance approach is used for the detection of a disease outbreak. In density-based approaches, data points in the region of low density are classified as outliers and normal otherwise [38]. The approach assumes that the data are of a certain distribution, which makes it practically impossible for real-life application since the data distribution is not known a priori. To mitigate this, non-parametric approaches are proposed in which the distributions are estimated from the training sample [38].
To enhance the performance of the outlier detection models, ensemble models are used since each individual model is good at certain characteristic feature. Dib et al. [17] applied an ensemble of machine learning models to monitor structural health by detecting damages using guided waves generated by the building sensors. An ensemble of novelty detection models based on a consensus vote is proposed in [50] and applied for the detection of ADL anomalies, while in [36], an ensemble approach based on similarity measures is proposed.
From the reviewed literature, it can be seen that anomaly detection is relevant to different application areas. A summary of the reviewed works relating to ADL anomaly detection is presented in Table 1.

Anomaly Detection in Human Activities
The proposed workflow for identifying the sources of abnormalities in human activities presented in 5 steps is shown in Fig. 2. To detect the anomaly sources, the underlining ADL data must contain outliers identifiable using computational models. Detecting abnormalities is a complex task due to the variability of activities from one individual to another, thereby leading to the absence of standardised datasets representing normal and abnormal activities. Additionally, the existence of anomalies in different activities makes the anomaly detection task rather arduous. To address this, a data-driven activity-based approach is adopted whereby the computational models for anomaly detection are trained on data representing the activities of interest.
The initial set of data collected from the home environment representing the usual behavioural routine of the monitored individual is used to train the novelty detection models to serve as a baseline. The baseline model is then utilised on subsequent activity data to detect deviating routines that constitute an abnormality. In this context, the result of the model for each activity is considered as either normal or anomaly. The observations predicted as anomalies are then explored further to identify the actual source of the abnormality as depicted in Fig. 2. In the remaining part of this section, six computational models for behaviour modelling and abnormality detection are explained. The exploratory similarity measure approach for identifying the anomaly sources (stage 5 of the workflow) is presented in "Proposed similarity measure approach to identify anomaly source".

One-Class Support Vector Machine (OC-SVM)
The OC-SVM is an unsupervised novelty detection algorithm proposed by Scholkopf et al. [43]. To identify outliers, assuming the data have an underlying probability distribution P, the problem can be framed into a minimisation of a quadratic function.
Let A = {a 1 , … , a n } be an n set of d-dimensional data ( A ∈ ℝ d ), and ∶ ℝ d → F be a non-linear mapping from a data space ℝ d to a feature space F, The support vector separating the data is computed by solving the quadratic problem: subject to where n is the training sample size, v ∈ (0, 1) is a trade-off parameter for the expected fraction of outliers, is a slack variable, w and are the hyper-plane parameters in the feature space F. To solve the Eq. 1, the decision function f(a) which determines if a i is an outlier is obtained as: where i is a Lagrange multiplier for the vectors a i and k(a i , a) = is the kernel function for the non-linear mapping.
The radial basis function (RBF) kernel with spread parameter is used: The prediction of the model is determined from Eqs. 3 and 5. A more details description of OC-SVM can be found in [43].

Isolation Forest
The iForest is based on the premise that outliers are few and different, making them susceptible to isolation [29]. This makes the detection of anomalies based on the concept of isolation rather than using distance or density measures. Let A = {a 1 , … , a n } be an n set of d-dimensional data ( A ∈ ℝ d ). An isolation tree (iTree) is built from subsample instances of A ′ ⊂ A by recursively dividing A ′ with a randomly selected attribute q and a split value p, until either: (1) the node has only one instance or (2) all data at the node have the same values. The iTree is a binary tree with each node having exactly zero or two child nodes. Assuming all instances are distinct, each instance is isolated to an external node when an iTree is fully grown, the number of external nodes is , the number of internal nodes is ( − 1 ) and the total number of nodes of an iTree is ( 2 − 1 ). To detect outliers, a ranking of the data that reflects the degree of anomaly is performed through the sorting of the data points according to their path lengths or anomaly scores. The anomalies are points that are ranked at the top of the list. The different terminologies for the iForest are defined as follows: -Isolation Tree (definition) Let T be a node of an iTree.
T is either an external node with no child, or an internal node with one test and exactly two child nodes ( T l , T r ). A test at node T consists of an attribute q and a split value p such that the test q < p determines whether the data point belongs to either T l or T r . -Path length (definition) The path length h(a) of a point a is a measure of the number of edges a traverses an iTree from the root node to an external node such that a short path length indicates a high degree of susceptibility to isolation and a long path length indicating low susceptibility. -Anomaly score (definition) The anomaly score s(a, ) for a data point a of data set with n instances is given as: a)) is the average path length (h(a)), c( ) is the average path length of unsuccessful binary search, and is the subsample where H(i) is a harmonic number estimated as ln(i) + 0.5772156649 (Euler's constant is 0.5772156649). The interpretation of the outcome of the anomaly score is summarised below with a more detailed discussion in [29].
-The instances are anomalies if the value of s is close to 1 ( E(h(a)) → 0, s → 1).

Local Outlier Factor
The local outlier factor (LOF) is an unsupervised approach for outlier detection that is based on density estimation of a data point relative to its nearest neighbours. Since the density around an outlier differs significantly from the density around its neighbours, data points with relatively lower density to its neighbours estimated in a form of a score are considered as outliers [8].
Let A = {a 1 , … , a n } be an n-sample dataset. Let d(a, b) denote the distance between two objects a and b. Assuming a = a i is an observation in A, the k-distance of a denoted by D k (a) is the distance between a and its k-nearest neighbours while the k-distance neighbourhood of a denoted by N k (a) contains every element whose distance from a is not greater than k-distance D k (a) of a given as: x is an entry in A, which is a neighbour of a The k-reachability distance RD k (a) of the object a w.r.t an its nearest neighbours a ′ is given as: The local reachability density LRD k (a) of a is given as: The average of the ratio of the local reachability density of a and its k-nearest neighbours is presented as: The lower the local reachability density LRD k (a) of a the higher the local reachability density LRD k (a � ) of its nearest neighbours a ′ , the higher the LOF LOF k (a) , making the a an anomaly. A more detailed discussion of LOF can be found in [8].

Covariance Matrix Estimation
In this approach, outliers are detected using the maximum likelihood estimators (MLE) for the mean and the covariance matrix of the normal (non-outlying) data. Observations with RD k (a, a � ) = max{D k (a), d(a, a � )}.
abnormally large distances (Mahalanobis distances) are predicted as outliers [42]. Let A = {a 1 , ..., a n } be an n-sample dataset of d-dimension and each observation a i = {a i1 , ..., a id } . Assuming the data follows a multivariate normal distribution, The mean ( ̂ ) and covariance matrix ( ̂ ) estimated using MLE are given as: The Mahalanobis distance of the observations are computed as: The estimations above assume that the observations are not contaminated as few outliers could lead to poor performance. Alternative robust approaches termed as Robust covariance estimation (RCE) for estimating the location (mean) and scatter (covariance) such as using minimum covariance determinant (MCD) are proposed [42].

Ensemble of Detectors Based on Similarity Measure
Ensemble approaches allow for the aggregation of individual models for better performance. Ensemble models for outlier detectors based on similarity measures are proposed in [36]. The authors proposed two approaches namely, ensemble of detectors with correlated votes (EDCV) and ensemble of detectors with variability votes (EDVV). The proposed approaches merely estimate the appropriate weight for each model in the ensemble using the individual model's results for a given dataset. The weight estimation in EDCV is based on correlation coefficient while the weight estimation in EDVV is based on a measure of mean absolute deviation (MAD) of the individual model output. Using the estimated weights, a score for the data entries are calculated to determine if the data points are outliers.
Let A = {a 1 , … , a n } be an n set of d-dimensional data ( A ∈ ℝ d ). Let G = {g 1 , … , g m } be a set of m outlier detection models. a i is an observation in A and g i is a model in G. The weight W(g i ) for g i is estimated using Equation 15 and Equation 16 for the EDCV and EDVV respectively.
ℂ is a matrix of the correlation coefficients of A for the corresponding model g i and m is the number of models in the ensemble.

is a matrix of the MAD of A for the corresponding model g i and m is the number of models in the ensemble
The final score for a data entry a i is calculated as: S(a i ) is the final outlier score, m the number of models, F(i, j) is the outlier score, V(i, j) is the label (output), and W(j) is the weight of the jth model respectively.

Consensus Novelty Detection Ensemble
As part of our earlier contribution for robust detection of ADL anomalies, an ensemble approach is proposed in [50] termed consensus novelty detection ensemble (CNDE). The approach is based on consensus votes obtained for an activity and the computation of a normality score that determines the data label (either outliers or inliers). Let A = {a 1 , … , a n } be an n set of d-dimensional data ( A ∈ ℝ d ). Let G = {g 1 , … , g m } be a set of m outlier detection models. The Normality Score S(a) which determine if a is an outlier is calculated as: where (a) is the ICS, k is the number of folds the training data is split into to train k sub-models, u is the vote from the sub-models. denotes the final weight (after penalisation), ̃ is the initial weight (before penalisation usually initialised to 1), e is the false prediction rate for each model in the ensemble respectively and n is the training sample size. A threshold value is introduced for the Normality Score S(a) estimated from the distribution of S(a) . The function f(a) determines the model outcome as: The Normality Score S(a) value ranges from 0 to 1 ( 0 ≤ S(a) ≤ 1 ) with lower score value ( S(a) → 0 ) signifying outliers. An elaborated discussion of this ensemble approach can be found in [50].
The presented anomaly detection models are applied to ADL datasets for the detection of outliers. Additionally, an ensemble of models based on a majority vote approach is considered and the obtained results are presented in Sect. 5.
x is an outlier otherwise x is NOT an outlier

Proposed Similarity Measure Approach to Identify Anomaly Source
Computational models identify outliers by measuring the similarity between data points such that entries with a significant variance in the measured similarities are predicted as anomalies. The process of identifying the sources of anomaly involves (a) estimating the similarity matrix of the training data, (b) estimating the threshold of the similarity matrix, (c) computing the similarity matrix of the anomalous observation and d) calculating the similarity score of the anomalous observation to identify the source as shown in the schematic diagram in Fig. 3. Different similarity measures exist in the literature for both numerical and categorical data with distance functions such as Euclidean, Minkowski, Manhattan distances commonly used as a measure of similarity for numerical data [48]. In general, machine learning models for both supervised and unsupervised learning utilises distance measures. For example, K-nearest neighbour (KNN) uses distance functions such as Euclidean and Manhattan to measure the distances between a data point and its neighbours, with instances having relatively close neighbours  [26,48]. Clustering algorithms such as K-means uses distance measure to estimate the proximity of the data entries to their assigned cluster centroids [48].
Two approaches for the distance measurement are proposed and termed as; one vs one similarity measure (OOSM) and one vs all similarity measure (OASM). The approaches involve the pairwise distance measurement of the corresponding features of the dataset. We utilised three distance functions, namely Euclidean, Chebyshev and Canberra distance satisfying the fundamental distance measure requirements as follows [48]: In the OOSM, the distance is measured between corresponding features of the data entries one at a time. For example, the distance of the ith feature of the first entry is a 1 is measured against the ith feature of the second entry a 2 , then with that of the third entry a 3 and vice-versa across all the features as a given in Eq. 27. In the OASM, the distance of the corresponding features is measured all together in one single expression. For example, the distance of the ith feature of the first entry a 1 is measured against the ith feature of all the remaining entries as presented in Eq. 31.

One vs One Similarity Measure (OOSM)
Let A = {a 1 , a 2 , ..., a n } be a d-dimensional set of n normal activity data used for training the anomaly detection model. The similarity matrix (A) is calculated as the distance of the pairwise features of the observations. Expressing the data A in a matrix form: Given the similarity matrix (A) for A: The similarity (a i , A) for the ith observation of A is can be presented as: where (a k i , a k j ) is a 1-dimensional pairwise distance calculated using the three distance functions as:

One vs All Similarity Measure (OASM)
The similarity matrix (a i , A) in Eq. 26 is calculated as: The one-dimensional pairwise distance (a k i , a k j=1,…,n ) is a calculated as: The threshold � ⃗ (A) of the features (columns) of (A, A) in Eq. 25 is a row vector estimated from the positively (right) skewed distribution of the entries using median and interquartile range rule for outlier detection [46].
where , are the median and interquartile range of the kth feature while e is a constant (usually set to 1.5).
Given a set of d-dimensional outliers B = {b 1 , b 2 , ..., a m } , the anomaly source for each observation b i is estimated by estimating its similarity with the non-outlying data given as: A) is calculated using either OOSM in Eq. 27 or using OASM in Eq. 31. The similarity score ̃ (b i , A) for b i is a row vector obtained by calculating the feature mean of (b i , A) from Eq. 37.
where k is the score for the kth feature of the observation b i .
The function f ( k ) that determines if the k feature is the anomaly source is expressed as: The anomaly source is identified in Eq. 40. If the similarity score of the feature k has an abnormally large variance to the feature threshold k , the kth feature of the observation is the anomaly source. Figure 3 shows a schematic diagram of the proposed similarity measure while its procedures are outlined in Algorithm 1.
The kth feature is NOT the anomaly source otherwise The kth feature is the anomaly source

Experimentation and Discussion
This section contains the description of the datasets employed for the validation of the proposed approach. The preprocessing technique, experimental scenarios and the obtained results are presented in this section.

Datasets and Preprocessing
Two real datasets utilised for the evaluation consists of data collected as part of this research work from Nottingham Trent University (NTU) smart home facility termed as "SmartNTU" and a publicly available dataset from Center for Advanced Studies in Adaptive System (CASAS) repository termed as "CASAS HH111". The datasets are collected using low-cost, non-invasive ambient sensors such as passive infrared sensors (PIR) installed in various location of the smart home to identify the presence of individuals, Fig. 4 A sample plot of raw binary data from ambient sensors SN Computer Science pressure sensors on sofas and beds to identify sleeping or sitting activity, door entry sensors to detect door opening and closing events, etc. The use of these sensors for data collection is due to their non-intrusive nature, thereby posing fewer privacy concerns, and are found to be generally more acceptable compared to visual sensors (e.g. cameras) [13]. The CASAS HH111 dataset consists of the daily activity data for a volunteer older adult living alone for a duration of 50 days [12]. During the data collection period, the recorded activities include but not limited to sleeping, toileting, eating and kitchen-related activities, etc. Similarly, the SmartNTU data consist of the recorded activity data for an individual living alone for the duration of 72 days.
A sample plot of the binary data generated by the ambient sensors (e.g. PIR sensor) is shown in Fig. 4. The attributes of the sensor data include a timestamp used to represent the start and end time of an activity, a unique device identifier for identifying the sensor location, event value, etc. Different computational models are proposed in the literature for data interpretation [14]. The interpreted activity each consist of several attributes such as start time, end time, activity type and the location of the performed activity. Table 2 shows a sample of the interpreted activities from the collected sensor data.
To efficiently evaluate the performance of the computational models and reduce bias due to class imbalance in the datasets, the datasets are oversampled using an approach proposed in [10] known as synthetic minority over-sampling technique (SMOTE).
Since the anomaly detection approach is activity dependent (i.e. anomalies are detected in activities of interest), the datasets are filtered, and sleeping activities are selected for modelling and detection of abnormalities. Additionally, artificial anomalies in sleeping activity simulated based on the data distribution are induced. The following features are extracted from the sleeping activity: -Interruption(s) This is used to represent the transitions from the sleeping activity to other activities. If the duration of the transition is less than 1 h, the activity is considered interrupted, otherwise, the end of the activity.  For the computational models to achieve optimal results, the extracted features are normalised due to the variability in their respective scales.

Experimental Scenario and Result
The proposed approach for identifying the sources of anomaly applies to data already classified as outliers by the anomaly detection models described in Sect. 3. The four models presented namely, OC-SVM, iForest, LOF and RCE as well the ensemble approaches such as majority votes (MV), EDCV, EDVV and CNDE are evaluated on both the SmartNTU and CASAS HH111 datasets. The model contamination rate parameter (i.e. the rate of outliers in the training data) is set to a minimal value of 0.1 across the models.
The model training is performed using the activity data for the first 31 days, and the data for the remaining days are used for the validation. Data observation predicted as outliers are confirmed from the ground truth of the simulated and oversampled data as well as the outliers manually annotated.
The result of the abnormality detection models for the SmartNTU dataset is shown in Fig. 5, while that of the CASAS HH111 dataset is shown in Fig. 6. It can be seen that in both cases, the ensemble models outperformed the individual models as expected. For the separate individual models, OC-SVM performs better than iForest, LOF and RCE across the two datasets. Overall, the CNDE ensemble approach we proposed in [50] achieved the overall best performance with the accuracy of 98% and 96% for the SmartNTU and CASAS HH111 datasets, respectively.
These results indicate that the models are able to identify abnormalities in the sleeping activity, which may be due to the variability in the extracted features. To identify the features that are the likely source of the identified anomalies, the anomalous observations are explored using the proposed similarity measure.
Utilising the anomaly detection results presented in Figs. 5 and 6, the observations from both datasets that are predicted as outliers are further explored using the proposed similarity measure to identify the anomaly sources. After the oversampling of the datasets with SMOTE prior to the model training, the respective datasets contains approximately 100 anomalous observations with a relatively equal number of sources in 4 of the most discriminating features that are identified using principal component analysis (PCA). The four features are the start time, duration, interruption, and interruption length. The outlying observations are explored and the features of the data that are the likely anomaly sources are identified. Since multiple features can be identified as the source, identification of at least one anomaly source per activity is sufficient. In a scenario where multiples anomaly sources (features) are identified, a true positive prediction is assigned if one of the predicted sources matches the ground truth.
To evaluate the performance of the similarity measure approaches, different metrics are measured in comparison to the ground truth. The ground truth of the anomaly sources is identified through the manual observation and annotation of the outliers on a feature by feature basis, and from the annotated data used for anomaly detection. For the artificially induced anomalies, this is easily achieved since the altered features of the data entries are known. The features that are altered to simulate an abnormally large variance for a given data entry are labelled as the sources of the anomaly for that entry. The four possible prediction outcomes for any given entry relative to its features are given as follows: -True positive (TP) When a feature of the data entry labelled as the anomaly source is correctly predicted as the source by the model. To further evaluate the proposed approaches, synthetic data are generated with outlying entries for the duration of 100 days. The features of the generated data are based on the distribution of the midpoints for the first and second quartile of the SmartNTU dataset. The simulated outliers sources are set as the third quartile of the data distribution of the features. These data are then utilised for the validation of the proposed approaches. The result obtained for the similarity measure approaches based on Euclidean distance is presented in Fig. 7 Tables 3 and 4. It can be seen from Table 3 that the obtained result is slightly better for the SmartNTU dataset compared to that of the CASAS HH111 dataset. However, the result for the Synthetic data surpasses that of the real datasets. This is expected since the synthetic data is carefully crafted to fit the model's requirement and therefore, should not be used as a measure of accuracy since the models can be biased towards the data. The average accuracy in Table 4 is grouped based on the distance function and based on the similarity measure approach across Fig. 7 Result for the similarity measures based on Euclidean distance on; a SmartNTU dataset, b CASAS HH111 dataset, c) Synthetic dataset the two real datasets (SmartNTU and CASAS HH111) while excluding the result of the synthetic data in the computation due to the biased nature of the result. From the tabulated results, Euclidean distance function has the best performance while Canberra distance has the least. Additionally, the OASM approach outperforms the OOSM approach across the datasets. The OASM approach has an additional advantage of having a linear run-time complexity O(n) over the OOSM approach that has a quadratic run-time complexity O(n 2 ).
The identified anomaly sources (e.g. start time, duration etc.) may not have a significant meaning in the context of human activity recognition and behaviour modelling. To better understand the anomalies, a mapping is created from the extracted feature space to the real-life sources. This means that the extracted features are translated and attributed to real-life causes of the anomalies. For example, if the anomaly source is the start time, then the real-life source could be an indication of going to bed early or later than usual. Similarly, if the anomaly source is the duration, then this can be  Table 5 indicating the identified source and its real-life mapping observed from the data. To the best of our knowledge, no other exploratory approach exist for identifying anomaly sources in this context thereby making a comparative analysis of the proposed similarity measure nearly impossible.
Additionally, the datasets used for this validation consist of small data samples and fewer features. In a scenario where the dataset is significantly large or containing a large feature set, the proposed approach for estimating the similarity matrices may be time-consuming. This is because the similarity is measured for each outlying observation against the entire training samples across all the features. A heuristic approach for selecting fewer samples Fig. 9 Result for the similarity measures based on Canberra distance on; a SmartNTU dataset, b CASAS HH111 dataset, c synthetic dataset of the training data to be used for the similarity estimation can improve the efficiency of the methodology.

Conclusion
This paper proposes an exploratory approach for identifying sources of abnormalities in human activities based on a similarity measure approach. The proposed approach involves the pairwise distance measurement of the extracted features from human activity dataset in the form of a similarity matrix. A statistical approach is then applied to estimate the optimal threshold of the features and for the identification of the anomaly source with an achieved average accuracy of 0.82. As part of the future work plan, the proposed methodology will undergo extensive evaluation for the identification of multiple anomaly sources. Furthermore, approaches for optimising the data selection process for the similarity matrix computation will be explored. In addition to the identification of anomaly sources, the possibility of utilising the proposed approach for anomaly detection will be explored.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creat iveco mmons .org/licen ses/by/4.0/.