1
$\begingroup$

I am working on a text classification work. The purpose of this work is to classify whether a particular document belong to class A or Class B.

I used KNN algorithm and i am able to get some decent results. However I want to know two things.

  1. Why a particular document has been classified as Class A or Class B? What keyword or information that made a document to be classified as such?
  2. How to perform mis-classification analysis?

Kindly help.

$\endgroup$
1
$\begingroup$

It seems to me that both of your questions could be answered by storing the retrieved neighbours on your test set and giving them a thorough analysis. Assuming you are using a unigram + tf-idf text representation and a cosine similarity distance metric for your K-NN retrieval, it would be trivial once you have a classified document to display the K neighbours and analyze their common unigrams and their respective tf-idf weights in order to see what influenced the classification. Moreover, doing it on your misclassified documents could help you understand which features caused the error.

I'd be interested to know if there is a more systematized approach to those issues.

$\endgroup$
  • $\begingroup$ Clos - Thank you very much for the answer. I have built a tdm for the corpus and applied K-NN on the dataset. Can i apply cosine similarity distance on the KNN. How can this be done? Can you give a sample R or Python code or reference for the same? $\endgroup$ – Arun Sep 22 '15 at 6:18
  • $\begingroup$ Clos - I also calculated tf-idf and upon this i applied KNN algortihm. But the results were poor. any idea on how it is different from calculating cosine similarity distance and then applying KNN? $\endgroup$ – Arun Sep 22 '15 at 6:39
  • $\begingroup$ K-NN is made of two things: a representation scheme (how you model your documents in your system, for example unigrams with tf-idf weighting) and a similarity metric between 2 documents which is used to retrieve the k nearest neighbours. I gave tf-idf and cosine similarity as examples, but you should use whatever you were using. You just need to store the neighbours somewhere and analyze which unigrams put them into the retrieved neighbours. $\endgroup$ – Jérémie Clos Sep 22 '15 at 8:22
  • $\begingroup$ Clos - Thank you again. I really dont have idea on how to store the neighbours. I searched for it and still continuing to do. If you can refer me to this technique it will be really helpful. sorry to trouble you again. $\endgroup$ – Arun Sep 22 '15 at 10:13
  • $\begingroup$ That would depend on whatever language and package/library you are using. $\endgroup$ – Jérémie Clos Sep 22 '15 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.