Wednesday, February 29, 2012

classification with KNN

Monday, Feb. 20 we talked about KNN. Of course, Shazam is a good example to use for teaching KNN. I had seen the Shazam case in the Linoff & Berry book and students like the example because many of them have seen or heard about Shazam. I use the free version of Shazam and when I ask my students: why my free version does not work as well as your paid ones? , they get excited to come up with ideas:

It is good to follow the traditional order of topic when teaching KNN:
1- distance function
2- choosing k
3- and combining information from the 

To do so I stay on my slide 7 (as I say in my second slide, all the pictures are from the web), and explain it as a patient/drug prescription case. The data is on previous patients and the drug that was prescribed for each. Then I ask the class to decide which drug to prescribe for the new patient. 

My ppt slides are available here.The numerical examples come from Daniel Larose's book. I also like the KNN example Jame's Hamilton has on his webpage.

SAS EM MBR node is not a very exciting one. It does not many customization options and the output does not include the details of the model. Here's the activity we completed in the class.

It is a good idea to discuss sensitivity and specificity after we have talked about two classification models. We are still working the "clean" ~3K-records churn data set that comes with book. We used SAS EM Model Comparison, set it to select the better model between LogReg and MBR based on validation misclassifications rate. It chooses MBR over LogReg. But when I asked the class to calculate sensitivity and specificity for both models, some of them said they would choose LogReg. And it is a reasonable choice because it has 2 percentage points higher sensitivity. We then discussed other applications in which sensitivity or specificity may be important criterion for evaluating models like HIV test, marketing campaigns, mammograms,...and an example by a student: pregnancy tests !!

I found this on the web, thought it's funny, one "neighboring" worm:


No comments:

Post a Comment