PACP: A Position-Independent Activity Recognition Method Using Smartphone Sensors

: Human activity recognition has been a hot topic in recent years. With the advances in sensor technology, there has been a growing interest in using smartphones equipped with a set of built-in sensors to solve tasks of activity recognition. However, in most previous studies, smartphones were used with a ﬁxed position—like trouser pockets—during recognition, which limits the user behavior. In the position-independent cases, the recognition accuracy is not very satisfactory. In this paper, we studied human activity recognition with smartphones in different positions and proposed a new position-independent method called PACP (Parameters Adjustment Corresponding to smartphone Position), which can markedly improve the performance of activity recognition. In PACP, features were extracted from the raw accelerometer and gyroscope data to recognize the position of the smartphone ﬁrst; then the accelerometer data were adjusted corresponding to the position; ﬁnally, the activities were recognized with the SVM (Support Vector Machine) model trained by the adjusted data. To avoid the interference of smartphone orientations, the coordinate system of the accelerometer was transformed to get more useful information during this process. Experimental results show that PACP can achieve an accuracy over 91%, which is more effective than previous methods.


Introduction
Human activity recognition plays a significant role in many fields, especially in health care, disease control, sports and fitness. For example, activity recognition can be utilized for fall detection in the daily life of the elderly [1]. Once a fall is detected, an urgent message will be sent to the hospital or family members for help. It can be also used for estimating the calorie expenditure of activities in quotidian life and providing healthy recommendations for people [2]. Therefore, the ability to identify physical activity automatically and efficiently is necessary.
Existing works on activity recognition are divided into two categories according to the data source: vision-based and sensor-based. Vision-based activity recognition analyzes and recognizes the activity of humans automatically through the video or pictures captured by a fixed camera [3][4][5][6]. Vision-based activity recognition has good performance for an indoor environment; however, it is not widely used due to the high cost and environmental restriction. In addition, it may compromise the user's privacy. The latter category is based on sensors like light sensor, accelerometer, gyroscope and magnetometer to get information from users [7][8][9][10]. Data-mining and machine-learning techniques such as clustering

•
The conversion of a smartphone coordinate system is analyzed and introduced to avoid the influence of smartphone orientation. Orientation is a big challenge during activity recognition.
By coordinate system conversion in the Parameters Adjustment Corresponding to smartphone Position (PACP) method, tri-axial acceleration is transformed to vertical and horizontal acceleration. Vertical and horizontal acceleration are more useful because they can mostly reflect the motion of users. • Sensitive features are analyzed and selected for position recognition before activity recognition. All activities mentioned above and not only walking are studied [22]. Experiments show that these features have good performance.

•
According to the result of position recognition, some adjustments are made to improve the accuracy of activity recognition. Positon of smartphone can provide the information of the device. By adjusting some parameters, the differences between the same activity in different positions can be narrowed down, making activity recognition easier. • Both position recognition and activity recognition are investigated in our paper and all of them have high accuracies.
The remainder of this paper is organized as follows. Some related works are briefly introduced in Section 2. Section 3 explains the design of PACP in detail. Section 4 is the implementation and evaluation of PACP. We also discuss the findings and limitations of PACP in Section 5. Finally, in Section 6, it draws a conclusion of this paper.

Related Work
Many experts and researchers proposed their novel methods for activity recognition with smartphone sensors. Kwapisz et al. asked volunteers to carry a smartphone in their front pant leg pocket to get accelerometer data [23]. There were 43 features generated from the data to train a Information 2016, 7, 72 3 of 18 model for activity recognition and achieved accuracy above 90%. Some novel features were proposed like the time between peaks and binned distribution, but frequency domain features were not contained. The sensor data were also used for user authentication in the literature [24]. Bieber et al. fixed the smartphone in the trouser pocket and improved the capabilities of activity recognition by fusing the information of accelerometer and sound sensor (microphone), since the sounds can provide additional information about the user's situation [25]. However, a microphone brings its own noise and there was no solution to this problem. Kwon et al. also used a specified position with a smartphone in a pant pocket [26]. Unsupervised learning techniques were used for activity recognition with smartphone sensors. In this way, it can solve the problem that researchers have of generating the labels. The method in [26] achieved 90% accuracy but had not researched going upstairs and downstairs, which are common everyday actions. Harasimowicz et al. used the accelerometer in the smartphone to classify eight user activities [27]: walking, sitting, going upstairs, going downstairs, standing, running, lying and even turning. They also investigated the influence of window size during recognition. In the best solution, KNN (k-Nearest Neighbor algorithm) resulted in an accuracy of 98.56%. The just obtained data only from the smartphone's location in a trouser pocket, which limits the position. In addition, they did not describe the issue of smartphone orientation. Ustev et al. presented their algorithm of human activity recognition using the accelerometer, gyroscope and magnetic field sensors in smartphone [18]. They studied the challenges of users, device and device orientation. To avoid the impact of device orientation, they converted the coordinate system of the smartphone to earth's magnetic coordinate system with the magnetic field vector. Experiments showed that their method works well. Shoaib et al. recognized complex human activity using both smartphone and wrist-worn motion sensors like a smartwatch [28]. Data from a smartphone in the right trouser pocket and a smartwatch on the right wrist were studied separately and combined to show the recognition performance. Their method could classify complex activities like smoking and talking but position and orientation of the smart device was also limited. All of these studies set the position of the smartphone in a fixed way for activity recognition and most of them obtained high accuracy. However, in reality, users usually do not fix their smartphone in one place.
When considering the orientation and position of the smartphone, the task becomes harder. Henpraserttae et al. conducted six daily activities with a smartphone in 16 different orientations and three different positions to study the influence of orientation and position [29]. They used a projection-based method to handle the various device orientations, but for positions, they used position-insensitive features to build models for each positon. Activity recognition in some positions had a low accuracy. Grokop et al. considered the variety of smartphone position [30]. They fused the data of the accelerometer, ALS (Ambient Light Sensor), proximity sensor and camera intensity to generate a tuple (motion state, device position) and, in this way, classified the motion states and device positions with the accuracies of 92.6% and 66.8%, respectively. Using more sensors might improve the accuracy while it could consume more resources of the smartphone. Moreover, this method also did not research going upstairs and downstairs which is similar to walking. Coskun et al. proposed a novel way to classify the position and activity by using solely an accelerometer. They recognized positions with angular acceleration to improve the position recognition accuracy but its activity recognition accuracy achieved only 85% [21]. Miao et al. placed smartphones in the two front and back pockets on the trousers and two front pockets on the coat for physical activity recognition [20]. They first used the light and proximity sensors to judge whether the smartphone was in the pocket or not; if so, then they collected raw data and extracted features which are insensitive to orientation and position for training models. Finally, they chose decision tree which has the best performance for classification and recognition. The resource of the smartphone can be saved by choosing the suitable situation to collect data and the recognition accuracy reached 89.6%. The method can deal with the smartphone orientation and position well but hand and bag were not considered in their study. In [19], Gu et al. explored the user-independent motion recognition using smartphone sensors. Different positions such as the trouser pocket, as well as holding with or without a swinging motion were studied during Information 2016, 7, 72 4 of 18 activity recognition. The barometer, which is newly embedded in the latest smartphones such as the iPhone 6, were used; the pressure derivatives captured by the barometer data can easily distinguish vertical activity from others. In order to improve the accuracy, the history results of activity recognition were utilized to make a decision and the final overall accuracy of different positions was 89.21%. Their method showed the good performance for activity recognition, but barometer is not a common sensor in most smartphones.
Fixed smartphone position during activity recognition will restrict the activity of users. As mentioned above, the performance of activity recognition needs to be improved by considering different positions. In this paper, the focus is on the influence of the position of the smartphone and use of the available information to improve activity recognition performance, which have not yet been taken into account.

The Design of PACP (Parameters Adjustment Corresponding to Smartphone Position)
The flowchart of the proposed activity recognition method, PACP, is shown in Figure 1. Similar to previous works [18][19][20][21][22], activity recognition can be divided into four steps: data collection, preprocessing, feature extraction and recognition. Firstly, raw data of smartphone sensors should be collected from users. In this paper, only accelerometer and gyroscope data are collected which are enough for recognition. The magnetic field sensor information has been discarded because it is strongly affected by the environment and is sometimes at risk of losing the data. Then PACP performs some operations to convert the smartphone coordinate system to a vertical and horizontal system with the accelerometer data in the preprocessing process. The raw data collected are formed into a data stream. The stream is separated with sliding windows to get some short time series data. After preprocessing, features are extracted from the segmentations. In contrast to previous studies, PACP first identifies the position of the smartphone, instead of recognizing the activity directly. For position recognition, position-sensitive features are selected, and then a decision tree-which proved to have a good performance in most previous works [19,20]-is trained for recognition. According to the result of position recognition, features extracted from acceleration are adjusted with a position parameter to improve the activity recognition accuracy. Finally, PACP constructs an SVM (Support Vector Machine) [31,32] model with adjusted features for activity recognition. PACP emphasizes the impact of smartphone position and characteristics of activities in different positions which is different from previous studies. As mentioned above, four positions (coat pocket, hand, trouser pocket and bag) and five activities (going upstairs, going downstairs, walking, running and standing) are studied in our work. In addition, six machine-learning algorithms are explored to find the best model for activity recognition. improve the accuracy, the history results of activity recognition were utilized to make a decision and the final overall accuracy of different positions was 89.21%. Their method showed the good performance for activity recognition, but barometer is not a common sensor in most smartphones. Fixed smartphone position during activity recognition will restrict the activity of users. As mentioned above, the performance of activity recognition needs to be improved by considering different positions. In this paper, the focus is on the influence of the position of the smartphone and use of the available information to improve activity recognition performance, which have not yet been taken into account.

The Design of PACP (Parameters Adjustment Corresponding to Smartphone Position)
The flowchart of the proposed activity recognition method, PACP, is shown in Figure 1. Similar to previous works [18][19][20][21][22], activity recognition can be divided into four steps: data collection, preprocessing, feature extraction and recognition. Firstly, raw data of smartphone sensors should be collected from users. In this paper, only accelerometer and gyroscope data are collected which are enough for recognition. The magnetic field sensor information has been discarded because it is strongly affected by the environment and is sometimes at risk of losing the data. Then PACP performs some operations to convert the smartphone coordinate system to a vertical and horizontal system with the accelerometer data in the preprocessing process. The raw data collected are formed into a data stream. The stream is separated with sliding windows to get some short time series data. After preprocessing, features are extracted from the segmentations. In contrast to previous studies, PACP first identifies the position of the smartphone, instead of recognizing the activity directly. For position recognition, position-sensitive features are selected, and then a decision tree-which proved to have a good performance in most previous works [19,20]-is trained for recognition. According to the result of position recognition, features extracted from acceleration are adjusted with a position parameter to improve the activity recognition accuracy. Finally, PACP constructs an SVM (Support Vector Machine) [31,32] model with adjusted features for activity recognition. PACP emphasizes the impact of smartphone position and characteristics of activities in different positions which is different from previous studies. As mentioned above, four positions (coat pocket, hand, trouser pocket and bag) and five activities (going upstairs, going downstairs, walking, running and standing) are studied in our work. In addition, six machine-learning algorithms are explored to find the best model for activity recognition.

Coordinate System Conversion
During data collection, raw tri-axial accelerometer and tri-axial gyroscope data are acquired from users' smartphones for further activity recognition. The accelerometer measures velocity over time along three axes and the gyroscope measures the rate at which a device rotates around each of the three spatial axes. Acceleration data can reflect the state of motion and gyroscope data can reflect the state of the smartphone. However, as shown in Figure 2a, these data are relative to the coordinate system of the smartphone, and once the device orientation changes, the data of accelerometer and gyroscope will change too. That is to say, if users hold a smartphone in different orientations, the acceleration would change even if they are doing the same thing in the same way, thereby creating large problems for activity recognition. To avoid the impact of device orientation, the coordinate system is converted into vertical and horizontal directions to get more useful information in PACP. The acceleration of smartphone is transformed from tri-axial accelerations to vertical and horizontal accelerations. Instead of using magnetic field sensor data like [18], the task is done by using accelerometer only. Nowadays, developers do not need to filter the acceleration data to remove the gravity in three axes because they can get gravity and user acceleration separately [33]. As we all know, the gravity points toward the center of the Earth, so the user's acceleration can be decomposed into two parts: one of them points toward the center of the Earth (like gravity) and the other is perpendicular to it. The angle between gravity and user's acceleration can be calculated first, then user's acceleration can be divided into vertical and horizontal acceleration easily using projection as follow: where θ is the angle between gravity and user's acceleration. A gx , A gy and A gz represent the gravity in X, Y and Z axes. A ux , A uy and A uz represent the user's acceleration in three axes, respectively. A v and A h are the vertical and horizontal user accelerations. The conversion process is shown in Figure 2b. By coordinate transformation, acceleration generated by users is converted to vertical and horizontal accelerations. These accelerations are only related to the users' activities, which are not affected by smartphone orientation.

Coordinate System Conversion
During data collection, raw tri-axial accelerometer and tri-axial gyroscope data are acquired from users' smartphones for further activity recognition. The accelerometer measures velocity over time along three axes and the gyroscope measures the rate at which a device rotates around each of the three spatial axes. Acceleration data can reflect the state of motion and gyroscope data can reflect the state of the smartphone. However, as shown in Figure 2a, these data are relative to the coordinate system of the smartphone, and once the device orientation changes, the data of accelerometer and gyroscope will change too. That is to say, if users hold a smartphone in different orientations, the acceleration would change even if they are doing the same thing in the same way, thereby creating large problems for activity recognition. To avoid the impact of device orientation, the coordinate system is converted into vertical and horizontal directions to get more useful information in PACP. The acceleration of smartphone is transformed from tri-axial accelerations to vertical and horizontal accelerations. Instead of using magnetic field sensor data like [18], the task is done by using accelerometer only. Nowadays, developers do not need to filter the acceleration data to remove the gravity in three axes because they can get gravity and user acceleration separately [33]. As we all know, the gravity points toward the center of the Earth, so the user's acceleration can be decomposed into two parts: one of them points toward the center of the Earth (like gravity) and the other is perpendicular to it. The angle between gravity and user's acceleration can be calculated first, then user's acceleration can be divided into vertical and horizontal acceleration easily using projection as follow: where θ is the angle between gravity and user's acceleration. Agx, Agy and Agz represent the gravity in X, Y and Z axes. Aux, Auy and Auz represent the user's acceleration in three axes, respectively. Av and Ah are the vertical and horizontal user accelerations. The conversion process is shown in Figure 2b.

Position Recognition
The raw data from a smartphone are data streams. In order to extract features, these data are divided into various segmentations. A set of features such as mean, variance, correlation coefficient, zero crossing rate, maximum, etc. are calculated from these segmentations for recognition. To identify the positions efficiently, PACP chooses some features that are sensitive to position.

Selection of Sensitive Features
We use walking activity as a sample to explain these features. Figure 3 shows the walking waveforms of tri-axial gyroscope and user acceleration in vertical and horizontal orientations with a smartphone in four positions. It is obvious that the waveforms of the tri-axial gyroscope are different in the four positions. For example, when the smartphone is in a user's hand, the changes of the gyroscope in three axes are gentle, whereas they are intense when placed in the user's pockets. It is easy to understand why: When holding the smartphone in their hands, people either make it stationary relative to the body or swing it along with the arm while walking as per the user's habits. The change rate of the gyroscope is smaller in hand than in other positions. When the smartphone is in the trouser pocket, the change rate is high. By coordinate transformation, acceleration generated by users is converted to vertical and horizontal accelerations. These accelerations are only related to the users' activities, which are not affected by smartphone orientation.

Position Recognition
The raw data from a smartphone are data streams. In order to extract features, these data are divided into various segmentations. A set of features such as mean, variance, correlation coefficient, zero crossing rate, maximum, etc. are calculated from these segmentations for recognition. To identify the positions efficiently, PACP chooses some features that are sensitive to position.

Selection of Sensitive Features
We use walking activity as a sample to explain these features. Figure 3 shows the walking waveforms of tri-axial gyroscope and user acceleration in vertical and horizontal orientations with a smartphone in four positions. It is obvious that the waveforms of the tri-axial gyroscope are different in the four positions. For example, when the smartphone is in a user's hand, the changes of the gyroscope in three axes are gentle, whereas they are intense when placed in the user's pockets. It is easy to understand why: When holding the smartphone in their hands, people either make it stationary relative to the body or swing it along with the arm while walking as per the user's habits. The change rate of the gyroscope is smaller in hand than in other positions. When the smartphone is in the trouser pocket, the change rate is high. In addition, there are also differences in users' horizontal acceleration. According to Figure 3, it always has a higher value in the hand and the trouser pocket than the coat pocket and bag because of the movement of users' hands and legs. The value changes smoothly when the smartphone is in  In addition, there are also differences in users' horizontal acceleration. According to Figure 3, it always has a higher value in the hand and the trouser pocket than the coat pocket and bag because of the movement of users' hands and legs. The value changes smoothly when the smartphone is in the coat pocket. If the smartphone is in hand or trouser pocket, the dispersion degree of users' horizontal acceleration is different. It can be used to distinguish these two positions.
Considering these factors, eight related features are chosen for position recognition: • The max value of vertical and horizontal acceleration • The max value of gyroscope (three axes) • The max value of change rate of the gyroscope of three axes • The standard deviation of horizontal acceleration • The mean of the angles between gravity and user acceleration • The range of horizontal acceleration.

Model Selection
According to the features described above, PACP constructs a decision tree to identify the positions of the smartphone. Decision tree is a classification and prediction model which represents the mapping mode between the feature vectors and object. It structures a binary tree by partitioning the attributes' values and pruning according to the training set. It is easy to implement and understand the decision tree. In previous work such as [20], it also achieved good performance.

Activity Recognition
The goal of PACP is to identify activity effectively. The accuracy can be improved after the smartphone position is known. It chooses some features that are insensitive to position and adjusts some other features to reduce the influence of the position.  the coat pocket. If the smartphone is in hand or trouser pocket, the dispersion degree of users' horizontal acceleration is different. It can be used to distinguish these two positions. Considering these factors, eight related features are chosen for position recognition: • The max value of vertical and horizontal acceleration • The max value of gyroscope (three axes) • The max value of change rate of the gyroscope of three axes • The standard deviation of horizontal acceleration • The mean of the angles between gravity and user acceleration • The range of horizontal acceleration.

Model Selection
According to the features described above, PACP constructs a decision tree to identify the positions of the smartphone. Decision tree is a classification and prediction model which represents the mapping mode between the feature vectors and object. It structures a binary tree by partitioning the attributes' values and pruning according to the training set. It is easy to implement and understand the decision tree. In previous work such as [20], it also achieved good performance.

Activity Recognition
The goal of PACP is to identify activity effectively. The accuracy can be improved after the smartphone position is known. It chooses some features that are insensitive to position and adjusts some other features to reduce the influence of the position.     As mentioned above, horizontal acceleration has obvious differences which are used for position recognition. If the differences of horizontal acceleration become smaller, the accuracy of activity might become higher. PACP therefore adjusts the horizontal acceleration before activity recognition. Because of the good performance of gyroscope data in reflecting the position information of smartphone, they are chosen to get a parameter for adjusting. The value should reflect the intensity of those activities in each position. The average value of the resultant gyroscope, the average value  As mentioned above, horizontal acceleration has obvious differences which are used for position recognition. If the differences of horizontal acceleration become smaller, the accuracy of activity might become higher. PACP therefore adjusts the horizontal acceleration before activity recognition. Because of the good performance of gyroscope data in reflecting the position information of smartphone, they are chosen to get a parameter for adjusting. The value should reflect the intensity of those activities in each position. The average value of the resultant gyroscope, the average value of the max value of gyroscope in three axes, as well as other values are calculated to test which one is best. Finally, the average value of the maximum change rate of the gyroscope in three axes is chosen as the position parameter for each position because it can reflect the position information best. PACP first computes the maximum change rate of the gyroscope in three axes of each sample and then calculates the average value of the rate of each position as a parameter. PACP describes it as α. These data α can reflect the intensity degree of movement in four positions which show that the trouser pocket has the highest score. The parameters are computed to adjust the horizontal acceleration in each position with Equation (4). This equation can narrow the differences of the horizontal acceleration between different positions. By doing so, features can reflect the characteristics of activities better. The adjusted value of horizontal acceleration is also used to calculate the resultant acceleration.

Feature Selection and Feature Adjustment
Finally, nine features, which are extracted from adjusted accelerometer data and used for activity recognition, are described in Table 1.

Model Selection
Model selection is also an important factor of activity recognition. An appropriate model can save time and get a satisfactory accuracy. In this paper, we studied six kinds of machine-learning algorithms, which are Random Forest, Decision Tree, SVM (Support Vector Machine) [34], KNN (k-Nearest Neighbor) [16], Naive Bayes [20] and Discriminant Analysis. These algorithms are widely used in activity recognition and are always efficient. In PACP, we evaluate the recognition performance of each algorithm (details in Section 4). According to the experimental result, PACP chooses the SVM model, which has the best performance, for activity recognition.
SVM is a supervised learning model that is commonly used for pattern recognition, classification and regression analysis. It usually analyzes and solves linearly separable problems. For linearly non-separable cases, it uses a mapping algorithm to transform the linearly non-separable samples into high dimensional feature space and find a hyperplane for classification or regression. The objective function and associated constraints of SVM can be described as follows: Information 2016, 7, 72

of 18
The hyperplane is defined by ω T + b = 0. ω is the parameters matrix to define decision boundary between classes. T represents transpose of matrix. X is the samples. b is the intercept associated with decision boundary. C is a regularization parameter and ξ i is the slack variable to solve the problem of an outlier. y i is the class of ith sample. The Equations (6) and (7) describe constraints of Equation (5). Equation (5) consists of two terms. The first one is maximizing the margin between classes and the other is balancing the errors with C. The Equation (6) ensures the existence of a margin, and Equation (7) restricts the noise and specific points to make them linearly separable. When dealing with the linearly non-separable, it uses a kernel function to transform the samples into higher dimensional space. There are many available kernel functions including linear kernel function, quadratic kernel function, polynomial kernel function, radial basis function, multi-layer perceptron and so on.

Implementation and Evaluation
In this section, we present the implementation and evaluation of PACP. We first introduce the data collection platform of our experiment, then demonstrate the effectiveness of position recognition and activity recognition respectively in detail.
We evaluate the performance of PACP by Accuracy, Precision and Recall. They are defined as follows: where TP means true positive or the number of correctly classified as a positive example. TN is true negative. TP + TN represents the number of samples that are correctly classified and P + N represents the total number of samples. Generally speaking, if the Accuracy is higher, the classifier will be better. In Equation (9)

Data Collection
We designed and developed an iOS app to collect raw accelerometer and gyroscope data from users, as shown in Figure 5. Ten volunteers, i.e., six males and four females, aged between 23 and 27 years old, were invited to place the smartphone in the coat pocket, hand, trouser pocket and bag, respectively. They carried out a series of activities including going upstairs, going downstairs, walking, running and standing. Each activity was required to last 2 min. During this process, the volunteers are allowed to place the smartphone in different orientations with their habits. The sampling frequencies of the accelerometer and gyroscope sensor data were both 32 Hz which would not bring the burden to CPU. To avoid the noise and the impact of the start and end of the activity, 0.5 minutes of data were cut off from the beginning and end of data stream, respectively; only 1 minute of data in the middle was left. For going upstairs or downstairs, more useless data were also cut off. These data were transmitted from the smartphone to the server through the network for further processing and analysis.
On the server which was a PC (Personal Computer), PACP preprocessed the raw data collected from volunteers. The sliding window technique was used to split the data stream into short segments. According to the research of [19], when the window size reaches 64, it obtained the best performance. PACP finally adopted 64 as the window size with 50% overlap to segment the sensor data. In this way, 2 s of data were dealt with for each time. Features were extracted from these segmentations for recognition. allowed to place the smartphone in different orientations with their habits. The sampling frequencies of the accelerometer and gyroscope sensor data were both 32 Hz which would not bring the burden to CPU. To avoid the noise and the impact of the start and end of the activity, 0.5 minutes of data were cut off from the beginning and end of data stream, respectively; only 1 minute of data in the middle was left. For going upstairs or downstairs, more useless data were also cut off. These data were transmitted from the smartphone to the server through the network for further processing and analysis.

Evaluation of Position Recognition
In Section 3, the method of position recognition was introduced in detail, including the transformation of the coordinate system as well as feature extraction. Features were extracted from the segmentations to generate sample feature vectors. During recognition, the four-fold cross-validation approach was used. The samples of all datasets are divided into four. Each time, one fold of these samples was treated as a test set and the rest were treated as a training set. The process is repeated four times and the average value is used for evaluation. A decision tree model was built for position recognition. Table 2 shows the confusion matrix of position recognition. From the confusion matrix, we can find that features that PACP extracted are effective and PACP can achieve an accuracy of 93.76% in the position recognition process. It is easy to distinguish the position especially when the smartphone is held in the trouser pocket. There are also some samples that are not correctly identified, because there are also standing samples in our dataset. Standing samples are difficult to distinguish for the positions.
In [35], Incel presented a novel method for position recognition. Features extracted from accelerometer were investigated and proved to be enough for position recognition. Three datasets, which are collected from different positions during different activities, were studied and the method achieved a good performance. We extracted all motion-related, orientation-related and rotation-related features described in [35] and tested them in our dataset. The performance is shown in Table 3. It shows that PACP has a better performance.
The accuracy of PACP is a little higher than Incel's method because PACP combined gyroscope with acceleration for position recognition. As described in Section 3, PACP identified five activities after adjusting the features according to the results of position recognition. The standard of adjustment is as in Equation (4). For choosing the suitable parameter as α, PACP calculated four values for selection and finally chose the best one with decision tree. Table 4 shows the result of comparison between different values. The average of maximum change rate of gyroscope was selected as α according to the result. In this paper, the experiment values of α are 2.8149 for the coat pocket, 1.0912 for hand, 3.4647 for the trouser pocket and 2.0351 for bag respectively. The trouser pocket has the highest value which means the movement in this position is the most active.
With the adjusted feature vectors, six kinds of machine-learning algorithms were used (including Random Forest, Decision Tree, SVM, KNN, Naive Bayes and discriminant analysis) to research the influence of models. For SVM, PACP used LIBSVM (A Library for Support Vector Machines) [36] for multi-classification problems and calculated the best parameters with the grid search method. The final parameters in LIBSVM are as follows: radial basis function for kernel function type, 32 for regularization parameter and 0.25 for gamma in kernel function. The accuracy results of these algorithms are shown in Figure 6. the suitable parameter as α, PACP calculated four values for selection and finally chose the best one with decision tree. Table 4 shows the result of comparison between different values. The average of maximum change rate of gyroscope was selected as α according to the result. In this paper, the experiment values of α are 2.8149 for the coat pocket, 1.0912 for hand, 3.4647 for the trouser pocket and 2.0351 for bag respectively. The trouser pocket has the highest value which means the movement in this position is the most active.
With the adjusted feature vectors, six kinds of machine-learning algorithms were used (including Random Forest, Decision Tree, SVM, KNN, Naive Bayes and discriminant analysis) to research the influence of models. For SVM, PACP used LIBSVM (A Library for Support Vector Machines) [36] for multi-classification problems and calculated the best parameters with the grid search method. The final parameters in LIBSVM are as follows: radial basis function for kernel function type, 32 for regularization parameter and 0.25 for gamma in kernel function. The accuracy results of these algorithms are shown in Figure 6.
It illustrates that Random Forest and SVM model showed better performance than other classifiers with accuracies of 91.06% and 91.27%. From the diagram, it is obvious that all the models obtain high accuracies. It shows the good performance of the features we chose. Finally, SVM-which has the highest recognition accuracy-was chosen for activity recognition in this paper. Table 5 shows the confusion matrix of activity recognition with SVM.
PACP can distinguish running and standing from other states easily because they have big differences in vertical acceleration. Since the acceleration characteristics are similar for going upstairs, going downstairs and walking, it is usually hard to identify the three states correctly. Our work can achieve a comparatively higher accuracy than previous work. If we just consider identifying these three activities, the accuracy is about 86% which is comparatively high.
In order to show that our method is position-independent, we also discuss the accuracy of activity recognition in different positions: the coat pocket, hand, trouser pocket and bag positions mentioned in our paper. Table 6 describes the results of activity recognition accuracy.  It illustrates that Random Forest and SVM model showed better performance than other classifiers with accuracies of 91.06% and 91.27%. From the diagram, it is obvious that all the models obtain high accuracies. It shows the good performance of the features we chose. Finally, SVM-which has the highest recognition accuracy-was chosen for activity recognition in this paper. Table 5 shows the confusion matrix of activity recognition with SVM. PACP can distinguish running and standing from other states easily because they have big differences in vertical acceleration. Since the acceleration characteristics are similar for going upstairs, going downstairs and walking, it is usually hard to identify the three states correctly. Our work can achieve a comparatively higher accuracy than previous work. If we just consider identifying these three activities, the accuracy is about 86% which is comparatively high.
In order to show that our method is position-independent, we also discuss the accuracy of activity recognition in different positions: the coat pocket, hand, trouser pocket and bag positions mentioned in our paper. Table 6 describes the results of activity recognition accuracy. When the smartphone was placed in coat pocket and hand, the activity recognition accuracy was higher. The reason is that, in the coat pocket, the horizontal acceleration is small and when the smartphone is held in hand, people usually swing their arms with their body. Different people may have their own style which brings difficulty for recognition. After the adjustment of PACP, this problem is improved. Generally speaking, each position has good performance. PACP proposed in this paper can avoid the influence of smartphone positions effectively.

Comparison
To prove the effectiveness of PACP, some contrast experiments were carried out in this paper. An SVM model was built and tested utilizing four-fold cross-validation with unadjusted features just like PACP. The accuracy is used to show the improvement by adjusting the features. It is shown in Figure 7 that the accuracy was improved by about 1.3 points on average.
Miao's method in [20] also studied activity recognition with smartphone sensors. The impact of both smartphone position and orientation were also researched in their paper. The activities they recognized including remaining static, walking, running, walking upstairs and walking downstairs similar to PACP. They presented some insensitive features to avoid the influence of smartphone position and orientation and finally built a decision tree for activity recognition. Considering the dataset and the good performance of their method, we implemented the algorithm they proposed in our dataset and compared the final performance with PACP in Table 7.

Comparison
To prove the effectiveness of PACP, some contrast experiments were carried out in this paper. An SVM model was built and tested utilizing four-fold cross-validation with unadjusted features just like PACP. The accuracy is used to show the improvement by adjusting the features. It is shown in Figure 7 that the accuracy was improved by about 1.3 points on average. Miao's method in [20] also studied activity recognition with smartphone sensors. The impact of both smartphone position and orientation were also researched in their paper. The activities they  Comparing to Miao's method, PACP has a better performance. Miao's method focused on insensitive features to deal with the smartphone position and orientation, but PACP not only considered the insensitive features but also adjusted the difference between positions. The position information was used to improve the activity recognition performance, proving to be very effective.

Discussion
In PACP, the position information was used to improve the accuracy of activity recognition. Four positions and five activities were studied during this process. By coordinate system conversion in Section 3.1, the impact of orientations can be avoided. Change rate of gyroscope and horizontal acceleration were found to be sensitive to positions and used for classifying smartphone position. Adjustment according to the result of position proved to be very effective in PACP because the accuracy was improved by about 1.3 points. However, there are some limitations in PACP too. The adjustment is based on the result of position recognition. Because accuracy of position activity is not 100%, some data from different positions could be mistakenly classified into a particular position. In PACP, the position accuracy is about 94%. It is satisfied and can be improved in the future. The adjustment of horizontal acceleration is utilized to narrow the difference between the same activity in different positions, it can achieve this goal in PACP.

Conclusions
In this study, we presented a novel method called Parameters Adjustment Corresponding to smartphone Position (PACP) for position-independent activity recognition with smartphone sensors. Accelerometer and gyroscope, which are available for most smartphones, were chosen as sensors to study. Raw data were collected from users using an iOS app. Transforming raw acceleration data from smartphone coordinate system to vertical and horizontal accelerations can avoid the influence of orientations of smartphone. The change rate of gyroscope, horizontal accelerations and some other features were found sensitive to positions. The final accuracy of position recognition is up to 93.76% with four-fold cross-validation, which is relatively high. With the information of smartphone position, PACP adjusted horizontal acceleration data using position parameter. It narrowed the difference between the same motion in different positions. Experimental results show that the recognition accuracy of PACP is up to 91.27% using four-fold cross-validation, which is greatly improved by about 1.3 points compared to the unadjusted method. It proves that PACP is effective. We mainly considered the impact of smartphone position and studied five activities in this paper. In future work, more factors will be considered, such as the group of users. The elderly, for example, may have different movement patterns than young people. Power consumption is also an important factor. We will consider adjusting the sampling frequency dynamically to reduce energy consumption. In addition, we will try to study some more activities in the future.