{'fraction_non_alphanumeric': 0.02340129749768304, 'fraction_numerical': 0.007568736484399135, 'mean_word_length': 4.729424778761062, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Elderly Fall Detection and Fall Direction Detection via Various Machine Learning Algorithms Using Wearable Sensors

The world population is aging rapidly. Some of elderly person live alone and it is observed that the elderly who live with their families frequently have to stay at home alone. Especially during the working hours of adult members of the family, elderly member stays alone. Falling while alone at home often results in fatal injuries and even death in elderly individuals. Fall detection systems can detect falls and provide emergency healthcare services in a short time. In this study, a two-step fall detection and fall direction detection system has been developed by using a public dataset with 5 different machine learning algorithms comparatively. If a fall is detected in the first stage, the second stage is started to determine the direction of the fall. In this way, the direction of fall can be determined for elderly individual to be used in future researches, and an early warning system that enables necessary measures such as opening an airbag in the direction of the fall can be developed. Thus, a gradual fall and its direction detection system has been developed by determining the best classifying algorithms. As a result, it has been determined that Ensemble Subspace k-Nearest Neighbor (ES k-NN) classifier performs a little more successful classification compared to other classifiers. The classification by using the test data which is corresponding to 30% of the total data that was never used during the training phase, has been performed 99.4% accuracy for fall detection, and 97.2% success has been achieved in determining the direction of falling.


INTRODUCTION
To develop a fall detection system, collected data during past falls are needed. Since falls are very rare cases compared to ADLs, it is not possible to wait for real falls and record at the time of the fall. For this reason, data of artificial falls performed by the subjects are used during the development of fall detection systems. Although it is not possible to imitate real falls by the subjects, it is possible to obtain realistic results with this method. Most of the researchers present the fall data they collect during their studies for the use of other researchers as a public dataset. These public datasets differ in terms of the number of subjects, the number and variety of falling movements and ADLs, the number of repetitions of the movements and the sensor types. What is common to all of this dataset is that the fall experiments performed only by adult subjects. Since it is risky to perform a fall test with elderly subjects, there is no study that collects and shares fall data from individuals over the age of 65. Although there are differences between the fall dynamics of young people and elderly people, it is thought that this does not significantly affect the success of the system. The SisFall dataset shared publicly in 2017 is one of the most detailed datasets in the literature (Sucerquia, López and Vargas-Bonilla, 2017). This dataset was created with data from 2 accelerometers and 1 gyroscope. Most of the studies using this dataset do the fall recognition process as binary (fall/ADL) ( ADLs and made the classification in a way to determine the type of fall. In the study using Decision Tree (DT), an accuracy of about 92% was obtained (Yacchirema et al., 2018). In Liu et al.'s study, the effect of sampling rate on success was investigated and classification was made as binary fall/non-fall (Liu et al., 2018). Hussain et al. first classified the movements as binary fall/ADL, and if the result was fall, they tried to find out which type of fall it was. All fall types were included in this study, and the effects of sensor types were investigated by using them individually or together. As a result, the highest classification success was obtained using the Random Forest (RF) classifier when all sensors were used (Hussain et al., 2019). Some researchers used multiple datasets, trained using one dataset and tested by using the other one (Kruptizer et al., 2018; Delgado-Escaño et al., 2020).
In this study, 34 types of ADLs and falls are classified as binary using SisFall dataset. Then the direction of the fall is determined for the movements identified as falling. Thus, an approach suitable for obtaining informati-studies try to specifically determine the type of fall, some of them make a determination of whether there is a fall or no fall in binary. However, the important thing in daily life is to quickly detect a fall and to determine the direction of the fall and to take precautions against hitting the hard floor if possible. The main goal here is to perform fall detection and fall direction detection quickly and with high accuracy. In this study, first fall detection is performed, then the fall direction is determined if a fall is detected in first stage. This is first in the literature by using the SisFall dataset. Thus, protective measures such as deploying an airbag in the direction of fall can be developed in future studies.
The following parts of the article are structured as follows. In Chapter 2, previous studies using the SisFall dataset are reviewed. In Chapter 3, the dataset is introduced and the method used in this study is explained. In Chapter 4, the results of the study are examined. In Chapter 5, a conclusion is made.  Gupta et al., 2020). However, it is known that systems working with this method are rejected by elderly individuals. The reason for this is the violation of privacy and the fact that these systems can only work within a certain area and cannot detect falls that occur outside the building or in another room of the house. On the other hand, Multimodal Fall Detection Systems are methods that aim to increase accuracy by using information from both wearable sensors and cameras.  life and the artificial falls performed by the subject who knows that he fakes a falling movement. However, it seems impossible to create a dataset consisting of spontaneous falls, as the frequency of falling spontaneously in daily life is not high. In the evaluation of a dataset to be used in the detection of falls under these conditions, it is necessary to pay attention to the following.

RELATED WORK
• Possible movements should be done by elderly people. The extremity movement speeds of the elderly and young people show great differences while doing their daily living activities. If the dataset is created with young subjects and the system is used on elderly individuals, the accuracy of fall detection will decrease.
• The type of movements should be diverse in a way that matches the daily life as much as possible. while creating the dataset, if the selected movements are not frequently used in daily life, the algorithm that gives good results in the computer environment may result erroneous inferences for real-life.
• The number of repetitions for the movements in the dataset should be high. As a result, the success of the created system is directly proportional to the quality of the dataset. The more diverse and multiple trials the dataset contains, the higher the classification success of the movements will be.
• In order to increase the success in terms of classification, the dataset should be balanced both as ADL/Fall and for each ADL and fall. Because a well-balanced training set eliminates bias of the classifier toward particular class due to over-representation or under-representation of input patterns belonging to those classes (Nath & Subbiah, 2018).
• The movements should be done by using various individuals in terms of gender, height and weight. Because the physiological structure of a person significantly affects the speed and acceleration of movement.
• It should be ensured that the subject is not affected of the negative physiological effects that may occur as a result of the fall, especially when falling movements are made, but to ensure this, the measures to be taken in the experimental area must be in a way that does not disturb the characteristics of the fall.
When the public datasets are examined under these conditions, it is seen that SisFall dataset is one of the most comprehensive datasets available in the literature. Sucer on about how the elderly individual made falls and what their movements are before and after the fall is developed. Thus, a classifier is created that can be used in studies such as preventing falls, taking precautions and giving a warning in case of a fall possibility based on previous activities. The classification is performed with 5 different machine learning algorithms and the most successful classification results are obtained with ES k-NN classifier in both stages. In the classification using the 30% (testing) part of the data, which is not used in the training phase, the fall detection is performed with 99.4% accuracy, while the direction of the falls is detected correctly at a rate of 97.2%. These results coincide with the results of studies in the literature that detect falling binarily. As far as we know, this study is the first study in the literature that aims to determine the direction of falling and it does this with a high accuracy rate.

METHODS
The proposed method in this study is a two-step method. First step is determining whether the activity is a falling or not. When the real-time application is started, the information received from the sensors will be processed in short window intervals and if it indicates a fall, the direction of the rapid fall will be determined. Thus, it will be possible to take a precaution for the falling elderly person. The block diagram of the method is given in Fig. 2.

Dataset
In the literature, there are public datasets containing various sensor and camera data prepared by different researchers. It is seen that almost all of these datasets consist of artificial falls and ADLs performed by young subjects (Casilari, Santoyo-Ramón, & Cano-García, 2017; Riquelme, Espinoza, Rodenas, Minonzio, & Taramasco, 2019). The body dynamics of the elderly and young individuals show great differences during the activities. However, it is not possible to perform the fall experiments by elderly subjects. So, it is a necessity to use the data obtained from the younger subjects. Likewise, there are serious dynamic differences between the real falls that occur in daily This dataset contains data from two 3-axis accelerometers and one 3-axis gyroscope. The dataset, which consists of 38 participants, consisting of young and old individuals, includes 15 different falling movements and 19 types of ADLs. It is seen that almost every movement was repeated 5 times by the participants. While creating the dataset, the sensor information was recorded with frequency of 200 Hz. The dataset content is shown in Table 1.

Pre-processing
Pre-processing is an important step that directly affects the success of the classification. When the SisFall dataset is examined structurally, it is a smooth dataset that does not require much preprocessing. No noisy results were obtained thanks to low frequency data collection.
In this study, only the activity duration was equalized in the preprocessing stage. All activities are divided into 12-second windows. Thus, activities such as walking and jogging were divided into parts and 8 separate samples were created from each trial.

Feature Extraction
In the next step, feature extraction is applied to extract more meaningful data from raw data. Thus, better characterization of each activity is provided. While choosing the features, the literature was examined and, the features that were used more frequently in previous studies during fall detection were determined. By examining the features in terms of computational complexity, the ones with high contribution/computational cost ratio were preferred. In Table 2, these features are given with their explanations. Here, μ present the mean value, N presents the number of elements, x presents the i th element, σ presents the standard deviation, s presents the sum, g 2 presents the kurtosis, g 1 presents the skewness and rms presents the root mean square. The features are extracted from each three axes of each three sensors, so that a total of 99 features for each observation are obtained.
Finally, the extracted features are brought to a common scale and normalized between -1 and 1. Thus, it was tried to take into account the small differences in the data depending on the used algorithm.

Fall Detection
In general, the movement speed of the body of the individual increases suddenly during a fall. This situation makes it possible to detect the fall by creating strong changes on the accelerometer connected to the individual's body. However, there are also movements with velocity changes close to the falling state in ADLs. This confusion is the main shortcoming of fall detection systems that are intended to be made only with accelerometer data. Therefore, in this study, gyroscope sensor is used together with accelerometer in order to detect angular change.
During the fall detection phase, binary classification is made, observations are divided into two groups Fall An SVM algorithm tries to obtain the hyperplane that best distinguishes between classes. This hyperplane is achieved by obtaining the largest margin between the classes. SVM is a computer algorithm that learns by example to assign labels to objects. At its core, an SVM is a mathematical entity and an algorithm for maximizing a particular mathematical function relative to a particular collection of data. There are 4 basic concepts at the core of the SVM classification; (i) separating hyperplane, (ii) hyperplane with maximum margin, (iii) soft margin, and (iv) kernel function. The general term for a straight line in a high-dimensional space is a hyperplane, and thus the dividing hyperplane is essentially the line that separates the differently labeled instances. If we define the distance from the separating hyperplane to the nearest expression vector as the margin of the hyperplane, the SVM chooses the maximum margin that separates the hyperplane. Choosing this particular hyperplane maximizes SVM's ability to predict the correct classification of previously unseen samples. Of course, many real data sets cannot be separated so clearly. Intuitively, it is desirable that the SVM could deal with errors in the data by allowing several anomalous expression profiles to fall on the wrong side of the separation hyperplane. To handle such cases, the SVM algorithm needs to be modified by adding a "soft margin". Essentially, this allows some data points to travel along the margin of the separation hyperplane without affecting the final result. The problem is that a single point cannot separate the two classes and adding a soft margin won't help. The kernel function provides a solution to this problem by adding an additional di-mension to the data. In essence, the kernel function is a mathematical trick that allows SVM to perform a "two-dimensional" classification of a set of original onedimensional data. In general, a kernel function projects data from a low-dimensional space to a higher-dimensional space by squaring the sample (Noble, 2006). K nearest neighbors (kNN) is an efficient lazy learning algorithm and has successfully been developed in real applications. It is an algorithm that classifies according to both the distance measure and the number of neighbors. kNN algorithm computes the distance between each training sample and test samples in the dataset and then returns k closest samples. Its time complexity is linearly and is guaranteed to find exact k nearest neighbors (Deng et al., 2016).
By its simplest description, decision tree analysis is a divide-and-conquer approach to classification and regression. Decision trees can be used to discover features and extract patterns in large databases that are important for discrimination and predictive modeling. A decision tree is constructed by recursively partitioning the feature space of the training set. The first cell of the decision tree is called the root. Each observation is labeled yes or no according to the situation at this root. There are nodes under the roots. The complexity of the model increases as the number of nodes increases. The leaves at the bottom of the decision trees give the classification result. The objective is to find a set of decision rules that naturally partition the feature space to provide an informative and robust hierarchical classification model (Myles et al., 2004).
Random Forest is an ensemble method, which constructs many decision trees that will be used to classify a new instance by the majority vote. Each decision tree node uses a subset of attributes randomly selected from the whole original set of attributes. Additionally, each tree uses a different bootstrap sample data in the same manner as bagging. A Random Tree is a tree drawn at random from a set of possible trees, with m random attributes at each node. The term "at random" means that each tree has an equal chance of being sampled. Random Trees can be efficiently generated, and the combination of large sets of Random Trees generally lead to accurate models (Oshiro et al., 2012).
ES-KNN is also ensemble classifier like RF. Its difference from RF is that it uses KNN as a classifier model. Despite its simplicity, k-NN gives competitive results and even outperforms other complex learning algorithms in some cases. However, k-NN is affected by noninformative features in the data, which are quite common in high-dimensional data. Subspace ensembles have the advantage of using less memory than ensembles with all estimators and can handle missing values. For this reason, it is expected that the classification success of the ES-kNN algorithm will increase, especially as the dataset grows (Psathas et al., 2020).
Undoubtedly, more training data is needed to obtain a classifier model with good performance. Therefore, except for some special cases (limited data set), it is desirable that the training data set be larger than the test dataset. In fact, there is no optimum split ratio. It is generally accepted in the literature to divide the data sets as 70-80% training and 20-30% testing. It was predicted that separating the training set by 60% would reduce the classifier performance by 70%. When we separate the training data set by 80%, the performance of the classifier model will increase, but the test data will not be able to represent a part of the training data. Apart from these, considering the training and evaluation costs, the data set was divided into 70% training and 30% testing. In order to measure the classification success of machine learning algorithms, a 2x2 confusion matrix is created and the samples are placed in the relevant section of the matrix by examining their real tags and classified tags. The components of the complexity matrix are the above-mentioned TP, TN, FP and FN. Performance parameters are calculated using these values. In this study, Sensitivity, Specificity, Accuracy, Precision and F1 score were used as performance parameters as in similar previous studies. Sensitivity (SE), which is one of the two most important metrics, is sometimes referred to as recall; It is used to calculate the rate at which the falls can be correctly detected. Another important parameter is Specifity (SP) that measures the success of the system in not giving false alarms. In addition, the value of accuracy (ACC) is the parameter that enables the classification result to be scored overall (Haq et al., 2018). The precision parameter serves to determine reliability of the model by checking whether a fall is existing when the model gives a fall alert. Real success rate of the system is obtained with the F1 score to be obtained from two parameters; precision and recall (Kocaoğlu and Akdoğan, 2019). All parameters used in performance evaluation are given in Table 3.

Falling Direction Classification
The main purpose of determining the fall of the elderly is to eliminate the negative effects of physiological and mental disorders that may occur after a fall as soon as possible. Therefore, when a fall is detected, the relevant 15 types of falling activities included in the SisFall dataset are classified as falling forward, backward and sideways (lateral) according to their directions as in Table 4. Only F06 (vertical fall while walking caused by fainting) defines the fainting and clutter drop, which can continue in any direction. Therefore, it is considered as a separate group. Again, classification is made using same machine learning algorithms. Each algorithm has been evaluated using machine learning performance parameters.

Testing Phase
At the end of the training phase, the most successful classifier model was created separately for both two stages. The system success was measured again by using 30% of the data allocated for testing and never seen by the classifiers. Testing process is carried out by using compact models of classifiers created during training phase. The success of the system is evaluated based on the results obtained at the end of this stage.

RESULTS AND DISCUSSION
The approach in this study consists of two stages: fall detection and falling direction detection. In k-folds cross validation, the relevant part of the dataset is divided into equal k parts. At each step, k-1 groups are used for training and performance is tested with the last group. This verification process is repeated k times. The performance of the classifier is calculated based on the k results (Haq et al., 2018). Choosing k at different values creates variation in classification performance. In this study, in both stages, 10 folds cross validation is used to re-check the results, since the best result was obtained in the case of k = 10.

Fall Detection Results
At this stage, each observation in the train data is classified as fall or ADL. Table 5 gives the results of all classifiers. At this stage, the classification success of all classifiers gave similar results. Although DT lags behind other classifiers by 4% in terms of accuracy, it approached the classification success of similar studies in the literature with an accurate classification rate of 94,4%. ES k-NN achieved a success rate of 99% and produced a similar F1 score. As such, binary classification in the fall detection stage has a high degree of accuracy.

Falling Direction Detection Results
At this stage, performance parameter results were obtained by testing with each classifier (Table 6). When the fall direction detection results are examined, it is seen that the ES-kNN algorithm is successful against other algorithms, although with a slight difference, as in the previous stage. Again, DT lags slightly behind other classifiers. Although the accuracy value of ES-kNN was 96,8%, the F1 score fell slightly behind this and became 93,8%. This is because the precision value is slightly lower than the accuracy value. This indicates that FPs are lower than FNs. Since the falling direction is being determined at this stage, this is due to the fact that the number of samples entering the random training set for each direction is not exactly equal.

Testing Results
It is seen that models created in previous studies are generally not tested. In order to test the reliability of the classification, the classification was made using the testing data, which was not used before, on the model. The results of this classification also coincide with the results of the training classification (Table 7).

CONCLUSION
In this study, the fall direction detection system is studied for elderly individuals. Direction detection creates a gap in the literature. It is seen that existing studies either detect falls binarily (fall/ADL) using various methods, or they try to determine exactly what falls and ADLs are. Binary fall detection success is observed to be very high in these studies, but success is low when activity detection is targeted. However, what is important in detecting a fall is not the reasons such as stumbling, fainting or losing balance, or head height during the fall, whether the knees touch the ground or not. The important detail in fall detection is to determine the direction of the fall and to prevent from hitting hard if it is possible. For this purpose, SisFall dataset, a very detailed dataset, was used in this study. Data belonging to two accelerometers and one gyroscope were used to create the processed dataset and a two-stage fall and fall direction detection system was developed. A total of 99 features are obtained with 11 various features extracted for three axes of each sensor and these features are used in both stages. As a result of the experiments made with 5 different machine learning algorithms, it was seen that the most successful classifier in both stages is ES k-NN. This classifier showed 98.9% accuracy in the fall detection stage and 96.8% accuracy in the fall direction detection stage. Similar results were obtained in the classification experiment using testing data corresponding to 30% of the total data, which were never used during the training on the ES k-NN model prepared.
In future studies, it can be tried to increase the classification success by using different techniques. By using different datasets together or using one of them with training and testing the other, a system can be developed that can be surer of its success when it is put into practice. While doing this study, our main goal was to develop a system that can predict the fall direction with high accuracy and take precautions against hitting the ground. We hope that in the next stages, airbags will be deployed in the determined direction and trials will be conducted with volunteers.