Syahrina Indah Harahap; Ilka Zufria; Abdul Halim Hasugian
This research aims to classify students’ lifestyles using the K-Nearest Neighbors (KNN) algorithm. The dataset consists of 392 high school students obtained from Kaggle, with key attributes including study hours, social media usage, Netflix viewing duration, attendance, sleep quality, internet quality, mental health, and extracurricular activities. KNN was chosen for its simplicity in distance-based classification, measured using Euclidean Distance. The data was divided into training and testing sets, then evaluated using accuracy and a confusion matrix. The results show that KNN effectively classifies students’ lifestyles into four categories: healthy, less active, at risk, and highly at risk. This classification is expected to assist educational institutions, parents, and students in understanding lifestyle patterns and their impact on academic performance and mental well-being. Furthermore, this study emphasizes the relevance of applying machine learning in education, aligned with Islamic values concerning health, discipline, and the optimal use of time.