Background: Mild cognitive impairment (MCI) poses significant challenges in early diagnosis and timely intervention.Underdiagnosis, coupled with the economic and social burden of dementia, necessitates more precise detection methods. Machinelearning (ML) algorithms show promise in managing complex data for MCI and dementia prediction.Objective: This study assessed the predictive accuracy of ML models in identifying the onset of MCI and dementia using theKorean Longitudinal Study of Aging (KLoSA) dataset. Methods: This study used data from the KLoSA, a comprehensive biennial survey that tracks the demographic, health, andsocioeconomic aspects of middle-aged and older Korean adults from 2018 to 2020. Among the 6171 initial households, 4975eligible older adult participants aged 60 years or older were selected after excluding individuals based on age and missing data.The identification of MCI and dementia relied on self-reported diagnoses, with sociodemographic and health-related variablesserving as key covariates. The dataset was categorized into training and test sets to predict MCI and dementia by using multiplemodels, including logistic regression, light gradient-boosting machine, XGBoost (extreme gradient boosting), CatBoost, randomforest, gradient boosting, AdaBoost, support vector classifier, and k-nearest neighbors, and the training and test sets were usedto evaluate predictive performance. The performance was assessed using the area under the receiver operating characteristic curve(AUC). Class imbalances were addressed via weights. Shapley additive explanation values were used to determine the contributionof each feature to the prediction rate. Results: Among the 4975 participants, the best model for predicting MCI onset was random forest, with a median AUC of0.6729 (IQR 0.3883-0.8152), followed by k-nearest neighbors with a median AUC of 0.5576 (IQR 0.4555-0.6761) and supportvector classifier with a median AUC of 0.5067 (IQR 0.3755-0.6389). For dementia onset prediction, the best model was XGBoost,achieving a median AUC of 0.8185 (IQR 0.8085-0.8285), closely followed by light gradient-boosting machine with a medianAUC of 0.8069 (IQR 0.7969-0.8169) and AdaBoost with a median AUC of 0.8007 (IQR 0.7907-0.8107). The Shapley valueshighlighted pain in everyday life, being widowed, living alone, exercising, and living with a partner as the strongest predictorsof MCI. For dementia, the most predictive features were other contributing factors, education at the high school level, educationat the middle school level, exercising, and monthly social engagement Conclusions: ML algorithms, especially XGBoost, exhibited the potential for predicting MCI onset using KLoSA data. However,no model has demonstrated robust accuracy in predicting MCI and dementia. Sociodemographic and health-related factors arecrucial for initiating cognitive conditions, emphasizing the need for multifaceted predictive models for early identification andintervention. These findings underscore the potential and limitations of ML in predicting cognitive impairment incommunity-dwelling older adults