I OT -B ASED A CTIVITY R ECOGNITION W ITH M ACHINE L EARNING F ROM S MARTWATCH

A BSTRACT Human activity recognition(HAR) with wearable Internet of Things (IoT) sensors can be beneficial for the elderly and patients monitoring. Smartwatches are the most accessible IoT devices that play an important role in human activity monitoring. The structure of an activity recognition system involves a platform that holds wearable sensors. Under the background, many platforms such as distributed sensors and smartphones and the combination of them have been investigated but platforms are still one of the main research challenges. Smartwatches can be more comfortable for the elderly and patients, therefore our research is focused on a smartwatch as an emerging IoT platform and machine learning method. The smartwatch attached to arm as the main position then was compared to other positions. We considered machine learning methods to present the smartwatch as a reliable platform in order to recognize activities, also we considered k-nearest neighbor and decision tree as two popular machine learning methods for activity recognition. We evaluated the performance with the confusion matrix and then we used accuracy and f1-score metrics for the result of our experiment. The metrics show accuracy and f1-score almost 99% as the performance of smartwatch on arm position.


1.INTRODUCTION
Internet of Thing (IoT), is an innovative design for network of thousands of sensor nodes communicating with each other and offering solutions for real life challenges [1]. A wide variety of applications and services is covered by IoT infrastructures, from smart environment [2] , smart navigation systems [3,4], smart sensor networks [5] and smart crowd-sourcing [6]. Human Activity Recognition(HAR) with wearable Internet of Things (IoT) sensors can be beneficial for the elderly and patients monitoring [7]. The increasing use of technology in healthcare causes better solutions for treatment, cost and time to a wide range of disease such as Parkinson [8], Multiple sclerosis(MS) [9], and elderly [10]. Parkinson's disease (PD) is a neurodegenerative disorder that affects neurons in the brain. Parkinson develops slowly and has negatively affected on patient's movements. The Tremor of hands, limb rigidity, balance problem occurred during developing. More than 10 million people with Parkinson's disease are in the world and about four percent of patients are before age 50. E-health systems provide a platform for monitoring patient's activities of daily living and trends of treatment. Multiple sclerosis (MS) is a long-lasting disease that damages the brain and the brain's signals will not be sent to the body truly. Most people with MS are young adults between the ages of 20 and 50. MS can cause problems with vision, balance, and muscle control, and it causes some patients to have trouble with doing daily tasks such as walking. Patient with MS should be done some activities and under monitored continuously. Falling is one of the daily living unpleasant events especially for elderly. World Health Organization (WHO) reported Falling is the second incident leads to death worldwide and the greatest number of fatal falls are related to elderlies who older than 65 years. According to the Centers for Disease Control and Prevention (CDC) the average hospital cost for a fall injury is over $30,000.
Remote E-health monitoring system is a choice to control activities of daily living (ADL) [11]. The remote monitoring system can improve elements such as better access to the elderly and patients' data, quality of care and support, real-time feedback [12,13]. The activity recognition system is a type of E-health systems that provide a platform to recognize the activities of daily living (ADL). According to [14] human activities classified into global and local. Global Activity means daily living movements with whole body motion such as walking and running as well as we considered in this paper.
There are several approaches to recognize activities involving wearables [15], cameras [16], and ambient [17] sensors. Wearable approaches include attaching a single sensor, attaching combined and distributed sensors, an inertial measurement unit(IMU) and devices that attached on different body positions. Wearable devices are a simple way for activity recognition. They have various types such as smartphones, smartwatches, wristbands, wearable pendants, smart eyewear, smart jewelry or even e-tattoo and e-skin. Among them, the smartwatch is one of the most popular devices that provides the opportunity to recognize activities as the new solution.
Today's smartwatches are easily available and accessible in markets and people interact with them in their daily life. Most of them support the required sensors for activity recognition such as accelerometer, gyroscope, and magnetometer. Their computational power and flexibility increase as well as their cost and size and energy consumption decrease every day. Using a smartwatch is a better solution for activity recognition in order to prevent wearing many sensors on different position that can uncomfortable for elderly and patients. Also, a smartwatch is a better solution than a smartphone because people carry smartwatches along the day but smartphones can not reachable as simple as smartwatches especially at sleep in case of fall event. Also, types of wristbands and other accessories have low power and limited resources than smartwatches. Therefore, in this paper, we considered a smartwatch as the main solution for activity recognition instead of other wearables.
The structure of an activity recognition system involves two main parts such as sensor position and method. Many positions such as waist, chest, and thigh and the combination of them have been investigated recently. Attaching permanently sensors on waist or chest are not comfortable, they are exposed to sudden blows and their connection can interrupt easily. In this paper, we considered the position of the arm because it can more comfortable for elderly and patients. Although the arm position has high variation in acceleration during activities our experiment shows it is accurate enough for activities of daily livings(ADLs).
In order to human global activities, Machine Learning especially supervised learning can train labeled data which gathered during activities [18]. A wearable like a smartwatch can collect body acceleration using accelerometer, gyroscope, and magnetometer in three axis x,y, and z [19]. After preprocessing, Machine Learning algorithms train preprocessed data to detect activities. K-nearest neighbors and decision tree are the two kind of supervised Machine Learning [20] that we considered to recognize activity in our study.
In this paper, we studied the position of the arm because of arm movement it can potentially won't be as accurate as another part of the body. A smartwatch that is comfortable for the elderly and patients is attached on the arm to collect acceleration of body for the classification and recognition of global human activities. We investigated a smartwatch as a platform with accuracy and F1-score parameters. and we compared algorithms by python.
Toward that end, this paper presents related works about wearable solutions and position of sensors in order to recognize activities in section II. Our experiment methodology involving dataset, experiment and result have described in section III and in section IV conclusion and future work are explained.

2.RELATED WORK
From the past decade, activity recognition with the wearable sensors has been considered. It is started with attaching several sensors on different positions and combining data. Then devices such as a smartphone are used [21]. The location of the sensors and smartphone always has been investigated.
The authors in [22] provided a system with a few distributed sensors instead of using a single accelerometer sensor located on the chest, left under-arm, waist and thigh. The volunteers in the research were adults with ranging in ages from70 to 83. Five classifiers of ANN, Decision tree, KNN, Na¨ıve Bayes, and SVM were used and the result showed 96% accuracy to recognize activities.
In [23] the authors collected data from a smartphone where it was located in the subject's pocket. The triaxial accelerometer collected data during daily living activity in three axes of x,y, and z. The authors noted when the smartphone located in hand, similar activities produced noisy data. After preprocessing, the algorithm of support vector machine used for classifying activities. They achieved a performance between 55% and 95% for different activities.
Fall is a type of daily living activity that causes death and serious injuries especially in the elderly. The paper [24] provided an Android solution to detect fall. The device located on the waist and attached to the user's belt, they used α = Ax 2 + Ay 2 + Az 2 to recognize fall among other daily living activities and when the value of α increases than the fall threshold value, there is a probability of a fall event. The system showed results of 90% specificity, 100% sensitivity, and 94% accuracy.
In another research [25] a single accelerometer located in subject's trousers pocket. After collecting data, effective features are extracted by using discrete cosine transform (DCT), then with principal component analysis (PCA), the dimension of features is reduced and SVM classifier is used for activity recognition with 97.51% accuracy. Using some sensors and smartphones on different positions on the body are common, but according to ever expanding devices especially in emerging IoT technology, devices such as a smartwatch, wearable pendant, and smart shoes [26,27] are more considered. Using the devices in healthcare are still in its infancy. In [28] researched comparison between a smartphone located in the subject's front-right pocket and smartwatch located on their dominant hand to recognize hand activities such as eating and drinking activities. The result showed 93.3% accuracy from smartphone and 77.3% accuracy from smartwatch during drinking. The papers concluded using smartwatch on hand is capable to detect a variety range of hand daily gestures activities.
Softwares are used for implementation machine learning algorithms on activities. Weka, IBM Spss Modeler, Matlab, Python, and R languages. In [29] 16 volunteers wore iPod Touch and performed activities. The device was located in front shorts pocket. The accuracy of 90% to 100% obtained from KNN classifiers and Weka tool.
In recent years although more researches conducted in order to recognize activities by wearable devices but they have more focused on new methods of learning. Most of them are trying to provide faster and lighter methods for machine learning, deep learning, and methods for feature selections. For example, in [30] the authors improved accuracy about 96.72% by providing a new method as a multisensor multiclassifier hierarchical fusion model based on entropy weight. However, they used inertial sensors involving accelerometer and gyroscope on five different positions of body that is uncomfortable.
In the other new published research [31], the authors used reinforcement learning based on recurrent attention learning as a new method for huge datasets. That method is useful for weakly labeled sensor data and the performance of that is better than other deep learning method such as convolutional neural network(CNN) and DeepConvLSTM. Despite improving the results they used a smartphone in the right trouser pocket that is not an appropriate position especially in sleeping situation.
Previous researches have conducted about wearable solutions especially smartphones. They presented that waist and torso and chest are better places for collecting data in order to recognize activities. In this paper, we studied a smartwatch as a new IoT solution and the position of arm as a comfortable position for activity recognition.

3.1DATA
We used a dataset from UCI Machine Learning Repository and we didn't generate data by ourselves. This dataset called "Heterogeneity Human Activity Recognition Dataset" [32] and collected for human activity recognition re-searches. This dataset includes data from several smartwatches and smartphones. We selected data from Samsung Galaxy Gear Smartwatch that exists in this dataset. The Samsung Galaxy Gear Smartwatch equipped with accelerom-eter and gyroscope for body acceleration and angular velocity respectively. Its accelerometer measures body ac-celeration with 100Hz as a record in x,y, and z-axes. Table 2 shows the description of the Samsung Galaxy Gear Smartwatch. To collect data, 9 volunteers named a,b,c,d,e,f,g,h,i between 25 and 30 years who wore smart watch performed 6 activities. The activities are sitting, standing, walking, stairs up, stairs down and cycling, as shown in Fig 1. Each activity was performed 5 minutes, by volunteers. The dataset has a file named Watch-accelerometer and it has more than 300000 records of activities. Each record has 8 features, the description of each feature shown in Table 1. The smartwatch model Device The specific device of the modle (Samsung Galaxy Gear Smart Watch) Gt The executed activities labeled bike sit, stand, walk, stairsup, stairsdown and null Attaching sensors on body directly are not comfortable for elderly and patients but devices such as smartwatches are more comfortable because using watches is one of the common habits for people. For an activity each position of body produce a specific acceleration. The output of body acceleration will be different, based on the position of the sensors. The variation rate of acceleration in arm is higher than waist position because arm has higher movements than the other positions such as waist. In previous works, the position of arm was used for local activities such as making coffee, brushing teeth, not for global activity such as walking. In this paper, we considered a smartwatch equipped accelerometer on arm position for global activities because it has comfortable using.

4.1.1.A METHODS
Machine learning methods have been an essential role to evaluate the performance of IoT devices. Machine learning provides supervised methods to classify labeled data, then discover patterns, and make decisions. The task of methods in activity recognition case is assigning each record of acceleration into a class of activities. For our experiment, we divided the dataset into two classes. One of the classes is 70 percent of whole data for training and the other subset is 30 percent for testing. We used Python's Scikit-Learn library for implementing machine learning methods.There are several machine learning methods used for activity recognition in recent years. We considered k-nearest neighbors(KNN) and decision tree(DT).
KNN is one of the popular machine learning methods for activity recognition. In this experiment we suggest KNN for the following features: -KNN has a better performance with a few dimensions. According to the structure of dataset that is shown in Table 1 we have just 8 features or dimensions, so KNN calculates distance in each dimension easily.
-KNN is a lazy algorithm, so it has a simple training phase opposite of deep learning. -Due to this point that KNN is a non-parametric method, it can be generalized for many people that produce variety situation and range of acceleration.
To use KNN we need K value and distance. In order to achieve the best K we set K value between 1 to 40 for test and we determined K=9 with the lowest mean error. Fig 2 shows a graph   .
Decision tree is one of the other supervised machine learning methods. A decision tree is a graph with several nodes that they are the same features in the dataset. After KNN we suggest decision tree for the following features: -It is a graph that shows the trend from data to assigning data into a class, so it is useful to discover patterns of activity in elderly and patients.
-Decision tree is a very fast method. The result of KNN and decision tree described in the next section.

RESULTS
IoT can employ wearable sensors to goal of healthcare. Wearable healthcare sensors are bridges between el-derly/patients and caregivers. Wearables are popular for activity recognition because they can be used both indoors and outdoors. We used a smartwatch as a new IoT comfortable wearable to recognize activities. For recognition, we considered two of more popular supervised machine learning methods involving KNN and decision tree. We used python to implement those methods.
We used the confusion matrix to evaluate our experiment. For example confusion matrix parameters in this experiment show true positive(TP) if the activity is cycling and it is predicted cycling, true negative(TN) if the activity is not cycling and it is predicted not cycling, false positive(FP) if the activity is not cycling and it is predicted cycling, false negative(FN) if the activity is cycling and it is predicted not cycling. After then we used accuracy and f1-score metrics for evaluating the results. We used recall and precision to achieve f1-score. Table 3 shows the metrics and description. The results of our experiment are presented in Table 4. The results show using a smartwatch as a new solution can be accurate 99%.
We also did study to compare other research about wearable devices for activity recognition and positioning sensors on the body. In point of view position, waist as the main position, and thigh have been studied in recent years. An accurate activity recognition system that utilizing a triaxial accelerometer on the waist and utilizing KNN for classification have shown 95% to 98% of accuracy [33]. Another study reported an experiment with a single triaxial accelerometer on the chest with 97.9% accuracy [34]. Although the arm position has many movements than the other parts of the body and it can potentially won't be as accurate as other parts but our experiment and comparing it with previous studies show, the arm position as accurate as the other positions, also it has an advantage because it is a comfortable position for attaching a device for elderly and patients.
In point of view IoT and other wearable solutions smartphone is a solution that used many times in previous research, but smartphone should be located on a pocket of shirt or trousers or on the belt for waist position. It is not comfortable for the elderly and patients, and also people don't use a smartphone in every moment such as sleeping. However, we did a similar experiment with a smartphone on the location of the chest that is a more common position for locating sensors, shown in Table 5. Based on the Table 5 chest position offered a high-level accuracy. In our smartwatch experiment, locating the sensors on the arm has a similar result as well as locating on the chest and both demonstrated high-level accuracy for activity recognition. Fig 3 presented differences of f1-score between the smartwatch on the arm and the smartphone on the chest. Therefore, Our result showed using only a smartwatch on arm is a possible position to achieve a high level of accuracy to recognize ADLs. And using the acceleration of the arm, it is the same level of accuracy as well as other places for activity recognition. Other wearables such as smart jewelry or e-tattoo still have not enough power for recognition. A few types of research have been conducted on eshoes to detect fall events but not for other daily activities. Therefore among the IoT wearable solutions, a smartwatch has enough power, it is located on a common and comfortable position and it can be used in every moment even in sleeping, taking a shower or other situations, and smartwatch is an appropriate new IoT solution for human activity recognition.

5.CONCLUSION
In this paper, we considered a smartwatch as an emerging IoT solution in order to recognize human activities. The smartwatch equipped with an accelerometer and it is attached to arm position. The smartwatch as an emerging wearable and the arm position have compared with other solutions and positions. For this purpose, we considered machine learning methods to present reliability of the smartwatch. Our experiment showed almost 99% for accuracy and f1score. The smartwatch has high accuracy and arm position is more comfortable for elderly and patients compared to other solutions. For future work, we plan to gather data of elderlies and other vulnerable people in outdoor, and we will use more common daily activities such as making tea. We would like to improve our work with real-time computing data on wearables such as smartwatch, for real-time responses and helping for elderlies and patients.