SlideShare a Scribd company logo
DATA STRUCTURES PROJECT
โ€ข Project name:
C++ implementation of KNN algorithm.
โ€ข Group members:
Muhammad Umair 2015-CS-05
Afraz Khan 2015-CS-27
Hassan Tariq 2015-CS-67
BACKGROUND
โ€œClassification is a data mining technique used to predict group
membership for data instances.โ€
โ€ข The group membership is utilized in for the prediction of the
future data sets.
ORIGINS OF K-NN
โ€ข Nearest Neighbors have been used in statistical estimation and
pattern recognition already in the beginning of 1970โ€™s (non-
parametric techniques).
โ€ข The method prevailed in several disciplines and still it is one
of the top 10 Data Mining algorithm.
DEFINITION
โ€ข K-Nearest Neighbor is considered a lazy learning algorithm
that classifies data sets based on their similarity with
neighbors.
โ€ข โ€œKโ€ stands for number of data set items
that are considered for the classification.
Ex: Image shows classification for different k-values.
TECHNICALLYโ€ฆ..
โ€ข For the given attributes A={X1, X2โ€ฆ.. XD} Where D is the
dimension of the data, we need to predict the corresponding
classification group G={Y1,Y2โ€ฆYn} using the proximity
metric over K items in D dimension that defines the closeness
of association such that X โ‚ฌ RD and Yp โ‚ฌ G.
THAT ISโ€ฆ.
โ€ข Attribute A={Color, Outline, Dot}
โ€ข Classification Group,
G={triangle, square}
โ€ข D=3, we are free to choose K value.
Attributes A
C
l
a
s
s
i
f
i
c
a
t
i
o
n
G
r
o
u
p
K-NN IN ACTION
โ€ข Consider the following data:
A={weight,color}
G={Apple(A), Banana(B)}
โ€ข We need to predict the type of a
fruit with:
weight = 378
color = red
SOME PROCESSINGโ€ฆ.
โ€ข Assign color codes to convert into numerical data:
โ€ข Letโ€™s label Apple as โ€œAโ€ and
Banana as โ€œBโ€
K-NN VARIATIONS
โ€ข (K-l)-NN: Reduce complexity by having a threshold on the
majority. We could restrict the associations through (K-l)-NN.
Ex: Decide if majority is over a given
threshold l. Otherwise reject.
Here, K=5 and l=4. As there is no
majority with count>4. We reject
to classify the element.
K-NN PROPERTIES
โ€ข K-NN is a lazy algorithm
โ€ข The processing defers with respect to K value.
โ€ข Result is generated after analysis of stored data.
โ€ข It neglects any intermediate values.
REMARKS: FIRST THE GOOD
Advantages
โ€ข Can be applied to the data from any distribution
for example, data does not have to be separable with a linear
boundary
โ€ข Very simple and intuitive
โ€ข Good classification if the number of samples is large enough
NOW THE BADโ€ฆ.
Disadvantages
โ€ข Dependent on K Value
โ€ข Test stage is computationally expensive
โ€ข No training stage, all the work is done during the test stage
โ€ข This is actually the opposite of what we want. Usually we can
afford training step to take a long time, but we want fast test step
โ€ข Need large number of samples for accuracy
C++ IMPLEMENTATION
Working process:
โ€ข Dataset input from a file.
โ€ข Input a new instance.
โ€ข Input the threshold(K).
โ€ข Classification of dataset.
โ€ข Output give most common class according to the instance
entered.
We will at 1st add our DatSet to the WEKA & also to our C++ Prog:
Weka file uploading C++ file uploading
Then user will enter a instance/TUPLE along with a K value to classify instances:
We can set value of K in WEKA same as in C++ Prog:
Just right click the algorithm applied and change K value as U want.
We will apply KNN algorithm to dataset in WEKA while in C++ we have a devised a
sorting algorithm which will give K instances closest to entered tuple.
We can see both C++ & WEKA output as approximately they are same. There may be
some differences in outputs because in C++ we enter tuple by our own will.
Ad

More Related Content

What's hot (20)

Quantum cryptography
Quantum cryptographyQuantum cryptography
Quantum cryptography
Sukhdeep Kaur
ย 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
ย 
strong slot and filler
strong slot and fillerstrong slot and filler
strong slot and filler
BMS Institute of Technology and Management
ย 
iot enabling technologies for IOT subject
iot enabling technologies for IOT subjectiot enabling technologies for IOT subject
iot enabling technologies for IOT subject
KotiBabu7
ย 
Model Performance Metrics. Accuracy, Precision, Recall
Model Performance Metrics. Accuracy, Precision, RecallModel Performance Metrics. Accuracy, Precision, Recall
Model Performance Metrics. Accuracy, Precision, Recall
Megha Sharma
ย 
Lan technologies
Lan technologiesLan technologies
Lan technologies
Manusha Dilan
ย 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
Nilu Desai
ย 
Machine learning clustering
Machine learning clusteringMachine learning clustering
Machine learning clustering
CosmoAIMS Bassett
ย 
Quantum Cryptography - Quantum Coin Tossing
Quantum Cryptography - Quantum Coin TossingQuantum Cryptography - Quantum Coin Tossing
Quantum Cryptography - Quantum Coin Tossing
Ruwan Ranganath
ย 
CONFUSION MATRIX.ppt
CONFUSION MATRIX.pptCONFUSION MATRIX.ppt
CONFUSION MATRIX.ppt
ssuser95fe88
ย 
Neural networks in robotics
Neural networks in roboticsNeural networks in robotics
Neural networks in robotics
Yasmin Mohamed
ย 
Graphs, frames and related structures
Graphs, frames and related structuresGraphs, frames and related structures
Graphs, frames and related structures
Dr. SURBHI SAROHA
ย 
Hetro associative memory
Hetro associative memoryHetro associative memory
Hetro associative memory
DEEPENDRA KORI
ย 
8 queens problem using ga
8 queens problem using ga8 queens problem using ga
8 queens problem using ga
Learning Courses Online
ย 
Ai 8 puzzle problem
Ai 8 puzzle problemAi 8 puzzle problem
Ai 8 puzzle problem
Sanad Bhowmik
ย 
Quantum computer
Quantum computerQuantum computer
Quantum computer
Kumar Abhijeet
ย 
Forward Backward Chaining
Forward Backward ChainingForward Backward Chaining
Forward Backward Chaining
QAU ISLAMABAD,PAKISTAN
ย 
RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy Networks
Pradeep Kumar TS
ย 
Ring topologoy
Ring  topologoyRing  topologoy
Ring topologoy
Nets international LLC
ย 
KNN
KNN KNN
KNN
West Virginia University
ย 
Quantum cryptography
Quantum cryptographyQuantum cryptography
Quantum cryptography
Sukhdeep Kaur
ย 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
Vaibhav Khanna
ย 
iot enabling technologies for IOT subject
iot enabling technologies for IOT subjectiot enabling technologies for IOT subject
iot enabling technologies for IOT subject
KotiBabu7
ย 
Model Performance Metrics. Accuracy, Precision, Recall
Model Performance Metrics. Accuracy, Precision, RecallModel Performance Metrics. Accuracy, Precision, Recall
Model Performance Metrics. Accuracy, Precision, Recall
Megha Sharma
ย 
Lan technologies
Lan technologiesLan technologies
Lan technologies
Manusha Dilan
ย 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
Nilu Desai
ย 
Machine learning clustering
Machine learning clusteringMachine learning clustering
Machine learning clustering
CosmoAIMS Bassett
ย 
Quantum Cryptography - Quantum Coin Tossing
Quantum Cryptography - Quantum Coin TossingQuantum Cryptography - Quantum Coin Tossing
Quantum Cryptography - Quantum Coin Tossing
Ruwan Ranganath
ย 
CONFUSION MATRIX.ppt
CONFUSION MATRIX.pptCONFUSION MATRIX.ppt
CONFUSION MATRIX.ppt
ssuser95fe88
ย 
Neural networks in robotics
Neural networks in roboticsNeural networks in robotics
Neural networks in robotics
Yasmin Mohamed
ย 
Graphs, frames and related structures
Graphs, frames and related structuresGraphs, frames and related structures
Graphs, frames and related structures
Dr. SURBHI SAROHA
ย 
Hetro associative memory
Hetro associative memoryHetro associative memory
Hetro associative memory
DEEPENDRA KORI
ย 
Ai 8 puzzle problem
Ai 8 puzzle problemAi 8 puzzle problem
Ai 8 puzzle problem
Sanad Bhowmik
ย 
Quantum computer
Quantum computerQuantum computer
Quantum computer
Kumar Abhijeet
ย 
RPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy NetworksRPL - Routing Protocol for Low Power and Lossy Networks
RPL - Routing Protocol for Low Power and Lossy Networks
Pradeep Kumar TS
ย 

Similar to KNN Algorithm using C++ (20)

Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim HunterDeep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Databricks
ย 
Clustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn TutorialClustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn Tutorial
Damian R. Mingle, MBA
ย 
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfvPCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
Sravani477269
ย 
Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1
khairulhuda242
ย 
MachineLearning.pptx
MachineLearning.pptxMachineLearning.pptx
MachineLearning.pptx
Bangtangurl
ย 
Ensemble_instance_unsupersied_learning 01_02_2024.pptx
Ensemble_instance_unsupersied_learning 01_02_2024.pptxEnsemble_instance_unsupersied_learning 01_02_2024.pptx
Ensemble_instance_unsupersied_learning 01_02_2024.pptx
vigneshmatta2004
ย 
Computer Vision for Beginners
Computer Vision for BeginnersComputer Vision for Beginners
Computer Vision for Beginners
Sanghamitra Deb
ย 
Unsupervised Learning: Clustering
Unsupervised Learning: Clustering Unsupervised Learning: Clustering
Unsupervised Learning: Clustering
Experfy
ย 
background.pptx
background.pptxbackground.pptx
background.pptx
KabileshCm
ย 
Build, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Build, Scale, and Deploy Deep Learning Pipelines Using Apache SparkBuild, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Build, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Databricks
ย 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
SharabiNaif
ย 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
Anonymous9etQKwW
ย 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
MumitAhmed1
ย 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
Vishwas Lele
ย 
Machine Learning With ML.NET
Machine Learning With ML.NETMachine Learning With ML.NET
Machine Learning With ML.NET
Dev Raj Gautam
ย 
Knn Algorithm presentation
Knn Algorithm presentationKnn Algorithm presentation
Knn Algorithm presentation
RishavSharma112
ย 
Application of machine learning and cognitive computing in intrusion detectio...
Application of machine learning and cognitive computing in intrusion detectio...Application of machine learning and cognitive computing in intrusion detectio...
Application of machine learning and cognitive computing in intrusion detectio...
Mahdi Hosseini Moghaddam
ย 
Machine Learning with Azure
Machine Learning with AzureMachine Learning with Azure
Machine Learning with Azure
Barbara Fusinska
ย 
Introduction to transfer learning,aster way of adapting a neural network by e...
Introduction to transfer learning,aster way of adapting a neural network by e...Introduction to transfer learning,aster way of adapting a neural network by e...
Introduction to transfer learning,aster way of adapting a neural network by e...
ShatrughanKumar14
ย 
Fa18_P2.pptx
Fa18_P2.pptxFa18_P2.pptx
Fa18_P2.pptx
Md Abul Hayat
ย 
Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim HunterDeep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Deep-Dive into Deep Learning Pipelines with Sue Ann Hong and Tim Hunter
Databricks
ย 
Clustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn TutorialClustering: A Scikit Learn Tutorial
Clustering: A Scikit Learn Tutorial
Damian R. Mingle, MBA
ย 
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfvPCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
PCA-LDA-Lobo.pptxttvertyuytreiopkjhgftfv
Sravani477269
ย 
Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1Week 12 Dimensionality Reduction Bagian 1
Week 12 Dimensionality Reduction Bagian 1
khairulhuda242
ย 
MachineLearning.pptx
MachineLearning.pptxMachineLearning.pptx
MachineLearning.pptx
Bangtangurl
ย 
Ensemble_instance_unsupersied_learning 01_02_2024.pptx
Ensemble_instance_unsupersied_learning 01_02_2024.pptxEnsemble_instance_unsupersied_learning 01_02_2024.pptx
Ensemble_instance_unsupersied_learning 01_02_2024.pptx
vigneshmatta2004
ย 
Computer Vision for Beginners
Computer Vision for BeginnersComputer Vision for Beginners
Computer Vision for Beginners
Sanghamitra Deb
ย 
Unsupervised Learning: Clustering
Unsupervised Learning: Clustering Unsupervised Learning: Clustering
Unsupervised Learning: Clustering
Experfy
ย 
background.pptx
background.pptxbackground.pptx
background.pptx
KabileshCm
ย 
Build, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Build, Scale, and Deploy Deep Learning Pipelines Using Apache SparkBuild, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Build, Scale, and Deploy Deep Learning Pipelines Using Apache Spark
Databricks
ย 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
SharabiNaif
ย 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
MumitAhmed1
ย 
Introduction to deep learning
Introduction to deep learningIntroduction to deep learning
Introduction to deep learning
Vishwas Lele
ย 
Machine Learning With ML.NET
Machine Learning With ML.NETMachine Learning With ML.NET
Machine Learning With ML.NET
Dev Raj Gautam
ย 
Knn Algorithm presentation
Knn Algorithm presentationKnn Algorithm presentation
Knn Algorithm presentation
RishavSharma112
ย 
Application of machine learning and cognitive computing in intrusion detectio...
Application of machine learning and cognitive computing in intrusion detectio...Application of machine learning and cognitive computing in intrusion detectio...
Application of machine learning and cognitive computing in intrusion detectio...
Mahdi Hosseini Moghaddam
ย 
Machine Learning with Azure
Machine Learning with AzureMachine Learning with Azure
Machine Learning with Azure
Barbara Fusinska
ย 
Introduction to transfer learning,aster way of adapting a neural network by e...
Introduction to transfer learning,aster way of adapting a neural network by e...Introduction to transfer learning,aster way of adapting a neural network by e...
Introduction to transfer learning,aster way of adapting a neural network by e...
ShatrughanKumar14
ย 
Fa18_P2.pptx
Fa18_P2.pptxFa18_P2.pptx
Fa18_P2.pptx
Md Abul Hayat
ย 
Ad

More from Afraz Khan (7)

Hyperledger Blockchain
Hyperledger BlockchainHyperledger Blockchain
Hyperledger Blockchain
Afraz Khan
ย 
Self reliance
Self relianceSelf reliance
Self reliance
Afraz Khan
ย 
Case tools
Case toolsCase tools
Case tools
Afraz Khan
ย 
Dr Abdul Qadder Khan & Islamic bomb
Dr Abdul Qadder Khan & Islamic bombDr Abdul Qadder Khan & Islamic bomb
Dr Abdul Qadder Khan & Islamic bomb
Afraz Khan
ย 
State of health in pakistan
State of health in pakistanState of health in pakistan
State of health in pakistan
Afraz Khan
ย 
Expository paragraph
Expository paragraphExpository paragraph
Expository paragraph
Afraz Khan
ย 
Secant Method
Secant MethodSecant Method
Secant Method
Afraz Khan
ย 
Hyperledger Blockchain
Hyperledger BlockchainHyperledger Blockchain
Hyperledger Blockchain
Afraz Khan
ย 
Self reliance
Self relianceSelf reliance
Self reliance
Afraz Khan
ย 
Case tools
Case toolsCase tools
Case tools
Afraz Khan
ย 
Dr Abdul Qadder Khan & Islamic bomb
Dr Abdul Qadder Khan & Islamic bombDr Abdul Qadder Khan & Islamic bomb
Dr Abdul Qadder Khan & Islamic bomb
Afraz Khan
ย 
State of health in pakistan
State of health in pakistanState of health in pakistan
State of health in pakistan
Afraz Khan
ย 
Expository paragraph
Expository paragraphExpository paragraph
Expository paragraph
Afraz Khan
ย 
Secant Method
Secant MethodSecant Method
Secant Method
Afraz Khan
ย 
Ad

Recently uploaded (20)

Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
ย 
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
ย 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
ย 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
ย 
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership โ€” the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
ย 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
ย 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
ย 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
ย 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
ย 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
ย 

KNN Algorithm using C++

  • 1. DATA STRUCTURES PROJECT โ€ข Project name: C++ implementation of KNN algorithm. โ€ข Group members: Muhammad Umair 2015-CS-05 Afraz Khan 2015-CS-27 Hassan Tariq 2015-CS-67
  • 2. BACKGROUND โ€œClassification is a data mining technique used to predict group membership for data instances.โ€ โ€ข The group membership is utilized in for the prediction of the future data sets.
  • 3. ORIGINS OF K-NN โ€ข Nearest Neighbors have been used in statistical estimation and pattern recognition already in the beginning of 1970โ€™s (non- parametric techniques). โ€ข The method prevailed in several disciplines and still it is one of the top 10 Data Mining algorithm.
  • 4. DEFINITION โ€ข K-Nearest Neighbor is considered a lazy learning algorithm that classifies data sets based on their similarity with neighbors. โ€ข โ€œKโ€ stands for number of data set items that are considered for the classification. Ex: Image shows classification for different k-values.
  • 5. TECHNICALLYโ€ฆ.. โ€ข For the given attributes A={X1, X2โ€ฆ.. XD} Where D is the dimension of the data, we need to predict the corresponding classification group G={Y1,Y2โ€ฆYn} using the proximity metric over K items in D dimension that defines the closeness of association such that X โ‚ฌ RD and Yp โ‚ฌ G.
  • 6. THAT ISโ€ฆ. โ€ข Attribute A={Color, Outline, Dot} โ€ข Classification Group, G={triangle, square} โ€ข D=3, we are free to choose K value. Attributes A C l a s s i f i c a t i o n G r o u p
  • 7. K-NN IN ACTION โ€ข Consider the following data: A={weight,color} G={Apple(A), Banana(B)} โ€ข We need to predict the type of a fruit with: weight = 378 color = red
  • 8. SOME PROCESSINGโ€ฆ. โ€ข Assign color codes to convert into numerical data: โ€ข Letโ€™s label Apple as โ€œAโ€ and Banana as โ€œBโ€
  • 9. K-NN VARIATIONS โ€ข (K-l)-NN: Reduce complexity by having a threshold on the majority. We could restrict the associations through (K-l)-NN. Ex: Decide if majority is over a given threshold l. Otherwise reject. Here, K=5 and l=4. As there is no majority with count>4. We reject to classify the element.
  • 10. K-NN PROPERTIES โ€ข K-NN is a lazy algorithm โ€ข The processing defers with respect to K value. โ€ข Result is generated after analysis of stored data. โ€ข It neglects any intermediate values.
  • 11. REMARKS: FIRST THE GOOD Advantages โ€ข Can be applied to the data from any distribution for example, data does not have to be separable with a linear boundary โ€ข Very simple and intuitive โ€ข Good classification if the number of samples is large enough
  • 12. NOW THE BADโ€ฆ. Disadvantages โ€ข Dependent on K Value โ€ข Test stage is computationally expensive โ€ข No training stage, all the work is done during the test stage โ€ข This is actually the opposite of what we want. Usually we can afford training step to take a long time, but we want fast test step โ€ข Need large number of samples for accuracy
  • 13. C++ IMPLEMENTATION Working process: โ€ข Dataset input from a file. โ€ข Input a new instance. โ€ข Input the threshold(K). โ€ข Classification of dataset. โ€ข Output give most common class according to the instance entered.
  • 14. We will at 1st add our DatSet to the WEKA & also to our C++ Prog: Weka file uploading C++ file uploading
  • 15. Then user will enter a instance/TUPLE along with a K value to classify instances:
  • 16. We can set value of K in WEKA same as in C++ Prog: Just right click the algorithm applied and change K value as U want.
  • 17. We will apply KNN algorithm to dataset in WEKA while in C++ we have a devised a sorting algorithm which will give K instances closest to entered tuple.
  • 18. We can see both C++ & WEKA output as approximately they are same. There may be some differences in outputs because in C++ we enter tuple by our own will.