KNN (K Nearest Neighbors)

Machine Learning


  • Jingsai Liang Westminster College


This activity focuses on predicting the property of unknown points based on the similarity of K nearest neighbors on a two-dimensional plane. Specifically, in model 1, students will predict the color of an unknown point using KNN classification. In model 2, students will predict the y value of a point using KNN regression. In both two models, students will discuss the choice of the optimal K.

This activity was developed with NSF support through IUSE-1626765. You may request access to this activity via the following link: IntroCS-POGIL Activity Writing Program

  • Level: Undergraduate
  • Setting: Classroom
  • Activity Type: Learning Cycle
  • Discipline: Computer Science
  • Course: Machine Learning
  • Keywords: nearest neighbors, classification, regression




How to Cite

Liang, J. (2022). KNN (K Nearest Neighbors): Machine Learning. POGIL Activity Clearinghouse, 3(4). Retrieved from



CS-POGIL Activity Writing Program