Sensor-based Human Activity Recognition has advanced rapidly, incorporating techniques such as sliding windows, feature extraction, and machine-learning parameter optimization for activity classification. Sliding windows and feature extraction are vital, as they occur early and significantly influence the classification outcomes. The proposed novel approach involves using feature ratios from three sub-windows and a static window combined with feature selection via Analysis of Variance (ANOVA) and machine learning algorithms such as Artificial Neural Networks (ANN) and Extreme Gradient Boosting (XGBoost). The primary objective of the proposed approach is to enhance the efficacy of machine-learning algorithms for recognizing human activities. The effectiveness of the proposed approach is evaluated using three datasets: FORTH-TRACE, SBHARPT, and WISDM. The experimental results indicate that the highest accuracy, precision, recall, and F1 score were achieved on the WISDM dataset, with values of 97.64%, 97.64%, 97.64%, and 97.64%, respectively, using 45 features and an Artificial Neural Network (ANN) classifier. The experiments demonstrated that an overlapping window of 25% enhanced the performance of the machine-learning model.