Giter Club home page Giter Club logo

kneighborsclassifier's Introduction

K-Nearest Neighbors (KNN) Classifier for Car Evaluation Dataset

This repository contains Python code implementing a KNN classifier for the Car Evaluation Data Set as part of a Machine Learning course project at my study in the University of Ottawa in 2023.

  • Required libraries: scikit-learn, pandas, matplotlib.
  • Execute cells in a Jupyter Notebook environment.
  • The uploaded code has been executed and tested successfully within the Google Colab environment.

Multi-class classification problem

Task is to classify the car dataset into 4 classes: Unacceptable /Acceptable /Good /Very good.

Independent Variables:

  • 'Buying': buying price
  • 'Maint': maintenance price
  • 'Doors': numbers of doors
  • 'Persons': capacity in terms of persons to carry
  • 'Lug_boot': Size of luggage boot
  • 'Safety': estimated safety of the car

Target variable:

  • 'Evaluation'

Key Tasks Undertaken

  1. Data Preparation:

    • Organized a 1728-sample dataset into distinct subsets:
      • Training (1000 samples),
      • Validation (300 samples), and
      • Testing (428 samples) using Python for accurate model assessment. merge_from_ofoct
  2. Preprocessing:

    • Transformed categorical string attributes into numerical representations, enabling the application of distance-based metrics, such as Euclidean distance, crucial for KNN classification.
  3. Exploring Training Sample Sizes:

    • Investigated the influence of diverse training sample sizes (ranging from 10% to 100% of the training set) on model performance.

    • Evaluated and measured accuracy on both the validation and test sets, discerning the impact of varying training sample sizes on model accuracy.

      image image

      • Using 10%-40% from the training set means, that the training set size is less than the validation and test set size so validation and testing accuracy in these points are meaningless because the model didn’t train enough.
      • From 50% - 100% our model starts to train well until reaches to 100% with the best validation and testing accuracy.
  4. Optimization of K Value:

    • Identified the most suitable K value (from 1 to 10) using the complete training set.
    • Visualized the effect of different K values through an accuracy curve plotted on the validation set, illustrating the performance variance of the KNN classifier. image

kneighborsclassifier's People

Contributors

rimtouny avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.