KNN Flashcards
full KNN form
K nearest neighbour
k value
odd/even
how to decide k value
‘k’ value will be decided based on the no. of classes present in the output parameter gf training data set
When will be k even and when it will be odd
If training data set contain even no. of class labels then ‘k’ value is an odd no.
If training data set contain odd no. of class labels then ‘k’ value is an even no.
k formula
k = n+1 [n: number of class labels]
knn algo (3 other properties of algo i.e. type of algo)
KNN algo is:
* Non parametric learning algo
* Instance based learning algo
* Lazy learning algo
Non parametric algo
also example
Knn is a non parametric algo because this model is never trained with an input parameter
Non parametric algo in ML are methods that do not assume a fixed form or finite set of parameters for the model structure. Instead they allow to the model to grow in complexity with the size of the training data.
Ex: KNN, Decision trees, SVM
Instance based algo
KNN is an instance based learning algo means given new observation (test data/test instance) comapred with all the training data set samples to make the predictions.
Instance based learning also known as lazy learning algorithms are class of ML techniques that delay the process of generalizing the training data until a query is made. Unlike eager learning algorithms which build a model during the training phase, instance based learning store the instances and use them directly to make predictions.
Lazy learning algo
KNN algo is lazy learning algo means no model is trained to make the predictions.
Instance based learning also known as lazy learning algorithms are class of ML techniques that delay the process of generalizing the training data until a query is made. Unlike eager learning algorithms which build a model during the training phase, instance based learning store the instances and use them directly to make predictions.
KNN - Classification / Regression
Both classification and regression
note about training data set in knn
This algo is continuously updated with a new training data set
When is knn used?
KNN is used when the relationship between feature is complex not linear
Hamming Distance
If x1 and x2 are the attribute value of two instances then if x1==x2 then hamming distance is 0 else if x1≠ x2 then distance is 1
hamming distance is case sensitive
KNN output diagram
Que1 of KNN
class I