O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using KNN to compute raw probabilities instead of classifications

When we use KNN to classify cases, the underlying algorithm uses a simple majority vote to determine the class. In such a case, we implicitly consider all errors to be equally important. However, in situations with asymmetric costs--where we are prepared to make one kind of error more readily than another--we might not want to use a simple majority vote to determine the class. Instead, we might want to get the raw probabilities (proportions) for each class and choose a cutoff probability for classification. For example, it might be 10 times costlier to classify a buyer as a non-buyer than to classify a non-buyer as a buyer. In such cases, we might accept a probability far lower ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required