Next Article in Journal
High-Dimensional Quantum Key Distribution with N-Qudits States in Optical Fibers
Next Article in Special Issue
Quantifying Readability in Chatbot-Generated Medical Texts Using Classical Linguistic Indices: A Review
Previous Article in Journal
Assessment of eHealth Literacy and Its Association with Oral Health Behavior Among Outpatients of a Dental College in Riyadh, Saudi Arabia—A Cross-Sectional Study
Previous Article in Special Issue
Deep Learning-Based Prediction of Tumor Mutational Burden from Digital Pathology Slides: A Comprehensive Review
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Machine Learning Models for Reliable Gait Phase Detection Using Lower-Limb Wearable Sensor Data

DeHealthLab, Department of Energy, Mechanical and Management Engineering, University of Calabria, 87036 Rende, Italy
*
Author to whom correspondence should be addressed.
Appl. Sci. 2026, 16(3), 1397; https://doi.org/10.3390/app16031397
Submission received: 1 December 2025 / Revised: 20 January 2026 / Accepted: 24 January 2026 / Published: 29 January 2026

Abstract

Accurate gait-phase detection is essential for rehabilitation monitoring, prosthetic control, and human–robot interaction. Artificial intelligence supports continuous, personalized mobility assessment by extracting clinically meaningful patterns from wearable sensors. A richer view of gait dynamics can be achieved by integrating additional signals, including inertial, plantar flex, footswitch, and EMG data, leading to more accurate and informative gait analysis. Motivated by these needs, this study investigates discrete gait-phase recognition for the right leg using a multi-subject IMU dataset collected from lower-limb sensors. IMU recordings were segmented into 128-sample windows across 23 channels, and each window was flattened into a 2944-dimensional feature vector. To ensure reliable ground-truth labels, we developed an automatic relabeling pipeline incorporating heel-strike and toe-off detection, adaptive threshold tuning, and sensor fusion across sensor modalities. These windowed vectors were then used to train a comprehensive suite of machine learning models, including Random Forests, Extra Trees, k-Nearest Neighbors, XGBoost, and LightGBM. All models underwent systematic hyperparameter tuning, and their performance was assessed through k-fold cross-validation. The results demonstrate that tree-based ensemble models provide accurate and stable gait-phase classification with accuracy exceeding 97% across both test sets, underscoring their potential for future real-time gait analysis and lower-limb assistive technologies.

1. Introduction

Gait analysis is the systematic study of human walking patterns using biomechanical and computational methods. It evaluates parameters such as stride length, joint kinematics, and walking speed. These measures support clinical diagnosis, rehabilitation monitoring, sports performance assessment, and human–machine interaction [1]. Within this domain, gait detection focuses on identifying walking activity or distinguishing individuals based on their unique gait signatures. This is commonly achieved using video-based systems, wearable sensors, or artificial intelligence (AI) models [2].
Human gait analysis plays a central role in the control of lower-limb assistive devices, including prostheses, orthoses, and exoskeletons [3,4,5]. A core component of these systems is discrete gait-phase detection, which identifies temporal segments such as stance, swing, and transitional phases. The accurate recognition of gait phases and their transitions is essential for safe and responsive interaction between humans and assistive robots. It enables stable locomotion, reliable torque generation, and real-time adaptation to user intent [3,4].
A wide range of sensing modalities has been explored for gait-phase detection. Vision-based systems provide detailed kinematic information and remain a laboratory reference standard [6,7,8,9]. However, their dependence on controlled environments and careful camera calibration limits their applicability in outdoor and daily-life scenarios. Physiological sensing modalities, such as electromyography (EMG) and electroencephalography (EEG), offer insights into neuromuscular activation during gait and exoskeleton-assisted locomotion [10,11,12]. Despite their advantages, these sensors remain sensitive to electrode placement, perspiration, and electrical noise.
Wearable sensors have therefore emerged as a practical solution for continuous gait monitoring in natural environments. Foot-mounted pressure sensors and force-sensing resistors (FSRs) enable reliable detection of heel-strike (HS) and toe-off (TO) events [13,14,15,16,17]. However, mechanical degradation and signal drift may affect their long-term reliability [18]. Inertial measurement units (IMUs) provide a lightweight, low-cost sensing of human motion. They have been widely applied to rehabilitation assessment, gait event detection, and ground reaction force estimation [19,20,21,22,23]. However, IMU-based systems remain susceptible to sensor drift, movement artefacts, and inter-subject gait variability.
Recent studies have shown that multimodal wearable systems can improve robustness across diverse locomotion tasks. These systems typically integrate IMUs with plantar pressure sensors, flex sensors, or footswitches. They have been evaluated during variable-speed walking, turning, stair ascent and descent, and ramp ambulation [24,25]. Despite these advances, heterogeneous signal quality and inconsistent pressure activations remain challenging. Misaligned contact events can further complicate the generation of consistent gait-phase labels. Notably, relatively few studies provide systematic and reproducible pipelines for automatically relabeling raw multimodal wearable data into discrete gait phases suitable for supervised learning.
From an algorithmic perspective, gait-phase detection approaches can be broadly categorized into rule-based methods and data-driven machine learning techniques  [26,27]. Rule-based approaches rely on heuristic thresholds applied to gyroscope or pressure signals and are computationally efficient. However, they often exhibit limited robustness to sensor placement variability and inter-subject differences [26]. In contrast, classical machine learning models, including support vector machines, k-nearest neighbors (kNN), artificial neural networks, and ensemble classifiers, have demonstrated improved performance across a range of gait datasets. Several studies have reported that ensemble and instance-based methods can outperform alternative classifiers for discrete gait-event recognition [27,28,29]. However, systematic comparisons of modern ensemble learning techniques under consistent experimental conditions remain limited.
Machine learning (ML) has become an important tool for gait-phase detection in prosthetic and rehabilitation applications [27,29]. ML methods are well suited to extracting subtle temporal patterns from noisy multi-sensor data that are difficult to capture using manual rules. From a gait-phase perspective, ML models have been applied to detect stance and swing phases, classify sub-phases, and recognize locomotion contexts such as level walking [27,30]. Such capabilities are essential for the safe and adaptive control of prostheses and exoskeletons.
Motivated by these gaps, this study investigates discrete gait-phase recognition using multimodal lower-limb wearable sensor data. The analysis is conducted on a publicly available dataset comprising multiple subjects instrumented with IMUs, plantar flex sensors, footswitches, and EMG channels. A total of forty biomechanical and kinematic features are extracted from segmented gait signals using fixed-length sliding windows. From each window, statistical descriptors including the mean, standard deviation, minimum, maximum, and root mean square values are computed. To establish consistent ground-truth labels, we develop an automatic relabeling pipeline that integrates HS–TO detection, adaptive threshold tuning, and sensor fusion across modalities. These features are then used to evaluate a suite of classical and ensemble machine learning models. The evaluated models include Random Forests, Extra Trees, kNN, XGBoost, and LightGBM. Structured hyperparameter optimization and k-fold cross-validation are applied to all models.
The main contribution of this work is a rigorous and reproducible evaluation pipeline. It combines automatic gait-phase relabeling, multimodal feature engineering, and a controlled benchmarking of widely used machine learning models under consistent experimental conditions. The results suggest that ensemble tree-based classifiers provide strong performance for discrete gait-phase recognition on the considered dataset. The study is limited by the specificity of the dataset and the adopted validation strategy. However, it yields practical insights for designing wearable sensor–based gait analysis systems for rehabilitation, prosthetic control, and exoskeleton-assisted mobility.

2. Literature Review

Gait-phase detection refers to the identification of different stages of the walking cycle, such as stance and swing, from signals recorded by wearable or external sensors. It enables a meaningful interpretation of human locomotion by segmenting continuous movement into discrete events. The accurate timing of gait phases is important in prosthetic devices and rehabilitation robots, which must synchronize their assistance with the user’s natural motion. Gait-phase detection is also used in clinical settings for assessing mobility impairments and monitoring recovery progress. For these reasons, reliable gait-phase detection is a central component of human movement analysis and the safe control of assistive technologies.
Farah et al. [27] investigated whether gait phases could be identified using only thigh and knee kinematics collected from healthy adults. They compared decision trees, Random Forests, neural networks, and support vector machines using a short sliding-window approach. Their results showed that a decision tree model achieved the lowest classification error, demonstrating that reliable gait-phase detection is possible even with a single thigh-mounted inertial sensor. This finding supports the feasibility of real-time orthosis control using minimal sensing configurations.
Several studies have explored alternative wearable sensing modalities. Pazar et al. [29] and Nazari et al. [30] examined whether soft, textile-based strain sensors embedded in ankle braces could be used to recognize gait phases during slow walking. Both studies evaluated multiple ML models, including Random Forests, neural networks, and support vector machines. In each case, Random Forest classifiers provided the most reliable performance. These findings indicate that lightweight, fabric-integrated sensors can offer practical alternatives to traditional IMU-based systems for gait phase detection.
Khamparia et al. [31] explored the use of machine learning to distinguish normal walking from freezing episodes in neuro-rehabilitated individuals. Acceleration signals were recorded from wearable sensors placed on the hip and legs. The authors evaluated several feature-reduced models and found that tree-based and nearest-neighbor methods outperformed simpler linear approaches. This study highlights the value of combining robust classifiers with appropriate feature processing for gait-related neurological assessment.
Vision-based approaches have also been investigated for gait-phase recognition. Pasinetti et al. [9] proposed a depth-camera-based system for users of powered gait orthoses. Their method extracts three-dimensional foot–floor geometry from Time-of-Flight images and uses percentile-based distance features as inputs to a modified Random Forest classifier. By incorporating prediction uncertainty, the system reduces misclassification during ambiguous transitions between stance and swing phases. The study demonstrates that depth sensing can support reliable real-time gait phase estimation in controlled environments.
Beyond classifier choice, gait-phase prediction performance is influenced by how sensor signals are segmented and processed. Sliding-window segmentation has been widely adopted for gait-phase identification, as it provides a simple and effective way to partition quasi-periodic inertial sensor signals into analysis units [32]. However, window design remains critical, since window length and overlap directly affect classification accuracy and detection latency. In particular, inappropriate window sizes can lead to a loss of phase-specific information or blurred boundaries around heel-strike and toe-off events [27].
Table 1 summarizes representative studies on gait-phase detection using machine learning approaches. It provides an overview of the datasets employed, the ML models evaluated, the best-performing classifiers, the target applications, and the key limitations identified in each study.

3. Materials and Methods

The dataset used in this study is publicly available and open source. It was published by Zafar et al. [33] and is accessible at (https://figshare.com/articles/dataset/Dataset_for_Lower_Limb_Prosthesis/11881332/9?file=33417746) (accessed on 10 November 2025). The dataset comprises recordings from six adult participants who completed structured lower-limb gait acquisition sessions. Five participants were healthy, while one participant was rehabilitated. All participants performed repeated level-ground walking trials under controlled laboratory conditions. Trials were conducted in both forward and backward walking directions. The demographic information provided in the original dataset documentation is summarized in Table 2.
A wearable sensing system was used to acquire multimodal lower-limb gait data. The setup integrated heterogeneous modalities, including surface electromyography (sEMG), inertial measurement units (IMUs), joint-angle encoders, and plantar-pressure sensors. In total, 20 physical sensors were mounted bilaterally: eight sEMG electrodes (four per leg) positioned over major lower-limb muscle groups, four IMUs (two per leg) attached to the thigh and shank segments, four potentiometer-based joint-angle encoders (knee and ankle per leg), and four FlexiForce plantar-pressure sensors (heel and toe per leg). In addition, footswitches embedded in the insole provided contact-state information for gait-event detection, and push-button triggers supported event annotation and trial management. All sensing streams were synchronized and logged using a dual NI-myRIO acquisition setup, enabling high-frequency sampling and precise temporal alignment across modalities. During the experimental trials, multimodal signals were collected continuously from both lower limbs while participants performed forward and backward walking and routine locomotor transitions, including level-ground walking, stair ascent and descent, ramp ascent and descent, and sit–stand movements. The resulting recordings capture complementary biomechanical information, joint kinematics, segment dynamics, muscle activation, and foot–ground interaction across a range of gait conditions. All channels were recorded simultaneously within each trial, yielding time-synchronized bilateral measurements. Although the acquisition platform supported up to 56 channels, the publicly released dataset contains 50 recorded channels (25 per leg), comprising 23 biomechanical channels and two auxiliary meta-signals (mode and tick_count). Table 3 summarizes the sensing hardware and the corresponding recorded channels.
The dataset is distributed in raw and post-processed formats; we use the post-processed version, in which streams are synchronized and quality-checked by the dataset authors [33]. For consistency across subjects and to simplify model evaluation, we restrict the analysis to right-leg signals and exclude mode and tick_count from the model input. Accordingly, each trial is represented by 23 right-leg input channels (Table 3).

3.1. Data Preprocessing

Before analysis, an additional structuring step was performed to consolidate the data across subjects and trials. Each participant’s recordings were distributed across multiple files corresponding to repeated walking trials and walking directions (forward or backward). First, all trials belonging to the same participant were merged into a continuous subject-level sequence. Metadata fields (subject, trial, and direction) were appended to each sample to preserve trial provenance. Finally, all subject-level sequences were concatenated into a single unified dataset. Any missing sensor samples arising from synchronization or recording gaps were imputed using simple interpolation to ensure continuity of the time series prior to window segmentation. The merged file served as the final dataset for window segmentation, feature extraction, and model training. Figure 1 provides a schematic overview of the final dataset.
To reduce inter-subject variability, a per-subject z-score normalization was applied independently to each sensor channel.

3.1.1. Data Labeling

Accurate gait-phase labeling is essential for the supervised classification of stance, swing, and mid-swing. The original dataset does not have labels for the gait-phase. Therefore, a multi-stage labeling pipeline was developed. The heel-strike (HS) and toe-off (TO) events were first estimated from the binary transitions of the shoe-mounted heel and toe buttons. Mechanical bounce and delayed releases occasionally introduced uncertainty. For this reason, the analogue heel-flex and toe-flex signals were incorporated to refine event timing. To account for amplitude differences across subjects, fixed thresholds were avoided. Instead, an automatic threshold-search procedure was used. The flex signals were normalized to the range [0,1]. A grid of candidate thresholds (0.10–0.90 in steps of 0.05) was evaluated. For each candidate threshold, HS/TO timings from the flex sensors were compared with the button-derived events, and the threshold minimizing the temporal deviation was selected. The optimal thresholds typically fell between 0.2 and 0.4. This selection provided trial-specific adaptability and improved consistency.
Using the refined HS and TO events, each sample was assigned to one of three gait phases: stance (HS to TO), swing (TO to mid-swing), and mid-swing (central 20–25% of the swing interval). Samples outside valid HS–TO–HS structures were removed. The final labeled dataset contained 186,468 stance, 125,033 swing, and 122,431 mid-swing samples. The labeling pipeline is summarized in Figure 2. These annotations served as ground truth for subsequent windowing and model training.

3.1.2. Segmentation and Windowing

After preprocessing, the synchronized multi-channel signals were partitioned into windows of length L = 128 samples across C = 23 channels. For classical machine-learning models, each window X i R L × C was vectorized into a 2944-dimensional feature vector ( 128 × 23 ). Feature scaling was applied only when required by the classifier: kNN models were trained using a pipeline with standardization (StandardScaler), whereas tree-based ensemble models were trained directly on the unscaled vectors, as they are insensitive to monotonic feature transformations.
The final dataset was segmented into fixed-length windows to enable supervised learning from continuous multimodal recordings. Window-based segmentation converts time-series signals into samples suitable for classical machine learning models while preserving the local temporal context relevant for distinguishing stance, swing, and mid-swing phases.
Let x ( t ) R C denote the multichannel sensor vector at time index t, where C = 23 corresponds to the selected right-leg channels used for gait phase prediction. A window of length L is defined as
X i = { x ( t i ) , x ( t i + 1 ) , , x ( t i + L 1 ) } ,
where X i R L × C represents one training instance. In this work, the window length was set to L = 128 samples. With a sampling frequency of 100 Hz, each window spans approximately 1.28 s, which is sufficient to capture a complete gait cycle during normal walking. This duration allows heel-strike, toe-off, and mid-swing events to be contained within a single window, thereby improving phase discrimination. Shorter windows may fail to capture full phase transitions, whereas substantially longer windows increase latency and reduce temporal specificity. A sliding-window strategy with 50% overlap was adopted, resulting in a stride of
S = L 2 = 64 samples .
Overlapping windows increase the sample density and provide a denser temporal coverage of gait dynamics. Although this introduces dependence between adjacent windows, such overlap is commonly used in gait analysis and human activity recognition to improve classification accuracy [34]. This approach is appropriate when the objective is reliable phase classification rather than strict sample independence. Each window was assigned a single class label corresponding to the dominant gait phase within the segment. Three gait phases were considered: stance, swing, and mid-swing (Section 3.1.1). Windows containing ambiguous phase transitions or mixed labels were excluded to reduce label noise and improve classification reliability. Table 4 summarizes the segmentation procedure, and Figure 3 illustrates the sliding-window strategy.

3.2. Machine Learning Models

A set of classical machine learning classifiers was used for gait-phase recognition from extracted time- and frequency-domain features. The evaluated models include Extremely Randomized Trees (Extra Trees) [35], Random Forest, k-Nearest Neighbors (kNN) [36], XGBoost [37], and LightGBM [38]. These algorithms are widely used for structured sensor data and have shown strong performance in human activity recognition and gait classification tasks.
Random Forest and Extra Trees are ensemble methods based on decision trees. Given an input feature vector x R M , each ensemble consists of T trees h t ( x ) trained on bootstrapped samples and random feature subsets [35,36]. For multiclass classification with classes { 1 , , C } , the predicted label is obtained by majority voting:
y ^ = arg max c { 1 , , C } t = 1 T I h t ( x ) = c ,
where I ( · ) is the indicator function. Random Forest uses optimized splits at each node. Extra Trees introduces additional randomness by selecting split thresholds from a random set rather than performing an exhaustive search. This additional randomness can reduce variance and improve performance on noisy, high-dimensional features.
XGBoost and LightGBM are gradient-boosted decision tree methods designed for efficient learning on structured features. Both models iteratively add trees to minimize a regularized loss function. For multiclass problems, the objective typically involves the sum of cross-entropy losses over all samples:
L = i = 1 N l y i , p ^ ( x i ) + t = 1 T Ω ( f t ) ,
where x i is the i-th instance in the dataset, y i is the corresponding class label, p ^ ( x i ) denotes the predicted class probabilities, and Ω ( f t ) penalizes tree complexity.
The kNN classifier is a non-parametric, distance-based method. The distance between two vectors x and z is defined using the Minkowski metric:
d ( x , z ) = m = 1 M | x m z m | p 1 / p .
When p = 1 , the metric corresponds to the Manhattan distance; when p = 2 , it reduces to the Euclidean distance. The k-Nearest Neighbors are then identified, and the predicted class is obtained by distance-weighted voting. Because kNN is sensitive to feature scaling, standardization (i.e., zero mean and unit variance) was applied using a pipeline.
The computational results were obtained using PyCharm version 2025.2.1.1 (build 252.25557.178).

3.3. Machine Learning Model Evaluation and Hyperparameter Tuning

The overall machine learning workflow employed in this study is illustrated in Figure 4. After segmentation and feature preparation, five machine learning models were trained and evaluated using a structured validation strategy combined with systematic hyperparameter tuning. Each model was trained using windowed samples.
Hyperparameters were explored through preliminary tuning experiments to identify model configurations that balance predictive performance, generalization ability, and computational cost [39]. The explored ranges were selected based on common practice in gait analysis and human activity recognition as well as initial exploratory experiments on the training data. This tuning step is essential because the performance of ensemble- and distance-based classifiers is highly sensitive to parameters such as the tree depth, number of estimators, learning rate, and neighborhood size. Table 5 lists the hyperparameter ranges evaluated for each model during the tuning phase. Only the best-performing configurations were retained for the final experiments.
Model performance was evaluated using a two-stage validation strategy. First, the dataset was divided using a stratified 80/20 train–test split to preserve the class proportions across stance, swing, and mid-swing windows. The training subset (80%) was used for model fitting and hyperparameter tuning, while the held-out test subset (20%) was reserved exclusively for final performance reporting. Second, stratified ten-fold cross-validation was used to obtain a robust estimate of generalization performance [40]. The dataset was partitioned into ten non-overlapping folds with approximately equal class proportions. In each iteration, nine folds were used for training and the remaining fold was used for testing. This procedure was repeated ten times, such that each fold served exactly once as the test set, and performance was averaged across folds. Table 6 summarizes the distribution of windowed samples across the three gait phases together with the stratified 80/20 train–test split used in the experiments. Because the dataset exhibits class imbalance, inverse-frequency class weights were computed from the training set and applied to the tree-based models during training to reduce bias toward the majority class. Distance-based classifiers such as kNN were trained without explicit class weighting.
The performance of the machine learning models was evaluated using standard multiclass classification metrics, including accuracy, precision, recall, F1-score, and Matthews correlation coefficient (MCC).
Accuracy = T P + T N T P + T N + F P + F N , Precision = T P T P + F P , Recall = T P T P + F N , F 1 score = 2 × Precision × Recall Precision + Recall , MCC = T P × T N F P × F N ( T P + F P ) ( T P + F N ) ( T N + F P ) ( T N + F N ) .
In these expressions, T P (true positive) denotes the number of samples correctly classified as belonging to a given gait phase, T N (true negative) represents samples correctly identified as not belonging to that phase, F P (false positive) corresponds to samples incorrectly assigned to a gait phase, and F N (false negative) indicates samples belonging to the phase that were misclassified. For multiclass evaluation, these quantities were computed in a one-vs-rest manner for each gait phase and then aggregated using weighted averaging based on class support. Accuracy measures the overall proportion of correctly classified windows. Precision quantifies the correctness of positive predictions, while recall reflects sensitivity to detecting positive instances. The F1-score balances precision and recall and is particularly informative under class imbalance. MCC provides a correlation-based summary metric that remains reliable for imbalanced multiclass classification and was therefore included as a primary evaluation criterion.

4. Results and Discussion

This study tests and compares five machine-learning classifiers for three-phase gait recognition (stance, swing, and mid-swing) using a high-dimensional window-based feature representation extracted from lower-limb wearable sensors. The evaluated models are Extra Trees, Random Forest, kNN, XGBoost, and LightGBM. Performance is assessed using accuracy, precision, recall, F1-score, and Matthews correlation coefficient, thereby providing both overall and class-balanced measures.
The main contribution is an end-to-end and reproducible evaluation framework that enables a controlled comparison of standard methods. Specifically, the pipeline integrates (i) automatic gait-phase relabeling based on heel-strike/toe-off (HS/TO) refinement with adaptive threshold calibration and sensor fusion; (ii) unified feature construction from multimodal wearable signals; and (iii) consistent preprocessing, hyperparameter tuning, and benchmarking across models. This design ensures that observed performance differences can be attributed to the classifiers themselves rather than to inconsistencies in data preparation or tuning, and it clarifies why classical ensemble methods remain strong baselines on this dataset.
The final hyperparameter configurations are reported in Table 7. Parameters were selected based on validation performance under a computationally feasible tuning budget. To ensure comparability and limit overfitting, we tuned only a standard set of high-impact hyperparameters for each model (e.g., number of estimators, maximum depth, learning rate, and subsampling ratios), avoiding extensive search procedures that could inadvertently favor one algorithm over another.

4.1. Test-Set Performance

Table 8 summarizes the test-set performance and the best results are in bold. Extra Trees achieved the best overall performance (accuracy 97.91%, F1 0.9781, MCC 0.9680). Random Forest followed closely (accuracy 97.73%, MCC 0.9652). This confirms that bagging-based ensembles are strong baselines for high-dimensional handcrafted features in this dataset. kNN achieved 93.23% accuracy with an MCC of 0.8961 and trained very quickly (12.77 s). This offers an efficiency advantage but with a clear performance gap to the tree ensembles. XGBoost and LightGBM performed worse in this feature setting, with lower recall and MCC, suggesting a weaker separation of the swing-related phases.
Figure 5 visualizes the normalized confusion matrices. Random Forest and Extra Trees show a strong diagonal structure, indicating stable class separation. Across all models, the largest error concentration is between swing and mid-swing. This is expected because these two phases are adjacent in time and share similar dynamics. XGBoost and LightGBM show more off-diagonal mass, which is consistent with their lower MCC. kNN preserves a relatively clear diagonal but shows more swing–mid-swing confusion than the tree ensembles.

4.2. 10-Fold Cross-Validation

To reduce dependence on a single split, stratified 10-fold cross-validation was performed. Table 9 reports the mean value of each performance metric across folds and the best results are in bold. The cross-validation ranking is consistent with the test-set outcome. Extra Trees achieved the best mean performance (accuracy 0.9787, MCC 0.9676), which is followed by Random Forest; kNN remained above 92% accuracy, while XGBoost and LightGBM performed less well.
Figure 6 shows the averaged confusion matrices across folds. Extra Trees keeps the strongest diagonal dominance and the most consistent class separation. Random Forest behaves similarly but shows slightly higher swing–mid-swing confusion. kNN preserves strong stance separation but shows more confusion within swing-related classes. XGBoost and LightGBM show more off-diagonal mass across multiple class pairs, which is consistent with their lower MCC.

4.3. Comparative Visualizations of Accuracy and Training Time

Figure 7 compares accuracy and training time across models. Extra Trees offers the most favorable trade-off, achieving the highest accuracy while training considerably faster than Random Forest. kNN exhibits the shortest training time but at the cost of lower accuracy. In contrast, XGBoost and LightGBM incur longer training times while achieving lower accuracy in this setting, suggesting that boosting provides limited additional benefit under the current feature representation.
Figure 8 compares the precision, recall, F1-score, and MCC across models. Extra Trees achieves the highest values across all metrics, which is followed by Random Forest. kNN remains competitive but below the bagging ensembles. XGBoost and LightGBM show reduced recall and MCC, which is consistent with larger confusion in swing-related classes.

4.4. Discussion

The strong performance of Extra Trees and Random Forest is consistent with the characteristics of the input representation. The feature vector is high dimensional and includes partially redundant descriptors extracted from multiple sensors. Bagging-based tree ensembles are well suited to such settings because they reduce variance through averaging, capture nonlinear interactions, and do not require feature scaling. In particular, Extra Trees introduces additional randomness in split selection, which can further mitigate overfitting when predictors are highly correlated. Gradient-boosted tree models (XGBoost and LightGBM) can achieve excellent performance in many structured learning tasks; however, in high-dimensional handcrafted feature spaces, they may become more sensitive to noisy or weakly informative predictors and to hyperparameter choices. Under the present feature representation and tuning budget, their lower recall and MCC suggest greater difficulty in separating swing and mid-swing, which is consistent with increased confusion among swing-related phases. kNN remains computationally efficient and competitive, but distance-based classification can be less discriminative when class boundaries are subtle and the underlying manifolds overlap.
The results should be interpreted in the context of the adopted windowing and labeling strategy. Windows were generated with 50% overlap; consequently, adjacent windows share substantial signal content and are highly correlated. Because both train–test splitting and cross-validation were performed at the window level, neighboring windows may appear in different folds, which can lead to optimistic performance estimates relative to trial-wise or subject-independent evaluation. Accordingly, the reported metrics reflect performance under the current dataset and evaluation protocol. In addition, windows containing mixed labels or phase transitions were excluded to reduce ambiguity and establish a clean baseline comparison across models. While this improves label consistency, it also yields an easier classification setting than real-time deployment, where transitions are unavoidable. In practical scenarios, boundary regions around heel-strike and toe-off are expected to increase confusion, particularly between swing and mid-swing. Finally, in order to evaluate the robustness under the evaluated conditions, we observe that the results indicate that tree-based ensembles are relatively robust to moderate feature redundancy and sensor noise within the evaluated dataset. However, the reported performance was obtained under controlled acquisition and preprocessing conditions, including synchronized sensor streams, fixed sampling frequency, and consistent sensor placement. Generalization beyond these conditions may be affected by factors such as sensor drift, placement variability, or changes in walking speed and context. A more comprehensive assessment of robustness would require additional experiments (e.g., controlled noise injection, simulated drift, or deliberate sensor misplacement). Although such analyses are outside the scope of this study, the present results establish a stable baseline under well-defined data acquisition assumptions.

4.5. Comparison with Existing Literature

Compared with previous ML-based gait-phase detection studies Table 10, the performance of the proposed models is competitive and often superior within the IMU-based paradigm.
Farah and Baddour [27] reported a J48 accuracy of 97.5% on thigh-mounted IMU data, closely aligning with the performance of our Random Forest and Extra Trees classifiers. Pazar et al. [29] found Random Forest to be the best-performing model 95.49% for textile-based ankle sensors, though their dataset was significantly smaller and more constrained in walking speeds.
Nazari et al. [30] demonstrated that deep learning outperformed traditional ML models for EMG-based gait intention detection though with higher sensitivity to noise and electrode placement. In contrast, our IMU-based approach avoids these biosignal inconsistencies and achieves higher accuracy without requiring deep neural architectures.
Khamparia et al. [31] reported Random Forest accuracies as high as 98.9% for freeze and non-freeze detection in Parkinson’s patients. Although their task is binary and not directly comparable, the strong performance of Random Forest is consistent with our findings. Pasinetti et al. [9] proposed a modified Random Forest variant based on depth-camera inputs, achieving 87.3% accuracy. Their lower accuracy reflects the inherent challenges of monocular depth imaging and the limited number of detectable gait phases.

4.6. Comparison with Micro-Doppler Radar

Wearable sensing is not the only approach for gait analysis, and non-invasive remote technologies such as micro-Doppler radar have been explored to analyze human motion without on-body sensors. Micro-Doppler radar captures motion-induced frequency modulations related to limb dynamics and has been successfully applied to human activity classification and gait-based recognition tasks using classical machine learning and radar-specific features [41,42,43]. These approaches offer advantages in terms of user comfort and unobtrusive monitoring, particularly in fixed and controlled environments. However, radar-based systems typically address coarse activity recognition or subject identification rather than discrete gait-phase segmentation, and their performance can be affected by subject orientation, environmental clutter, and sensor placement. In contrast, the wearable-sensor framework adopted in this study directly measures limb kinematics and foot–ground interaction, enabling a precise detection of heel-strike and toe-off events and supporting low-latency phase recognition. As a result, wearable sensing remains better suited to real-time closed-loop applications such as prosthetic and exoskeleton control, while micro-Doppler radar represents a complementary solution for unobtrusive gait monitoring and screening in controlled settings.

4.7. Limitations and Future Work

Several limitations should be considered when interpreting these results. First, model evaluation relied on window-level stratified train–test splitting and cross-validation. Because windows were generated with 50% overlap, adjacent samples share substantial signal content and are therefore highly correlated. This dependence can inflate performance estimates relative to stricter protocols (e.g., trial-wise splitting or subject-independent evaluation). Accordingly, the reported metrics should be interpreted as benchmark performance under the current protocol rather than as definitive evidence of generalization to unseen users. Second, the dataset includes a limited number of participants and was collected under controlled laboratory conditions. These factors constrain external validity and may limit generalization to broader populations and to pathological gait patterns. Expanding the cohort size and diversity, and validating on more heterogeneous acquisition settings, would strengthen robustness claims. Third, although bilateral recordings are available, this study used only right-leg signals to reduce model complexity and enable controlled comparisons. This design choice prevents any analysis of inter-limb asymmetries and bilateral coordination, which are important in clinical gait assessment and prosthetic applications. Incorporating bilateral features is therefore a relevant extension of this work. Fourth, windows spanning mixed or transitional gait phases were excluded to provide clean supervision during training. While this improves label consistency for controlled benchmarking, it simplifies the task compared with real-world deployment, where transitions are unavoidable. A more deployment-oriented evaluation should explicitly account for transitions (e.g., via an additional transition class, soft labeling, or boundary-focused error analysis around heel-strike and toe-off events). Finally, the present study focuses on classical and ensemble machine-learning models evaluated under preprocessing and labeling assumptions. Although the results indicate that gait-phase recognition is feasible from these signals, conclusions about real-time prosthetic control require additional validation. In particular, future work should prioritize subject-independent protocols (e.g., leave-one-subject-out cross-validation) and compare against temporal models, including sequence-based and deep learning approaches, within the same standardized pipeline.

5. Conclusions

This study presented a structured and reproducible framework for discrete gait-phase recognition using multimodal lower-limb wearable sensor data. The proposed pipeline integrates automatic gait-phase relabeling based on refined heel-strike and toe-off detection, window-based feature construction from synchronized sEMG, IMU, pressure, and footswitch signals, and the benchmarking of established machine-learning classifiers under a unified evaluation protocol. Five classifiers were trained on the same window-based representation and evaluated using both a held-out test set and stratified cross-validation.
Across all evaluation metrics, tree-based ensemble methods—particularly Extra Trees and Random Forest—consistently achieved the most reliable performance for three-phase gait classification. These models delivered high accuracy and strong agreement measures with stable performance across validation settings. This behavior is consistent with the suitability of bagging-based ensemble methods for high-dimensional, correlated, and nonlinear wearable sensor data, allowing effective learning without extensive feature scaling. In contrast, distance-based and boosting-based methods showed reduced robustness under the same representation and tuning budget, particularly when distinguishing swing-related gait phases.
Overall, the results demonstrate that accurate gait-phase recognition can be achieved under idealized labeling and window-level evaluation conditions by combining reliable automatic relabeling, consistent feature construction, and classical machine-learning models. The proposed framework should therefore be interpreted as a strong baseline and an upper performance bound under the present experimental protocol, providing a transparent reference for future work toward more robust and deployment-ready gait analysis systems.

Author Contributions

Conceptualization, M.F., R.G. and D.C.; methodology, M.F. and R.G.; software, M.F.; validation, M.F.; formal analysis, M.F. and R.G.; investigation, M.F.; data curation, M.F.; writing—original draft preparation, M.F., R.G. and D.C.; writing—review and editing, M.F., R.G. and D.C.; supervision, R.G. and D.C.; project administration, R.G. and D.C. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in the study are included in the article, further inquiries can be directed to the corresponding author.

Acknowledgments

The authors acknowledge their scientific collaboration within the National Research Center for High-Performance Computing, Big Data and Quantum Computing (CN00000013, CUP H23C22000360005), carried out in the framework of the National Recovery and Resilience Plan (PNRR).

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
AIArtificial Intelligence
BMIBody Mass Index
CVCross-Validation
DCNNDeep Convolutional Neural Network
DTDecision Tree
EMGElectromyography
sEMGSurface Electromyography
ExtraTreesExtremely Randomized Trees
FESFunctional Electrical Stimulation
FlexiForceForce-Sensitive Resistor Sensor
GPUGraphics Processing Unit
HSHeel Strike
IDIndoor
IMUInertial Measurement Unit
IMUsInertial Measurement Units
KNNK-Nearest Neighbors
LGBMLight Gradient Boosting Machine
LRLogistic Regression
MCCMatthews Correlation Coefficient
MLMachine Learning
MLPMultilayer Perceptron
NBNaive Bayes
NI-myRIONational Instruments MyRIO Controller
ODOutdoor
RFRandom Forest
RMSRoot Mean Square
SVMSupport Vector Machine
TOToe-Off
XGBExtreme Gradient Boosting

References

  1. Muro-De-La-Herran, A.; Garcia-Zapirain, B.; Mendez-Zorrilla, A. GAIT Analysis Methods: An overview of Wearable and Non-Wearable systems, highlighting clinical applications. Sensors 2014, 14, 3362–3394. [Google Scholar] [CrossRef]
  2. Rani, V.; Kumar, M. Human gait recognition: A systematic review. Multimed. Tools Appl. 2023, 82, 37003–37037. [Google Scholar] [CrossRef]
  3. Li, L.-L.; Cao, G.-Z.; Liang, H.-J.; Zhang, Y.-P.; Cui, F. Human Lower Limb Motion Intention Recognition for Exoskeletons: A Review. IEEE Sens. J. 2023, 23, 30007–30036. [Google Scholar] [CrossRef]
  4. Li, J.; Gu, X.; Qiu, S.; Zhou, X.; Cangelosi, A.; Loo, C.K.; Liu, X. A Survey of Wearable Lower Extremity Neurorehabilitation Exoskeleton: Sensing, Gait Dynamics, and Human–Robot Collaboration. IEEE Trans. Syst. Man Cybern. Syst. 2024, 54, 3675–3693. [Google Scholar] [CrossRef]
  5. Li, W.; Lu, W.; Sha, X.; Xing, H.; Lou, J.; Sun, H.; Zhao, Y. Wearable Gait Recognition Systems Based on MEMS Pressure and Inertial Sensors: A Review. IEEE Sens. J. 2022, 22, 1092–1104. [Google Scholar] [CrossRef]
  6. Bijalwan, V.; Semwal, V.B.; Mandal, T.K. Fusion of Multi-Sensor-Based Biomechanical Gait Analysis Using Vision and Wearable Sensor. IEEE Sens. J. 2021, 21, 14213–14220. [Google Scholar] [CrossRef]
  7. Luo, J.; Wu, H.; Lei, L.; Wang, H.; Yang, T. GCA-Net: Gait Contour Automatic Segmentation Model for Video Gait Recognition. Multimed. Tools Appl. 2022, 81, 34295–34307. [Google Scholar] [CrossRef]
  8. Jamsrandorj, A.; Jung, D.; Kumar, K.S.; Arshad, M.Z.; Lim, H.; Kim, J.; Mun, K.-R. View-Independent Gait Events Detection Using CNN-Transformer Hybrid Network. J. Biomed. Inform. 2023, 147, 104524. [Google Scholar] [CrossRef]
  9. Pasinetti, S.; Fornaser, A.; Lancini, M.; De Cecco, M.; Sansoni, G. Assisted Gait Phase Estimation Through an Embedded Depth Camera Using Modified Random Forest Algorithm Classification. IEEE Sens. J. 2020, 20, 3343–3355. [Google Scholar] [CrossRef]
  10. Tortora, S.; Tonin, L.; Sieghartsleitner, S.; Ortner, R.; Guger, C.; Lennon, O.; Coyle, D.; Menegatti, E.; Felice, A.D. Effect of Lower Limb Exoskeleton on the Modulation of Neural Activity and Gait Classification. IEEE Trans. Neural Syst. Rehabil. Eng. 2023, 31, 2988–3003. [Google Scholar] [CrossRef]
  11. Hollinger, D.; Schall, M.; Chen, H.; Bass, S.; Zabala, M. The Influence of Gait Phase on Predicting Lower-Limb Joint Angles. IEEE Trans. Med. Robot. Bionics 2023, 5, 343–352. [Google Scholar] [CrossRef]
  12. Qin, S.; Chen, X.; Li, P.; Sun, H. Estimation of Gait Subphase Time Parameters Based on a Human Electrostatic Field Detection System. IEEE Sens. J. 2023, 23, 9716–9726. [Google Scholar] [CrossRef]
  13. Benbakhti, A.S.; Boukhenous, S.; Zizoua, C.; Attari, M. An Instrumented Shoe for Ambulatory Prevention of Diabetic Foot Ulceration. In Proceedings of the 4th International Conference on Wireless Mobile Communication and Healthcare—Transforming Healthcare Through Innovations in Mobile and Wireless Technologies (MOBIHEALTH), Athens, Greece, 3–5 November 2014. [Google Scholar] [CrossRef]
  14. Aqueveque, P.; Osorio, R.; Pastene, F.; Saavedra, F.; Pino, E. Capacitive Sensors Array for Plantar Pressure Measurement Insole Fabricated with Flexible PCB. In Proceedings of the 2018 40th Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC); IEEE: Honolulu, HI, USA, 2018; pp. 4393–4396. [Google Scholar] [CrossRef]
  15. Park, J.S.; Lee, C.M.; Koo, S.-M.; Kim, C.H. Gait Phase Detection Using Force Sensing Resistors. IEEE Sens. J. 2020, 20, 6516–6523. [Google Scholar] [CrossRef]
  16. Huang, B.; Chen, M.; Shi, X.; Xu, Y. Gait Event Detection with Intelligent Shoes. In Proceedings of the 2007 International Conference on Information Acquisition, Seogwipo, Republic of Korea, 8–11 July 2007; pp. 579–584. [Google Scholar] [CrossRef]
  17. Nagashima, M.; Cho, S.-G.; Ding, M.; Garcia Ricardez, G.A.; Takamatsu, J.; Ogasawara, T. Prediction of Plantar Forces During Gait Using Wearable Sensors and Deep Neural Networks. In Proceedings of the 2019 41st Annual International Conference of the IEEE Engineering in Medicine and Biology Society (EMBC), Berlin, Germany, 23–27 July 2019; pp. 3629–3632. [Google Scholar] [CrossRef]
  18. Ledoux, E.D. Inertial Sensing for Gait Event Detection and Transfemoral Prosthesis Control Strategy. IEEE Trans. Biomed. Eng. 2018, 65, 2704–2712. [Google Scholar] [CrossRef]
  19. Zhao, H.; Wang, Z.; Qiu, S.; Shen, Y.; Wang, J. IMU-Based Gait Analysis for Rehabilitation Assessment of Patients with Gait Disorders. In Proceedings of the 2017 4th International Conference on Systems and Informatics (ICSAI); IEEE: Hangzhou, China, 2017; pp. 622–626. [Google Scholar] [CrossRef]
  20. Huang, H.; Zhou, P.; Li, Y.; Sun, F. A Lightweight Attention-Based CNN Model for Efficient Gait Recognition with Wearable IMU Sensors. Sensors 2021, 21, 2866. [Google Scholar] [CrossRef]
  21. Mahoney, J.M.; Rhudy, M.B. Methodology and Validation for Identifying Gait Type Using Machine Learning on IMU Data. J. Med. Eng. Technol. 2019, 43, 25–32. [Google Scholar] [CrossRef]
  22. Wu, C.-C.; Wen, Y.-T.; Lee, Y.-J. IMU sensors beneath walking surface for ground reaction force prediction in gait. IEEE Sens. J. 2020, 20, 9372–9376. [Google Scholar] [CrossRef]
  23. Zhang, M.; Wang, Q.; Liu, D.; Zhao, B.; Tang, J.; Sun, J. Real-Time Gait Phase Recognition Based on Time Domain Features of Multi-MEMS Inertial Sensors. IEEE Trans. Instrum. Meas. 2021, 70, 1–12. [Google Scholar] [CrossRef]
  24. Hu, X.; Duan, Q.; Tang, J.; Chen, G.; Zhao, Z.; Sun, Z.; Chen, C.; Qu, X. A Low-Cost Instrumented Shoe System for Gait Phase Detection Based on Foot Plantar Pressure Data. IEEE J. Transl. Eng. Health Med. 2024, 12, 84–96. [Google Scholar] [CrossRef]
  25. Wu, X.; Ma, Y.; Yong, X.; Wang, C.; He, Y.; Li, N. Locomotion Mode Identification and Gait Phase Estimation for Exoskeletons During Continuous Multilocomotion Tasks. IEEE Trans. Cogn. Dev. Syst. 2021, 13, 45–56. [Google Scholar] [CrossRef]
  26. Fadillioglu, C.; Stetter, B.J.; Ringhof, S.; Krafft, F.C.; Sell, S.; Stein, T. Automated Gait Event Detection for a Variety of Locomotion Tasks Using a Novel Gyroscope-Based Algorithm. Gait Posture 2020, 81, 102–108. [Google Scholar] [CrossRef]
  27. Farah, J.D.; Baddour, N.; Lemaire, E.D. Gait Phase Detection from Thigh Kinematics Using Machine Learning Techniques. In Proceedings of the 2017 IEEE International Symposium on Medical Measurements and Applications (MeMeA); IEEE: Rochester, MN, USA, 2017; pp. 263–268. [Google Scholar] [CrossRef]
  28. Alaqtash, M.; Sarkodie-Gyan, T.; Yu, H.; Fuentes, O.; Brower, R.; Abdelgawad, A. Automatic classification of pathological gait patterns using ground reaction forces and machine learning algorithms. In Proceedings of the 2011 Annual Interna tional Conference of the IEEE Engineering in Medicine and Biology Society, Boston, MA, USA, 30 August–3 September 2011; pp. 453–457. [Google Scholar] [CrossRef]
  29. Pazar, A.; Khalilbayli, F.; Ozlem, K.; Yilmaz, A.F.; Atalay, A.T.; Atalay, O.; Ince, G. Gait Phase Recognition Using Textile-Based Sensor. In Proceedings of the 2022 7th International Conference on Computer Science and Engineering (UBMK); IEEE: Diyarbakir, Turkey, 2022; pp. 1–6. [Google Scholar] [CrossRef]
  30. Nazari, F.; Mohajer, N.; Nahavandi, D.; Khosravi, A. Comparison of Gait Phase Detection Using Traditional Machine Learning and Deep Learning Techniques. In Proceedings of the 2022 IEEE International Conference on Systems, Man, and Cybernetics (SMC); IEEE: Prague, Czech Republic, 2022; pp. 403–408. [Google Scholar] [CrossRef]
  31. Khamparia, A.; Gupta, D.; Maashi, M.; Mengash, H.A. Cognitive Driven Gait Freezing Phase Detection and Classification for Neuro-Rehabilitated Patients Using Machine Learning Algorithms. J. Neurosci. Methods 2024, 409, 110183. [Google Scholar] [CrossRef] [PubMed]
  32. Liu, L.; Wang, H.; Li, H.; Liu, J.; Qiu, S.; Zhao, H.; Guo, X. Ambulatory human GAIT phase detection using wearable inertial sensors and hidden Markov model. Sensors 2021, 21, 1347. [Google Scholar] [CrossRef] [PubMed]
  33. Zafar, S.; Maqbool, H.F.; Raza, A.; Zubair, M.; Ishaq, H.N. Development and Evaluation of a Low-Cost Data Acquisition System Using Heterogeneous Sensors. Int. J. Sens. Netw. 2022, 40, 45–56. [Google Scholar] [CrossRef]
  34. Figo, D.; Diniz, P.C.; Ferreira, D.R.; Cardoso, J.M.P. Preprocessing techniques for context recognition from accelerometer data. Pers. Ubiquitous Comput. 2010, 14, 645–662. [Google Scholar] [CrossRef]
  35. Geurts, P.; Ernst, D.; Wehenkel, L. Extremely Randomized Trees. Mach. Learn. 2006, 63, 3–42. [Google Scholar] [CrossRef]
  36. Faisal, A.; Jhanjhi, N.; Ashraf, H.; Ray, S.K.; Ashfaq, F. A Comprehensive Review of Machine Learning Models: Principles, Applications, and Optimal Model Selection. TechRxiv 2025. [Google Scholar] [CrossRef]
  37. Hanif, I. Implementing Extreme Gradient Boosting (XGBoost) Classifier to Improve Customer Churn Prediction. In Proceedings of the 1st International Conference on Statistics and Analytics, ICSA 2019, Bogor, Indonesia, 2–3 August 2019; EAI: Bogor, Indonesia, 2020. [Google Scholar] [CrossRef]
  38. Machado, M.R.; Karray, S.; De Sousa, I.T. LightGBM: An Effective Decision Tree Gradient Boosting Method to Predict Customer Loyalty in the Finance Industry. In Proceedings of the 2019 14th International Conference on Computer Science & Education (ICCSE); IEEE: Toronto, ON, Canada, 2019; pp. pp 1111–1116. [Google Scholar] [CrossRef]
  39. Hossain, R.; Timmer, D. Machine Learning Model Optimization With Hyper Parameter Tuning Approach. Glob. J. Comput. Sci. Technol. 2021, 21, 7–13. [Google Scholar]
  40. Kohavi, R. A study of cross-validation and bootstrap for accuracy estimation and model selection. In Proceedings of the 14th International Joint Conference on Artificial Intelligence (IJCAI’95); Morgan Kaufmann: Montreal, QC, Canada, 1995; Volume 2, pp. 1137–1143. [Google Scholar]
  41. Kim, Y.; Ling, H. Human activity classification based on Micro-Doppler signatures using a support vector machine. IEEE Trans. Geosci. Remote Sens. 2009, 47, 1328–1337. [Google Scholar] [CrossRef]
  42. Ricci, R.; Balleri, A. Recognition of humans based on radar micro-Doppler shape spectrum features. IET Radar Sonar Navig. 2015, 9, 1216–1223. [Google Scholar] [CrossRef]
  43. He, X.; Zhang, Y.; Dong, X. Gait-based human recognition based on millimetre wave multiple input multiple output radar point cloud constructed using velocity-depth-time. IET Radar Sonar Navig. 2024, 18, 1381–1389. [Google Scholar] [CrossRef]
Figure 1. Workflow for assembling the final unified dataset.
Figure 1. Workflow for assembling the final unified dataset.
Applsci 16 01397 g001
Figure 2. Pipeline for the dataset construction.
Figure 2. Pipeline for the dataset construction.
Applsci 16 01397 g002
Figure 3. Sliding-window segmentation with 128-sample windows and 64-sample stride.
Figure 3. Sliding-window segmentation with 128-sample windows and 64-sample stride.
Applsci 16 01397 g003
Figure 4. Pipeline of the machine learning workflow.
Figure 4. Pipeline of the machine learning workflow.
Applsci 16 01397 g004
Figure 5. Normalized confusion matrices computed on the held-out test set for all evaluated models. Panels are listed as follows: (a) Random Forest, (b) Extra Trees, (c) XGBoost, (d) LightGBM, (e) kNN.
Figure 5. Normalized confusion matrices computed on the held-out test set for all evaluated models. Panels are listed as follows: (a) Random Forest, (b) Extra Trees, (c) XGBoost, (d) LightGBM, (e) kNN.
Applsci 16 01397 g005
Figure 6. Normalized confusion matrices averaged over 10-fold stratified cross-validation for all evaluated models. Panels are listed as follows: (a) Random Forest, (b) Extra Trees, (c) XGBoost, (d) LightGBM, (e) kNN.
Figure 6. Normalized confusion matrices averaged over 10-fold stratified cross-validation for all evaluated models. Panels are listed as follows: (a) Random Forest, (b) Extra Trees, (c) XGBoost, (d) LightGBM, (e) kNN.
Applsci 16 01397 g006
Figure 7. Accuracy and training time for all evaluated machine learning models. Panels are listed as follows: (a) test-set accuracy plotted alongside the corresponding training time for each classifier, (b) mean accuracy and training time computed over the 10-fold stratified cross-validation.
Figure 7. Accuracy and training time for all evaluated machine learning models. Panels are listed as follows: (a) test-set accuracy plotted alongside the corresponding training time for each classifier, (b) mean accuracy and training time computed over the 10-fold stratified cross-validation.
Applsci 16 01397 g007
Figure 8. Comparison of precision, recall, F1-score, and MCC across all evaluated machine learning models. Panels are listed as follows: (a) metric values computed on the held-out test set, (b) mean metric values computed over the 10-fold stratified cross-validation.
Figure 8. Comparison of precision, recall, F1-score, and MCC across all evaluated machine learning models. Panels are listed as follows: (a) metric values computed on the held-out test set, (b) mean metric values computed over the 10-fold stratified cross-validation.
Applsci 16 01397 g008
Table 1. Studies on gait-phase detection by machine learning models.
Table 1. Studies on gait-phase detection by machine learning models.
Ref.DatasetML ClassifiersBest ML ModelStudy ContributionLimitations
Farah et al. [27]Thigh IMU (acceleration, angular velocity), knee angle; healthy adultsJ48, Random Forest, MLP, SVMJ48Demonstrates thigh-only IMU sensing can classify four gait phases for orthosis controlSmall dataset; healthy subjects only; controlled walking; fixed sliding window
Pazar et al. [29]Textile-based strain sensor in ankle brace; slow walking dataRandom Forest, SVM, Neural NetworkRandom ForestShows feasibility of low-cost textile sensors for gait-phase detectionVery small sample; limited speeds; lab environment; placement sensitivity
Nazari et al. [30]Multi-channel lower-limb EMG (Mohr dataset)NB, DT, RF, LDA, Deep CNNDeep CNN and RFEvaluates handcrafted vs. deep features; EMG supports early gait-intent detectionEMG noise, electrode instability, high variability; imbalanced data; accuracy fluctuation
Khamparia et al. [31]Daphnet Freezing of Gait dataset; hip and leg accelerometersLR, SVM, RF, DT, KNN, NB, Perceptron with PCA/LDA/SVDRF most reliable; KNN and NB competitive under LDA reductionProvides objective freeze vs. non-freeze detection using multiple ML modelsVery small dataset; limited to Parkinson freezing; binary only; heavy preprocessing
Pasinetti et al. [9]Time-of-Flight depth images from crutches; foot–floor 3D geometryModified Random Forest (“Sigma-z RF”)Improved performance over standard RFUses confidence-based stance/swing classification; robust to ambiguous framesOnly two phases; transition frames unclassified; depth camera sensitive to environment
Table 2. Physical attributes of selected subjects. H = Healthy, R = Rehabilitated, M = Male, F = Female, OD = Outdoor, ID = Indoor.
Table 2. Physical attributes of selected subjects. H = Healthy, R = Rehabilitated, M = Male, F = Female, OD = Outdoor, ID = Indoor.
No.SubjectGenderAge (yrs)Weight (kg)Height (cm)BMISubject IDID/OD
1HM2453177.816.7HP112OD
2F2452162.619.6HP114OD
3M2755165.120.2HP115ID
4M2558182.917.3HP116ID
5M2250165.118.4HP117ID
6RM2762177.819.6UP112ID
Table 3. Wearable sensing hardware and recorded channels. Muscle abbreviations: ST (Semitendinosus), VL (Vastus Lateralis), SOL (Soleus), TA (Tibialis Anterior).
Table 3. Wearable sensing hardware and recorded channels. Muscle abbreviations: ST (Semitendinosus), VL (Vastus Lateralis), SOL (Soleus), TA (Tibialis Anterior).
CategorySensorsPhys.Ch./legTotal
Muscle activitysEMG (ST, VL, SOL, TA)848
Joint kinematicsEncoders (knee, ankle)424
Segment kinematics (shank)IMU (3 acc. + 3 gyro)2612
Segment kinematics (thigh)IMU (3 acc. + 3 gyro)2612
Foot–ground interactionPlantar pressure (heel, toe)424
Foot contact eventsFootswitches (heel, mid, toe)36
Input features 2346
Auxiliary signalsmode, tick_count24
Total channels 2550
Table 4. Sliding-window segmentation pipeline.
Table 4. Sliding-window segmentation pipeline.
StepDescription
Input signals23 selected right-leg sEMG/IMU/pressure/footswitch channels, synchronized at 100 Hz.
Window length128 samples (≈1.28 s).
Stride64 samples (50% overlap).
Label assignmentMajority label inside window; ambiguous windows discarded.
Output tensors ( N , 128 , 23 ) array for training ML models.
Table 5. Hyperparameters explored during model tuning. These parameters were evaluated during the grid or random search phase but were not necessarily retained in the final selected configurations.
Table 5. Hyperparameters explored during model tuning. These parameters were evaluated during the grid or random search phase but were not necessarily retained in the final selected configurations.
ModelParameterValues Explored
Random Forestn_estimators{50, 100, 150, 200, 300}
max_features{sqrt, log2, None}
min_samples_split{2, 5, 10}
min_samples_leaf{1, 2, 4}
max_depth{None, 10, 20, 30}
Extra Treesn_estimators{100, 200, 400}
max_depth{10, 20, 30, None}
max_features{sqrt, log2, None}
min_samples_split{2, 5, 10}
XGBoost (GPU)learning_rate{0.05, 0.1, 0.2, 0.3}
n_estimators{200, 300, 350, 400}
max_depth{4, 6, 8, 10}
subsample{0.6, 0.7, 0.8}
colsample_bytree{0.6, 0.7, 0.8}
gamma{0, 0.1, 0.2}
LightGBM (GPU)num_leaves{31, 63, 127, 255}
max_depth{5, 10, 15, −1}
learning_rate{0.05, 0.1, 0.2, 0.3}
subsample{0.6, 0.7, 0.8}
colsample_bytree{0.6, 0.7, 0.8}
n_estimators{150, 200, 250, 300}
kNN + StandardScalern_neighbors{3, 5, 7, 11, 15}
weights{uniform, distance}
p (Minkowski){1, 2}
Table 6. Summary of dataset window distribution, stratified train–test split, and class weights used during model training.
Table 6. Summary of dataset window distribution, stratified train–test split, and class weights used during model training.
Gait PhaseTotal WindowsTrain (80%)Test (20%)
Stance186,468149,17437,294
Swing125,033100,02625,007
Mid-swing122,43197,94524,486
Class Weights0.7761.1571.181
Table 7. Hyperparameter configurations of the ML models used for gait-phase classification.
Table 7. Hyperparameter configurations of the ML models used for gait-phase classification.
ModelKey Hyperparameters (Final Configuration)
Random Forestn_estimators = 200; max_depth = None; min_samples_split = 2; min_samples_leaf = 1; max_features = log2; n_jobs = −1; random_state = 42.
ExtraTreesn_estimators = 100; max_depth = 30; min_samples_split = 5; min_samples_leaf = 1; max_features = sqrt; n_jobs = −1; random_state = 42.
XGBoost (GPU)objective = multi:softprob; num_class = 3; eval_metric = mlogloss; n_estimators = 350; max_depth = 8; learning_rate = 0.2; subsample = 0.7; colsample_bytree = 0.7; gamma = 0.0; tree_method = gpu_hist; predictor = gpu_predictor; n_jobs = −1; random_state = 42.
LightGBM (GPU)objective = multiclass; num_class = 3; device_type = gpu; n_estimators = 250; max_depth = 10; num_leaves = 127; learning_rate = 0.2; subsample = 0.7; colsample_bytree = 0.7; random_state = 42.
kNN (with scaling)Standardization via StandardScaler; n_neighbors = 5; weights = ’distance’; Minkowski distance with p = 1 (Manhattan).
Table 8. Test-set classification performance for all models.
Table 8. Test-set classification performance for all models.
ModelAccuracyPrecisionRecallF1MCCTraining Time (s)
Random Forest0.97730.97670.97580.97620.96521410.54
Extra Trees0.97910.97820.97800.97810.9680481.56
XGBoost0.91320.91690.90570.91060.8670435.18
LightGBM0.87280.87560.86380.86880.8047232.34
kNN0.93230.93160.92820.92980.896112.77
Table 9. Summary of 10-fold cross-validation results (mean across all folds).
Table 9. Summary of 10-fold cross-validation results (mean across all folds).
ModelAccuracyMacro PrecisionMacro RecallMacro F1MCC
Random Forest0.97580.97540.97380.97460.9628
Extra Trees0.97870.97840.97780.97800.9676
XGBoost0.90970.91300.90310.90770.8627
LightGBM0.87280.87600.86380.86890.8049
kNN0.92390.92320.91890.92140.8835
Table 10. Comparison of existing ML-based gait phase detection studies.
Table 10. Comparison of existing ML-based gait phase detection studies.
ReferenceModel and MethodAccuracy
Farah and Baddour [27]J48, Random Forest, MLP, SVMJ48 = 97.5%
Pazar et al. [29]Random Forest, SVM, Neural Network (textile strain sensor)RF = 95.49%
Nazari et al. [30]NB, DT, RF, LDA (handcrafted EMG), Deep CNN (raw EMG)ML models up to 75%; DCNN = 79% (max 89.5%)
Khamparia et al. [31]LR, SVM, RF, DT, KNN, NB, Perceptron + PCA/LDA/SVDRF = 98.9%
Pasinetti et al. [9]Modified Random Forest (“Sigma-z RF”) on depth-camera features87.3% (higher than standard RF)
Proposed StudyExtra Trees, RF, XGBoost, LightGBM, KNNExtra Trees = 97.91 % , RF = 97.73%, KNN = 93.23%, XGBoost = 91.32%, LightGBM = 87.28%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Fiaz, M.; Guido, R.; Conforti, D. Machine Learning Models for Reliable Gait Phase Detection Using Lower-Limb Wearable Sensor Data. Appl. Sci. 2026, 16, 1397. https://doi.org/10.3390/app16031397

AMA Style

Fiaz M, Guido R, Conforti D. Machine Learning Models for Reliable Gait Phase Detection Using Lower-Limb Wearable Sensor Data. Applied Sciences. 2026; 16(3):1397. https://doi.org/10.3390/app16031397

Chicago/Turabian Style

Fiaz, Muhammad, Rosita Guido, and Domenico Conforti. 2026. "Machine Learning Models for Reliable Gait Phase Detection Using Lower-Limb Wearable Sensor Data" Applied Sciences 16, no. 3: 1397. https://doi.org/10.3390/app16031397

APA Style

Fiaz, M., Guido, R., & Conforti, D. (2026). Machine Learning Models for Reliable Gait Phase Detection Using Lower-Limb Wearable Sensor Data. Applied Sciences, 16(3), 1397. https://doi.org/10.3390/app16031397

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop