Work

Optimization of KNN Classification for ECG Data Analysis: Comparative Study of Model Performance Using the Hyperparameter Tuning and Cross-Validation

Year: 2025
Type: article
Abstract: Abnormal heart rhythms such as arrhythmias can lead to severe complications, including stroke and cardiac arrest. Electrocardiography (ECG) is commonly used to monitor heart activity due to its non-invasive, affordable, and efficient nature. However, manual ECG interpretation can be time-consuming and error-prone, especially in high-demand clinical settings. This study aims to improve the performance of the K-Nearest Neighbors (KNN) algorithm for ECG signal classification by applying hyperparameter tuning and validating the results through cross-validation. ECG data were collected from participants under three physical activity conditions: sitting, walking, and running. The methodology included signal preprocessing, model development, hyperparameter tuning via Grid Search, and performance validation using K-fold cross-validation. The baseline KNN model achieved an accuracy of 78%. After optimization—by setting the number of neighbors to 16, using the Manhattan distance metric, and applying distance-based weighting—accuracy improved to 82%. Precision increased from 0.79 to 0.82, and the F1-score rose from 0.76 to 0.79. These results demonstrate the impact of systematic tuning on classification performance. An optimized KNN model offers a practical diagnostic aid for arrhythmia detection, particularly in settings with limited access to expert analysis. Its simplicity and low computational cost make it suitable for integration into portable diagnostic devices
Authors: Miftahul Jannah, Adli Abdillah Nababan
Language: English
Field: Medicine
Open Access status: diamond
OpenAlex ID: W7081921261
FWCI:
Cites:
Cited by:
Related to: