Date of publication xxxx 00, 0000, date of current version xxxx 00, 0000

More versatile, user-independent tools for recognizing and predicting locomotion modes (LMs) and LM transitions (LMTs) in natural gaits are still needed. This study tackles these challenges by proposing an automatic, user-independent recognition and prediction tool using easily wearable kinematic motion sensors for innovatively classifying several LMs (walking direction, level-ground walking, ascend and descend stairs, and ascend and descend ramps) and respective LMTs. We compared diverse state-ofthe-art feature processing and dimensionality reduction methods and machine-learning classifiers to find an effective tool for recognition and prediction of LMs and LMTs. The comparison included kinematic patterns from 10 able-bodied subjects. The more accurate tools were achieved using min-max scaling [-1;1] interval and “mRMR plus forward selection” algorithm for feature normalization and dimensionality reduction, respectively, and Gaussian support vector machine classifier. The developed tool was accurate in the recognition (accuracy > 99% and > 96%) and prediction (accuracy > 99% and > 93%) of daily LMs and LMTs, respectively, using exclusively kinematic data. The use of kinematic data yielded an effective recognition and prediction tool, predicting the LMs and LMTs one-step-ahead. This timely prediction is relevant for assistive devices providing personalized assistance in daily scenarios. The kinematic data-based machine learning tool innovatively addresses several LMs and LMTs while allowing the user to self-select the leading limb to perform LMTs, ensuring a natural gait. INDEX TERMS kinematic data, machine learning, motion intention recognition, motion transition prediction


I. INTRODUCTION
Humans can perform distinct locomotion modes (LMs) in a variety of conditions and terrains in their daily routine.The classification of daily LMs and LM transitions (LMTs) is required to timely tune the assistance provided by the robotic assistive devices (e.g., orthoses and prostheses) according to the patient's LM and to generate smooth transitions, respectively [1].The recognition and prediction of LMs and LMTs is a requirement in the assist-as-needed paradigm to foster personalized gait assistance in daily-life scenarios [1], [2].Recognition tackles the classification of the ongoing LMs and LMTs, whereas the prediction refers to the classification one-step-ahead of their occurrence.For this purpose, it is necessary to develop automatic, userindependent tools capable of recognizing and predicting the LM and LMTs using wearable sensors [1].
Multiple efforts have been made to develop automatic LM recognition tools.Part of them tackles patternrecognition from electromyography (EMG) data [3]- [5].However, EMG sensors present some drawbacks when compared to kinematic sensors, such as the lengthy and expert-based installation, difficulty for keeping them attached during the user's daily locomotion, and the shifting electrodes may change EMG patterns and degrade the classification over time [2], [4], [6].
To avoid these limitations, more cost-effective, wearable kinematic sensors, namely inertial measurement units (IMUs), have been applied.Previous studies [2], [6], [7] have proposed LM recognition tools driven by IMU sensors and validated in able-bodied subjects.Jang et al. [7] and Li et al. [2] applied a finite state machine whereas Liu et al. [6] and Leuenberger et al. [8] employed machine learning approaches, namely the linear discriminant analysis (LDA) and the k-nearest neighbors (KNN), respectively.Despite their contribution to accurate recognition tools, these works did not tackle the LM prediction problem, nor LMT classification, both demanded on robotic-based rehabilitation and assistance.
The existing state-of-the-art [5], [10], [11], for predicting LMs and recognizing LMTs, presents some methodological drawbacks.Huang's work [5] used LDA and support vector machine (SVM) to recognize five LMTs (level-ground walking to stair ascent, ramp ascent, and stepping over an obstacle and stair descent and ramp descent to level-ground walking).Despite the successful classification, some factors are limiting this work; namely, the tool depends on EMG information, and transitions were recognized when one of the legs was already on the next terrain type.This transition assumption, also observed in [10], does not lead to a genuinely user-independent tool since the user is asked to start the terrain transition with a predefined limb, and it may interfere with the natural gait flow.In contrast, Chen et al. [11] applied LDA for LMT recognition without imposing a predefined leg for performing the transition.This tool was not prepared to recognize common LMTs between the level-ground and ramp.
There is still a set of challenges to be pursued, such as to (i) develop a more versatile tool for predicting and recognizing more daily performed LMs and LMTs; (ii) use discriminative sensor data measured by easily wearable sensors, such as kinematic data collected from IMUs, to ensure a natural gait; and, (iii) allow the user to freely choose the leading limb to perform the LMT.The latter challenge demands less cognitive effort from the user and enabling a more natural walk during daily activities.
This study tackles the mentioned challenges.It proposes a versatile, automatic, user-independent recognition and prediction tool for classifying LMs and LMTs using kinematic patterns collected from easily wearable sensors (i.e., IMUs) that fosters a more natural gait.The recognition and prediction tool aims an efficient classification of the LMs commonly encountered in the daily life while covering different walking directions (i.e., forward, back, clockwise, and counter-clockwise) along with variations in gait speed and terrains (i.e., flat, ascending and descending stairs, climbing up and down ramp, stepping over obstacles).The tool also approaches transitions from/to those terrains using the user's self-selected lower limb.We used heterogenous kinematic patterns from 10 able-bodied subjects, including variation in walking direction, gait speed, and terrain, to assess the tool's effectiveness.To the best knowledge of the authors, there is yet no available automatic tool that is capable of accurately recognizing and predicting all these daily LMs and respective LMTs independently of the leading limb, and no prior study has addressed the transition prediction problem only including kinematic data of the step that precedes the LMT.Moreover, the proposed tool was able to achieve generalization for a given set of healthy subjects.It may be applied to establish a recognition and prediction tool for a segment of the population of pathological end-users.We exclusively used kinematic data from IMUs to explore the potential of using easily tracked data in high-complex decision making of several daily LMs and LMTs.The kinematic data contains valuable information on the time domain, which is essential for evaluating the natural human motion progress.
Additionally, we compared standard machine learning classifiers of gait pattern recognition to find an accurate tool for both recognition and prediction purposes.We implemented a machine learning-based framework for enabling the fast and systematic benchmark, by applying various state-of-the-art algorithms namely, feature selection and pre-processing methods, and supervised machine learning classifiers (DA, KNN, random forest (RF), SVM, and multilayer perceptron-neural network (MLP)).
This work aims to pursue two main research questions, as follows: (i) which machine learning-based configuration is best for the recognition and prediction of LMs and LMTs?, and (ii) Is it possible to recognize and predict LMs and LMTs using only kinematic data?These questions are explored in Section III and Section IV, respectively, considering the methods described in Section II.

II. METHODS
This section describes the machine learning-based framework implemented in Matlab® (2017b, The Mathworks, MA, USA).The framework, presented in Fig. 1, was designed to enable the fast implementation, testing, and comparison of different feature processing methods and machine learning classifiers to identify an accurate classification model for both recognition and prediction purposes.This framework considers the most applied procedures in gait pattern recognition, as reviewed in [12].
The framework describes the conducted stages in the training and testing phases.Given the possibility of comparing different techniques with the same kinematic data, we used this framework to answer the first research question to propose a versatile, effective, and benchmarking tool for the recognition and prediction of LMs and LMTs.We explain each stage of the proposed framework in the following.

A. DATA ACQUISITION
In the raw data table (Fig. 1), we included kinematic data, sampled at 200 Hz, namely the angle and angular velocity of the lower limb segments (thigh, shank, and foot) in the sagittal plane, and the angle and angular velocity of the torso in the sagittal and axial planes.Data were filtered by a 1 st order low-pass filter (exponential smoothing) with 0.5 as the smoothing factor and a cut-off of 10 Hz [13].Appendix I provides instances of the collected data.

1) PARTICIPANTS
We included 10 able-bodied subjects (6 males, 4 females).The participants' mean age was 27±7.35 years old, with a height of 1.70 ± 0.12 m and a weight of 62.63 ± 9.39 kg.All participants provided written and informed consent, according to the ethical conduct defined by the University of Minho Ethics Committee that follows the standards set by the declaration of Helsinki and the Oviedo Convention.

2) EQUIPMENT
We collected kinematic data using a wearable IMU-based system, InertialLAB (Fig. 2.A), given its usability and operability in daily scenarios, such as those considered in this study.It includes 7 IMUs (MPU-6050) connected via I 2 C protocol to the STM32F4 microcontroller, which has attached a USB flash drive to store the data.A 2000 mAh power-bank powered the InertialLAB.The IMUs were positioned on the outer side of the thighs and shanks, on top of the feet, and one IMU on the torso (Fig. 2.A).

3) EXPERIMENTAL PROTOCOL
Before data collection, we calibrated the InertialLAB while the subject was in the upright standing position for 5 s.Then, the participants performed randomly 9 trials per walking direction (3 trials per gait speed) considering the output of a random number generator (used to set the trial number randomly).The trials included different walking directions (forward, backward, clockwise, and counterclockwise) performed on a 10 m level-ground at 3 self-selected gait speeds (slow, normal, and fast) in an indoor corridor.Additionally, the subjects conducted 10 trials on four walking circuits at a self-selected gait speed.In the first circuit (Fig 3 .A), they walked 2 m forward on level-ground; ascended the staircase; walked forward on level-ground for 2 m and stopped; and descended the staircase back to the starting position.This circuit included 3 LMs (level-ground walking (LW), stair ascent (SA), and stair descent (SD)) and 4 LMTs (LW→SA, SA→LW, LW→SD, SD→LW).The indoor staircase (Fig 2 .B) had 8 steps each with 17 cm of height, 31 cm of depth, and 110 cm width.On the second circuit, the participants walked 2 m forward on levelground; ascended a ramp; walked forward on level-ground for 2 m and stopped; and descended the ramp back to the starting position.The outdoor ramp (Fig 2 .B) was 10 m with a 10º inclination.This circuit included 3 LMs (LW, ramp ascent (RA), and ramp descent (RD)) and 4 LMTs (LW→RA, RA→LW, LW→RD, RD→LW).On the 2 last circuits, the subjects walked forward 2 m on level-ground, step over an obstacle (SO), and walked forward 2 m (Fig. 3.B).These circuits differ in the obstacle dimension.One circuit included an obstacle with 22 cm in height and 34 cm depth; whereas, the other circuit involved an obstacle with 34 cm in height and 22 cm depth.The subjects could freely perform the LMTs with any leading leg to enable transition seamlessly and intuitively between LMs.
An experimenter walked alongside the subjects marking the transitional moments (vertical red line in Fig. 3) using a digital button, similarly to [10], [14].A transitional moment is a moment belonging to the interval from the instant the leading limb left the terrain to the instant that this limb touched the other terrain.Fig. 3 shows that a transitional step differs for recognition and prediction purposes.For recognition, a transitional step refers to the period from the moment that the leading limb leaves the prior terrain (last foot contact) to the first moment that this limb touches the upcoming terrain (initial foot contact).For prediction, we used the step that precedes the ongoing transitional step (the one used in recognition), i.e., the prediction tackles onestep-ahead of ongoing LM or LMT.

B. FEATURE CALCULATION
The Feature Calculation stage aims to obtain a feature table that includes five types of features (the mean value, standard deviation value, range, and the values of the first and last positions of the stride) calculated per gait stride for each kinematic data of the raw data table, resulting in a total of 80 features.Previous intent recognition tools used these features [10], [14], [15].Fig. 4 presents the content of the feature table.The gait stride's boundaries were defined as the heelstrike and toe-off events for recognition and prediction models, respectively, as illustrated in Fig. 3.We considered the toe-off event for prediction since it is a critical point for transition (i.e., the beginning of the transitional step) [10], and it has achieved low prediction errors [16].We used an adaptive rule-based finite state machine [13] to segment these gait events from the feet gyroscopes' signal monitored by InertialLAB.
We investigated different time window sizes, established as fractions of the stride (namely, full-stride, 1/2, 1/3, 1/4, 1/5, and 1/6), to identify the most representative window's size for recognition and prediction models.We arbitrary selected the fractions of the stride, as in [16], to explore segmentation approaches less dependent on external tools for gait event detection in an attempt to minimize cumulative errors.As the time window size is based on fractions of the stride, it adapts automatically to gait speed variations instead of considering a fixed timing size.
As depicted in Fig. 3, for recognition and prediction models, the features were calculated from a time window that starts with the heel-strike event and ends according to the selected stride's fraction, and from a time window that starts according to the selected stride's fraction and ends with the toe-off event, respectively.
The feature table contains data from both legs [17].There is evidence that bilateral features improve intent recognition [14] and that walking, especially transitions, requires bilateral coordination of the lower limbs because the leading and opposite legs have distinct biomechanical functions, even for unilaterally-impaired subjects.We explored two-leg feature approaches to study the relevance of discriminating the leading and opposite legs.The first approach considers the leading and opposite leg, whereas the second approach considers the left and right leg.

C. PRE-PROCESSING
The Pre-Processing stage is relevant for improving features using normalization techniques and for identifying discriminative features to build the models.
We normalized the features by the subject's height since the anthropometric scaling features reduce the variability of the feature table [12].Additionally, we compared different normalization techniques, namely centering, z-score standardization, and min-max scaling [18].
Subsequently, we compared the effects on the models' performance of one filter feature selection method and one feature extraction method.As the filter method, we applied an ANOVA-based method, which uses the minimumredundancy maximum-relevancy (mRMR) algorithm to rank features in descending order according to their relevance [19].Then, we used the ANOVA, starting on the highest-ranked feature, to assess which classes are distinguishable for the feature considering the feature's mean and variance per class.This procedure was done until there are a set of features that distinguish between all classes.
As the feature extraction method, we applied the principal component analysis (PCA) considering the Horn's Parallel Analysis as a cut-off criterium for extracting the number of components to retain [20].A component is retained whether the associated eigenvalue is higher than the 95 th of the distribution of eigenvalues derived from the random data.

D. DATA LABELING
In the Data Labeling stage, the processed feature table was labeled according to the LM or LMT from whereas it was collected.For this purpose, we merged a priori knowledge of the feature's origin with the transitional moment recorded during gait trials.During the training, the labeled feature table is the ground truth on which the model bases its decisions.
We implemented 8 classification models for both recognition and prediction purposes (4 models for each one), following the classification scheme depicted in Fig. 5. From the processed feature table, we created the labeled feature table organized into 4 databases, one to train each classification model for recognition and prediction purposes.
The features of the recognition and prediction databases were equally labeled as follows.The direction_ft database includes features from the trials varying the walking direction.This database contains 4 classes (i.e., forward, backward, counter-clockwise, and clockwise), and the features were labeled according to these classes.The database named sts_trs_ft contains two classes; the steadystate step, that considers all gait steps associated with the LMs; and transition step, that includes the gait steps related to LMTs.We labeled the features of the steady_state_type_ft database according to the five steadystate classes, one per LM (i.e., LW, SA, SD, RA, and RD).The database transition_type_ft includes features from transitional steps, which were labeled according to nine classes: LW→SA; SA→LW; LW→SD; SD→LW; LW→RA; RA→LW; LW→RD; RD→LW; and, SO.The period for crossing the obstacle (SO) refers to a transitional step from the first terrain (LW) to the second one (LW).

E. MODEL BUILDING
The Model Building stage builds the classification models for recognition and prediction purposes.It may involve the application of wrapper and embedded feature selection methods and the optimization of the model's hyperparameters.
In this stage, we explored two wrapper methods, the "mRMR plus forward selection" and "forward selection plus backward selection".When using "mRMR plus forward selection", the features were ranked through the mRMR method, and a classification model was built and evaluated using the highest rated feature.A feature was only kept when it increased the performance.This selection was made for every feature or until the model reached the maximum performance (Mathew's correlation coefficient equal to 1).
When using "forward selection plus backward selection", the feature that improves the performance the most in combination with the already established feature set was added to the set.Afterward, the backward selection was used on the obtained feature set, and the process was inverted; the features were iteratively removed if their absence did not affect the model's performance.
Moreover, we compared five machine learning classifiers, namely DA with linear and quadratic approaches; KNN, using both weighted and unweighted (regular) neighbor distances; RF; MLP; and, SVM, using linear, quadratic, cubic and Gaussian kernels.We implemented these classifiers due to their prevalence in gait pattern recognition [12].This comparison aims to identify the better-suited classifier for the LM and LMT prediction and recognition purposes.
We optimized the classifiers' hyperparameters for each selected feature dataset until the best hyperparameter's values were found.The KNN and RF were tuned by increasing the number of nearest neighbors (k) and the number of decision trees, respectively, starting with 1 until the performance reached the maximum value or started decreasing.For the SVM, we applied the grid-search strategy ([-10,10] interval) to tune the box constraint parameter (C) and the kernel scale parameter (σ) for the Gaussian kernel.For DA, we used the delta threshold set to 0, and gamma regularization set to 1.The MLP consisted of one input layer (number of neurons equal to the number of selected features), two hidden layers of 10 neurons, and one output layer with the number of possible classes.The sigmoidal was the used activation function.The weights were updated through the backpropagation algorithm for 1000 iterations with a learning rate set to 0.01.
The implemented classification scheme seems to be advantageous compared with the one proposed in [10], [14] since it demands fewer models, decreasing the computational load, and allows the easy incorporation of further LMs and LMTs, adding versatility to the framework to act as a benchmark tool.This stage produced 4 classification models (Fig. 5), one per database (direction_ft, sts_trs_ft, transition_type_ft, and steady_state_type_ft).The Direction Classification Model classified the gait step data according to the walking direction.If a gait step has been classified as forward, then it was classified as a steady-state step or a transitional step by the Steady-State/Transition Type Classification Model.
If it has been classified as steady-state, the Steady-State Type Classification Model was used for the final classification.Otherwise, the final classification used the Transition Type Classification Model.This classification sequence was applied to build the recognition and prediction models.

F. MODEL EVALUATION
We evaluated the built model through cross-validation methods with a two-fold applicational goal.The first goal aims the hyperparameter tuning and comparison of the classification models using the different features and techniques, as listed in Table I.In this case, the Model Evaluation was performed by 2-fold cross-validation with 5 repetitions for minimizing the computational burden associated with the models' comparison.As the second goal, we evaluated the generalization capability of the final classification models using the leave-one-out crossvalidation [12].We used Mathew's correlation coefficient (MCC) for both comparison and reporting of model's performances due to its good representative properties of unbalanced classes [21], as considered in this work.We also computed the accuracy (ACC) for comparing the results with the literature's findings.

III. MACHINE LEARNING-BASED FRAMEWORK: RESULTS AND DISCUSSION
This section presents a comparative analysis of the different techniques explored in some stages of the machine learningbased framework detailed in Section II to answer the first research question for finding the machine learning-based configuration for the recognition and prediction of LMs and LMTs.Table I summarizes the purpose and conditions considered in this comparative analysis.

A. FEATURE CALCULATION ANALYSIS
Results of the recognition models show that using the fullstride fraction with the left/right approach outperforms (MCC = 0.907) all the other cases by a significant margin (MCC < 0.808).On the other hand, for prediction, the leading/opposite approach and 1/4 fraction of gait stride yielded the best results (MCC = 0.857).The latter remark suggests that the interval from 1/4 stride's fraction to the toe-off event (likely from terminal stance phase to preswing phase) contains relevant information for the user's motion prediction.We considered these findings in the subsequent analyses.They suggest that both the feature leg approach and the time window size affect the model's performance, but these parameters depend on whether it is a recognition or prediction model.

B. FEATURE NORMALIZATION ANALYSIS
We verified that min-max scaling with the interval [-1;1] yielded the best results for recognition (MCC = 0.852) and prediction (MCC = 0.728).It was chosen for the remaining analyses, as proposed in [22].Although min-max scaling may be sensitive to outliers, we did not observe this fact in this comparative analysis.Using no normalization or centering data had the same effect, suggesting that centering data to zero does not improve the classification based on kinematic features.Overall, the normalization had a more positive effect in recognition models (MCC > 0.711) than in the prediction ones (MCC > 0.630).

C. FEATURE SELECTION AND EXTRACTION ANALYSIS
Overall, feature selection and extraction methods performed better in recognition models (0.677 < MCC < 0.96) than in the prediction ones (0.589 < MCC < 0.87).
The application of an adequate dimensionality reduction method improved the effectiveness of the classifier compared to the inclusion of the entire dataset.This finding is according to the literature [12] since it results from the ability to create a compact set of uncorrelated features that still characterize the original data without redundancy.Using the "mRMR plus forward selection" method (MCC > 0.8483) or "forward selection plus backward selection" (MCC > 0.8696), both feature selection methods, yielded similar results.However, the former is less computationally intensive, and while it selects a larger number of features than the latter method (20 and 13 features, respectively), it was the selected method allowing a feature reduction of 75% from a total of 80 features.This sequential selection and ranking-based methods were used in [8], [23], [24].In particular, the findings are consistent with [23], who concluded that the mRMR was faster and more effective than the "forward selection" and "backward selection" methods.
On the other hand, the ANOVA was less effective (MCC < 0.677) due to the low number of selected features (2 to 3 features) to discern between the classes.
These findings suggest that the dimensionality reduction methods that depend on the built model outperformed the ones (as ANOVA and PCA) that consider neither the classification model nor the classification goal.

D. MODEL BUILDING ANALYSIS
Fig. 6 shows that the SVM classifier with the Gaussian kernel performed better than other classifiers for both prediction (MCC = 0.86) and recognition (MCC = 0.94).The SVM's ability to define more complex decision boundaries by applying optimization instead of probabilities, and its inherent flexibility to suit the data may explain this finding [12].Previous literature indicates this classifier as the best, mainly when the Gaussian kernel is involved.Begg et al. [25] concluded that SVM performs better than MLP, as observed in this benchmarking analysis.Badesa et al. [26] noted that the SVM is more appropriate than LDA, QDA, and KNN methods.Huang et al. [27] reported that SVM yielded better results than LDA to recognize six LMs and predict five LMTs.
The results achieved for RF models indicate their middleranked performance for prediction and recognition.Despite the optimization of the hyperparameter related to the number of decision trees, the optimization procedure could have addressed further hyperparameters.
On the other hand, both DA models produced the worst classification performance (MCC < 0.73), in contrast to [14], where the LDA performance was comparable to the SVM.Three reasons can explain this finding: LDA does not work well if the design is not balanced, such as the one in this study; LDA is not suitable for non-linear data, such as the kinematic data; and, LDA simplicity was perhaps not sufficient to discriminate the LMs and LMTs using the calculated features.
Due to the increased complexity of SVM, the built model took almost double time to classify data comparing to other classifiers (Fig. 6).However, this computational burden is acceptable for recognition and prediction applications, considering human gait frequency at a normal pace (> 1s).
This comparative analysis suggests that the SVM classifier with a Gaussian kernel is an effective classifier to yield a benchmark tool for both recognition and prediction purposes, despite the higher computational burden than other classifiers.This remark is based on its higher prediction performance, which is still a critical challenge in the literature.

IV. RECOGNITION AND PREDICTION TOOL: RESULTS AND DISCUSSION
This section shows the performance of the final recognition and prediction tool built from the best machine learning configuration found in Section III.The findings presented in this section allow investigating whether kinematic data is enough to recognize and predict LMs and LMTs, addressing the second research question of this study.We approached the first steps on a user-independent recognition and prediction tool by including inter-subject gait pattern variability into the tool building, i.e., the tools were built using data from all subjects instead of building a subjectspecific tool [10].More participants will increase the userindependent character.

A. EVALUATION OF RECOGNITION TOOL
The final recognition models were built using features calculated from a window size covering full-stride with the left/right approach and normalized by min-max scaling in [-1; 1] interval.Table II summarizes the results of the Gaussian SVM classifier (C = 64, σ = 4) in terms of MCC and AC and presents the number of classified steps and the number of selected features by "mRMR plus forward selection" algorithm.The obtained confusion matrices are presented in Appendix II for a more in-depth analysis.
The number of selected features was variable, given the different decision-making complexity between the models.The features collected from the IMU placed on the back were exclusively used in the recognition models, as follows: standard deviation of the axial torso angle for Direction Recognition Model; mean of sagittal torso angular velocity for Transition Type Recognition Model; standard deviation of the axial torso angular velocity for Steady-State Type Recognition Model; and, mean, range and first position of the sagittal torso angle, first and last position of the sagittal torso angular velocity, mean and first position of the axial torso angle for Steady-State/Transition Recognition Model.The feature selection for the different models was consistent across subjects and involved features from all 7 IMUs.The Direction Recognition Model had near-perfect results (MCC = 0.998, ACC = 99.9%) with only few forward steps being classified as counter-clockwise or clockwise.This model used 43 features from a total of 80.It shows that not all information is necessary for accurate classification of the walking direction.
On the other hand, the Steady-State/Transition Recognition Model was less effective (MCC = 0.817, ACC = 96.5%)even using more features (69 features).The selection of more features may indicate that the discrimination between steady-state and transition is complex.Previous studies [10], [16] reported that the inclusion of ramps as an LM introduced some error due to the similarities between ramps and LW.This remark is according to the obtained results since all misclassifications involved walking on or transitioning to ramps.The fusion of kinematic data with environment-aware data [6]  The Transition Type Recognition Model was accurate (MCC = 0.993, ACC = 99.6%),even when it was built with one-tenth of the steps and with the least number of used features (19 features).This finding shows that it is possible to accurately distinguish transition steps using a small number of kinematic features.The Steady-State Type Recognition Model had near-perfect results (MCC = 0.995, ACC = 99.8%)using 53 features.Errors were due to the classification of level walking steps as ramp steps and viceversa.
By comparing with the existing machine learning-based recognition tools based on kinematic data from wearable sensors, the proposed framework can perform a more versatile classification.At the best of the authors' knowledge, there is still no accurate recognition tool able to classify LMs and LMTs that considers different walking directions in LW (forward, back, clockwise, and counterclockwise) and terrains (LW, RA, RD, SA, and SD).Chan et al. [24] limited the recognition to SA and SD by using a less accurate tool (ACC = 96.8%)than the one proposed in this work (ACC = 99.8%).Further, the proposed recognition tool performs better when comparing to the one in [8], which identified the LW, SA, and SD with a sensitivity of 97%, 94%, and 87%, respectively.
The achieved results for recognizing steady-state steps in the LMs (LW, SA, SD, RA, RD) are consistent with the ones reported in [11] (ACC = 99.8% and ACC = 99.7%,respectively), where the lowest recognition accuracy occurred for RA.Nonetheless, this tool [11] and other studies [6], [23], [24], [27], [28] did not define transitional steps as a class; instead, they set a boundary between LMs after which the upcoming LM was attributed.In contrast, our tool recognizes the transitional steps to allow some time to the robotic device to timely generate smooth LMTs.
Lastly, we observed that the most effective recognition tools proposed in the literature [10], [27] only recognized an LMT after the leading leg is already on the next terrain.In contrast, our recognition tool recognizes an LMT before the leading leg reaches the second terrain type, without demanding any predefined leading leg, allowing a more natural walk in daily activities.

B. EVALUATION OF PREDICTION TOOL
The final prediction models were built using features calculated over a window size of 1/4 of the stride preceding the leading/opposite leg approach and normalized by minmax scaling in [-1; 1] interval.We used the "mRMR plus forward selection algorithm" for feature selection and Gaussian SVM classifier (C = 64, σ = 4).Table III presents the results considering the number of classified steps, the number of selected features, and the MCC and ACC metrics.Appendix III presents the confusion matrices.
The prediction models incorporate a different number of features by including features from all wearable sensor units.Thus, the dimensionality reduction did not contribute to reducing the number of IMUs.Around eighteen features (almost 25% of the total) were common to all models.Some features were exclusively used in the prediction models, as follows: mean of the event foot angular velocity for Direction Prediction Model; first and last positions of the sagittal torso angle, and standard deviation of the sagittal torso angular velocity for Steady-State/Transition Prediction Model; mean angular velocity of the opposite shank, range of the opposite foot angle, range of the sagittal torso angle, last position of the sagittal torso angular velocity for Steady-State Prediction Model.No specific feature was associated exclusively with the Transition Type Prediction Model, and there is no evidence for indicating the critical sensors per prediction model.
From Table III, we concluded that the prediction models used more features than the analogous recognition models.The Direction Prediction Model presented a near-perfect behavior (MCC = 0.989, ACC = 99.6%),even when considering variations in gait speed.We observed few misclassifications that occurred when forward steps were classified as counter-clockwise or clockwise and vice-versa, similarly to the recognition models.The model used 52 features from a total of 80 features, showing that there were still quite a few features irrelevant to the model.A previous automatic turn system with IMUs reported results similar to the ones achieved in this work (ACC > 97% vs. ACC = 99.6%,respectively) [17].
The Steady-State/Transition Prediction Model had the worst performance (MCC = 0.67, ACC = 93.3%)while using the most features (64 features).The use of an unbalanced sts_trs_ft database, including a higher number of steady-state steps than transitional steps, may explain this finding.Experiments with more transition steps are needed.
A previous study [10] developed a prediction system based on kinematic data and LDA that was able to classify LW, ramp, and stair steady-states with 99% accuracy.Our proposal (ACC = 99.4%) also matches this performance.This suggests that the proposed prediction tool, when compared with similar works, is more versatile (by considering more steady-state and transition steps) and similarly effective.Moreover, our protocol was, in part, identical to the study [14], by investigating kinematic data from the step that precedes the LMT.However, our prediction models are more accurate, more versatile by varying walking direction and speed on LW, and followed a lower complex prediction scheme than the one proposed in [14].Furthermore, our approach is more practical considering daily application requirements given the faster time for wearing the IMUs and provided a less intrusive experience than the one reached with the tethered solution proposed in [14].
Other studies [16], [23] have combined EMG with kinematic sensors, addressing a neuromechanical sensor fusion for improving the steady-state and transition prediction.The sensor fusion used in [23] was slightly more effective (ACC = 0.95) in the transition prediction problem than the proposed kinematic-based tool (ACC = 93.3%for Steady-State/Transition Prediction Model and ACC = 95.9% for Transition Type Prediction Model).On the other hand, the developed transition prediction model was more accurate than the models described in [16] (ACC = 88%), which used EMG sensors that also reported uncomfortable usability [10].

C. LIMITATIONS AND FUTURE DIRECTIONS
In this study, we presented a proof-of-concept of applicability of kinematic data to recognize and predict LMs and LMTs with able-bodied subjects walking without an assistive device.Our long-term goal is to test the recognition and prediction tool with neurologically impaired subjects walking with an assistive orthosis to investigate whether the achievements of this study translate to meaningful clinical benefit.The cross-validation results indicate that the proposed tool was able to achieve generalization for a given set of subjects; consequently, it may be applied to individual subjects afterward.We expect that we could use the presented machine learning-based framework to establish a recognition and prediction tool for a segment of the population of pathological end-users.The procedure described in this study will be part of further validation to obtain a pathological data-driven recognition and prediction tool.
There is still room for improving the decision-making from/to ramp, as reported in [10], [16].For this purpose, environment-aware data [29] may be fused with kinematic data towards improving the Steady-State/Transition and Transition Type Prediction Models.Furthermore, we expect to increase the accuracy of the Steady-State/Transition Prediction Model with more data from the transitional steps of a larger number of participants.
This study shows the potential of lower limbs' kinematic data to recognize and predict LMs and LMTs.The future investigation aims to reduce the number of sensors while ensuring the models' effectiveness.The use of smartphone sensors is a practical solution for daily use; however, their application has been limited to recognition purposes [9].
The developed classification scheme requires accurate classification models throughout the classification sequence since classification errors would propagate from the initial to the final classification stage.
The combination of variable walking direction and gait speed with terrains still has to be approached, extending the implemented classification sequence presented.Otherwise, the Direction Classification Model is only useful for levelground.

V. CONCLUSION
This study showed that the automatic recognition and prediction tool built from a kinematic data-based machine learning framework correctly classify LMs and LMTs commonly encountered in daily life.The most effective machine learning configuration includes min-max scaling in [-1;1] interval and "mRMR plus forward selection algorithm" for feature normalization and dimensionality reduction, respectively, and Gaussian SVM classifier.The machine learning-based framework offers methodological directions for future studies to find an effective machine learning-based tool for recognition and prediction purposes.
The contribution of this study to the state-of-the-art is manifold; it proposes a more versatile tool that classifies several LMs and LMTs while covering different walking directions and terrains; it tackles the transition prediction problem only using kinematic data; and, it allows the user to self-select the leading limb for performing the transitional step.There is evidence that kinematic data are appropriate for predicting LMs and LMTs one step before their occurrence.

FIGURE 1 .
FIGURE 1. Schematic of the machine learning-based framework for LMs and LMTs recognition and prediction purposes.

FIGURE 2 .
FIGURE 2. A) Wearable sensor system (InertialLAB) used in the Data Acquisition stage.B) Instances of experimental protocol performed at the indoor staircase and outdoor ramp.

FIGURE 3 .
FIGURE 3. Representation of two circuits (staircase and obstacles), highlighting the transitional step, transitional moment, and the explored time window sizes for recognition and prediction using heel-strike (HS) and toe-off (TO) events.

FIGURE 4 .
FIGURE 4. Feature Table with 5 types of features per kinematic data.

FIGURE 5 .
FIGURE 5. Schematic of the classification model's sequence for recognition and prediction purposes.Identification of databases and corresponding classes.

FIGURE 6 .
FIGURE 6.Average performance (MCC and computational load) for each machine learning classifier across every database and subject.
might improve the ramp classification.The performance of the Steady-State/Transition Recognition Model may affect endstage classification accuracy, i.e., the performance of the Transition Type Recognition Model and Steady-State Type Recognition Model.

FIGURE 10 .FIGURE 11 .
FIGURE 10.Angular velocity and angles of the lower limb segments collected from one female subject in stair descend.The transitional moments are marked with the vertical black line.

FIGURE 12 .
FIGURE 12. Angular velocity and angles of the lower limb segments collected from one female subject in ramp descend.The transitional moments are marked with the vertical black line.

TABLE I EXPERIMENTAL
COMPARISON OF TECHNIQUES FROM FRAMEWORK'S STAGES a Only KNN classifier was used given its fast training with reliable results b Previously reported as the best normalization technique

Table IV ,
Table V, Table VI, Erro!

A origem da referência não foi encontrada.and Table
VII present the confusion matrices of the final recognition models, as follows.

TABLE IV CONFUSION
MATRIX OF DIRECTION RECOGNITION MODEL

Table VIII ,
Table IX, Table X Erro!A origem da referência não foi encontrada.andTable XI present the confusion matrices of the final prediction models, as follows.

TABLE XI CONFUSION
MATRIX OF TRANSITION TYPE PREDICTION MODEL