Wednesday, 21 January 2015

K-Nearest Neighbors Algorithm - KNN

KNN algorithm is a classification algorithm can be used in many application such as image processing,statistical design pattern and data mining.

As for any classification algorithm KN also have a model and Prediction part. Here model is simply the input dataset. While predicting output is a class membership. An object is classified by a majority vote of its neighbors (k), with the object being assigned to the class most common among its k nearest neighbors (k is a positive integer, typically small).
1.  If k = 1, then the object is simply assigned to the class of that single nearest neighbor.
2.  If k=3, and the classlabels are Good =2 Bad=1,then the predicted classlabel will be Good,which contains the magority vote.

Lets see how to handle a sample data in KNN algorithm.


We have data from questionnaires survey and objective testing with two attribute to classify whether a special paper issue is good or not.

Here is for training sample.







Let this be the test sample





1. Determine the parameter k=the no.of nearest neighbours.
      Say  k=3
2. Calculate the distance between queryinstance and all the training samples. 

Coordinate of query instance is (3,7) ,instead of calculating the distance we compute square distance which is faster to calculate(without squareroot)


3. Sort the distance and determine Nearest neighbors based on the kth minimum distance.


4. Gather  the category Y  of the nearest neighbours .



-> the second row inthe last column that the category of nearest neighbours (Y) is not included becoz the rank of this data is more than 3(=k).

5. Use simple majority of the category of  nearest neighbors as the prediction value of query instance.

We have  2 good and 1 bad ,since,2>1 So we conclude that a new paper tissue that pass laboratory test with x1=3 and x2=7 is included in Good category.



30 comments:

  1. For latest and updated Cloudera certification dumps in PDF format contact us at completeexamcollection@gmail.com.
    Refer our blog for more details http://completeexamcollection.blogspot.in/2015/04/cloudera-hadoop-certification-dumps.html

    ReplyDelete
  2. Really a good piece of knowledge on Big Data and Hadoop. Thanks for such a good post. I would like to recommend one more resource NPN Training which helps in getting more knowledge on Hadoop. The best part of NPN Training is they provide complete Hands-on classes.

    For More feedback visit
    http://npntraining.com/testimonial.php

    ReplyDelete
  3. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.
    java training in chennai | java training in USA

    selenium training in chennai

    ReplyDelete
  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.

    Devops training in sholinganallur

    ReplyDelete
  5. Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Blueprism training in Chennai

    Blueprism training in Bangalore

    Blueprism training in Pune

    ReplyDelete
  6. Pleasant Tips..Thanks for Sharing….We keep up hands on approach at work and in the workplace, keeping our business pragmatic, which recommends we can help you with your tree clearing and pruning in an invaluable and fit way.

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  7. Really This goes far beyond the commenting! It wrote his thoughts while reading the article amazingly :)
    Blueprism Training in pune
    blueprism Training

    ReplyDelete
  8. A debt of gratitude is in order for sharing the information, keep doing awesome... I truly delighted in investigating your site. great asset...

    Data Science Course

    ReplyDelete
  9. I truly like you're composing style, incredible data, thank you for posting.

    Data Science Training

    ReplyDelete
  10. Very interesting blog. Many blogs I see these days do not really provide anything that attracts others, but believe me the way you interact is literally awesome. I will instantly grab your rss feed to stay informed of any updates you make and as well take the advantage to share some information about

    CREDIT CARD HACK SOFTWARE which many are not yet informed of the latest technology.

    Thank so much, keep doing this great job.

    ReplyDelete

  11. This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works ExcelR Data Analytics Course

    ReplyDelete
  12. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.

    Data Science In Bangalore

    ReplyDelete
  13. I finally found a great article here. I will stay here again. I just added your blog to my bookmarking sites. Thank you. Quality postings are essential to get visitors to visit the website, that's what this website offers.

    Data Science Training in Pune

    ReplyDelete
  14. I have voiced some of the posts on your website now, and I really like your blogging style. I added it to my list of favorite blogging sites and will be back soon ...
    Best Data Science Courses in Bangalore

    ReplyDelete
  15. You can comment on the blog ordering system. You should discuss, it's splendid. Auditing your blog would increase the number of visitors. I was very happy to find this site. Thank you...
    Digital Marketing Course in Bangalore

    ReplyDelete
  16. I finally found a great article here. I will stay here again. I just added your blog to my bookmarking sites. Thank you. Quality postings are essential to get visitors to visit the website, that's what this website offers.

    Best Data Science Courses in Bangalore

    ReplyDelete

  17. Very good message. I came across your blog and wanted to tell you that I really enjoyed reading your articles.

    Business Analytics Course

    ReplyDelete
  18. I will very much appreciate the writer's choice for choosing this excellent article suitable for my topic.

    Best Data Science Courses in Bangalore

    ReplyDelete
  19. You have completed certain reliable points there. I did some research on the subject and found that almost everyone will agree with your blog.


    Data Analytics Course in Bangalore

    ReplyDelete
  20. I'm always looking online for articles that can help me. I think you also made some good comments on the functions. Keep up the good work!


    Data Science Training in Nashik

    ReplyDelete
  21. I'm always looking online for articles that can help me. I think you also made some good comments on the functions. Keep up the good work!

    Data Science Training in Kolkata

    ReplyDelete
  22. Very informative message! There is so much information here that can help any business start a successful social media campaign!

    Data Scientist Course in Kolkata

    ReplyDelete
  23. I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts.Data Science Course in Mohali

    ReplyDelete
  24. A data science is a researcher who prepares huge volumes of bog data for analysis, build complex quantitative algorithms to organize and synthesize the information
    http://360digitmg.com/india/data-science-using-python-and-programming-banglore

    ReplyDelete
  25. Thanks for the best blog. it was very useful for me.keep sharing such ideas in the future as well. Gossip

    ReplyDelete