/GIK-SimpleKNN

This is a weekly task for GIK research program (ML topics)

Primary LanguageC++

Garuda Ilmu Komputer - Weekly Task

K-Nearest Neighbor Implementation


Table of Contents

  1. General Info
  2. Creator Info
  3. Features
  4. Technologies Used
  5. Setup
  6. Usage
  7. Screenshots
  8. Structure
  9. Project Status
  10. Room for Improvement
  11. Acknowledgements
  12. Contact

General Information

A simple program to implement K-Nearest Neighbor algorithm. The program will randomly generate 1000 data points with 2 features (x and y). The program will then ask user input for X and Y value that want to be assigned as pivot point. After that, the program will ask user input for K value. The program will then calculate the distance between the pivot point and all the data points. The program will then sort the data points based on the distance from the pivot point. The program will then show the K nearest data points to the pivot point. This program is made for GIK research program - ML Topics at Week01-March.

Creator Information

Nama NIM E-Mail
Mohammad Rifqi Farhansyah 13521166 13521166@std.stei.itb.ac.id

Features

  • Generate 1000 data points with 2 features (x and y)
  • Ask user input for X and Y value that want to be assigned as pivot point
  • Ask user input for K value
  • Calculate the distance between the pivot point and all the data points
  • Sort the data points based on the distance from the pivot point
  • Show the K nearest data points to the pivot point
  • Visualize the data points and the pivot point with different color (using GNUPlot)

Technologies Used

  • MingGw-W64 version 8.1.0

Note: The version of the libraries above is the version that we used in this project. You can use the latest version of the libraries.

Setup

  1. Download the MingW-W64 from here.
  2. Install the MingW-W64.

Usage

  1. Open the terminal in the project directory.
  2. cd output and then k_nearest_neighbor.exe to run the program.
  3. Input the X and Y value that want to be assigned as pivot point.
  4. Input the K value.
  5. The program will then calculate the distance between the pivot point and all the data points.
  6. Program will sort the data points based on the distance from the pivot point.
  7. KNN Simple Program will output the K nearest data points to the pivot point.
  8. The program will then visualize the data points and the pivot point with different color (using GNUPlot).

Screenshots

Figure 1. Main Menu

Figure 2. Nearest Points Output

Figure 3. Visualization of The Points

Structure

│   Doc.docx
│   gnu_plot_script.plt
│   k_nearest_neighbour.cpp
│   README.md
│
├───.vscode
│       c_cpp_properties.json
│       launch.json
│       settings.json
│
├───image
│       SS1.png
│       SS2.png
│       SS3.png
│
└───output
        k_nearest_neighbour.exe
        near_points_file.txt

Project is: complete

Room for Improvement:

  • Optimalization of the KNN algorithm
  • Add more features
  • Thanks To Allah SWT

Contact

Contact Me : mrifki193@gmail.com
2023