Skip to content

kaydata/Classification-using-K-K-Nearest-Neighbors-KNN-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

K-Nearest Neighbors (KNN) Classification with Python - README

This repository contains a Python implementation of the K-Nearest Neighbors (KNN) algorithm for classification. We use the Iris dataset as the example for demonstrating the steps of the machine learning workflow.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This project is written in Python 3. You will need the following Python packages installed:

NumPy
Pandas
Matplotlib
Seaborn
scikit-learn

You can install these packages using pip:

pip install numpy pandas matplotlib seaborn scikit-learn

Running the code

The code consists of various sections that correspond to each step of the machine learning workflow, from loading and preprocessing the data, to training the model, to evaluating its performance.

Code Details

Loading the data: The Iris dataset is loaded from a CSV file.

  • Data Preprocessing: We check for missing values and perform exploratory data analysis, using visualizations where appropriate. The data is then split into features (X) and labels (y).

  • Splitting the dataset: The dataset is split into a training set and a test set.

  • Building the KNN model: We use the scikit-learn library to create a KNN classifier. A grid search is performed to find the optimal number of neighbors.

  • Training the model: The model is trained on the training set.

  • Making predictions: The model makes predictions on the test set. An example prediction is also made on new, unseen data.

  • Evaluating the model: We calculate the accuracy of the model and display the confusion matrix. We also perform cross-validation and generate a classification report for further evaluation.

Feedback

If you have any feedback or questions about this project, feel free to open an issue or submit a pull request.

Authors KENNETH MURIUKI KIMATHI

License This project is licensed under the MIT License

Acknowledgments

Thanks to the UCI Machine Learning Repository for providing the Iris dataset. Thanks to the scikit-learn team for their machine learning library.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published