Social media has become a primary platform for the public to express opinions on government policies, including Indonesia’s Free Nutritious Meal (MBG) program. This study analyzes public sentiment toward MBG by comparing the K-Nearest Neighbor (KNN) and Naive Bayes algorithms. A total of 9,723 tweets were collected, and after removing the neutral category, 6,322 tweets remained (3,955 positive and 2,367 negative), indicating a dominance of positive opinions. The experimental results show that KNN performed best at k=9 with a 70:30 split, achieving an accuracy of 72.27% and an F1-score of 65.92%, with an average cross-validation accuracy of 73.30%. Naive Bayes with parameter α=0.5 consistently outperformed KNN, achieving an average accuracy of 79.61% and an F1-score of 77.33%, along with better precision–recall balance. The main contribution of this research is providing empirical evidence that Naive Bayes is more effective than KNN for sentiment analysis of Indonesian-language text with a large dataset, as well as offering a methodological framework applicable to the evaluation of other public policies.Media sosial menjadi ruang utama masyarakat untuk mengekspresikan opini terhadap kebijakan publik, termasuk Program Makan Bergizi Gratis (MBG) di Indonesia. Penelitian ini menganalisis sentimen publik terhadap MBG dengan membandingkan algoritma K-Nearest Neighbor (KNN) dan Naive Bayes. Data diperoleh dari 9.723 tweet, kemudian setelah penghapusan kategori netral tersisa 6.322 tweet (3.955 positif dan 2.367 negatif), yang menunjukkan dominasi opini positif. Hasil eksperimen menunjukkan bahwa KNN terbaik pada k=9 dengan rasio 70:30 menghasilkan akurasi 72,27% dan F1-score 65,92%, dengan akurasi rata-rata cross-validation 73,30%. Naive Bayes dengan parameter α=0,5 unggul dengan akurasi rata-rata 79,61% dan F1-score 77,33%, serta keseimbangan presisi dan recall yang lebih baik. Kontribusi penelitian ini adalah memberikan bukti empiris bahwa Naive Bayes lebih efektif dibandingkan KNN dalam analisis sentimen teks berbahasa Indonesia dengan dataset besar, serta menawarkan kerangka metodologis yang dapat diterapkan untuk evaluasi kebijakan publik lainnya.
Copyrights © 2025