Skip to content

This repository contains a simple implementation of the k-Nearest Neighbors (k-NN) algorithm in Python, a popular machine learning method for classification and regression tasks.

Notifications You must be signed in to change notification settings

sahanddddd/Implementation-of-kNN-algorithm-from-scratch-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Implementation-of-kNN-algorithm-from-scratch-in-Python

This repository contains a simple implementation of the k-Nearest Neighbors (k-NN) algorithm in Python, a popular machine learning method for classification and regression tasks.

Overview

The k-NN algorithm works by analyzing the distances between data points to make predictions based on the majority vote of the k-nearest neighbors. This implementation includes functions for calculating various distance measures (Euclidean, Manhattan, and cosine distance) and finding the k-nearest neighbors for a given data point.

Features

  • Simple implementation of the k-Nearest Neighbors algorithm
  • Distance calculation using Euclidean, Manhattan, and cosine distance measures
  • Data preprocessing functions for MinMax scaling and standard scaling
  • Train and test dataset splitting
  • Data visualization through scatter plot matrices

Dependencies

  • NumPy
  • pandas
  • Matplotlib
  • scikit-learn (only for loading the example dataset)

Usage

  • Clone the repository
  • Install the required dependencies
  • Import the necessary functions and libraries
  • Load your dataset and preprocess it (if necessary)
  • Apply the k-Nearest Neighbors algorithm to your dataset

About

This repository contains a simple implementation of the k-Nearest Neighbors (k-NN) algorithm in Python, a popular machine learning method for classification and regression tasks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published