This repository contains implementations of the K-Nearest Neighbors (KNN) algorithm in both C++ and Python, along with a comparison of their runtime performance.
K-Nearest Neighbors is a simple yet powerful classification algorithm widely used in machine learning and pattern recognition. In this repository, we provide implementations of KNN in both C++ and Python to explore the differences in runtime performance between the two languages.
- main.cpp: C++ implementation of the KNN algorithm.
- main.py: Python implementation of the KNN algorithm.
- data.csv: Sample datasets for testing the implementations.
-
C++ Implementation: Compile
main.cppusing your preferred C++ compiler.g++ -o main main.cpp
Run the compiled executable:
./main
-
Python Implementation: Run
main.pyusing Python.python main.py
We measure the runtime performance of both implementations using various datasets and report the results in the performance_comparison.md file.
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or create a pull request.