K-nearest neighbor for text classification, Computer Engineering

Assignment Help:

Assignment 2: K-nearest neighbor for text classification.

The goal of text classification is to identify the topic for a piece of text (news article, web-blog, etc.). Text classification has obvious utility in the age of information overload, and it has become a popular turf for applying machine learning algorithms. In this project, you will have the opportunity to implement k-nearest neighbor and apply it to text classification on the well known Reuter news collection.

1.       Download the dataset from my website, which is created from the original collection and contains a training file, a test file, the topics, and the format for train/test.

2.       Implement the k-nearest neighbor algorithm for text classification. Your goal is to predict the topic for each news article in the test set. Try the following distance or similarity measures with their corresponding representations.

a.        Hamming distance: each document is represented as a boolean vector, where each bit represents whether the corresponding word appears in the document.

b.       Euclidean distance: each document is represented as a numeric vector, where each number represents how many times the corresponding word appears in the document (it could be zero).

c.         Cosine similarity with TF-IDF weights (a popular metric in information retrieval): each document is represented by a numeric vector as in (b). However, now each number is the TF-IDF weight for the corresponding word (as defined below). The similarity between two documents is the dot product of their corresponding vectors, divided by the product of their norms.

3.        Let w be a word, d be a document, and N(d,w) be the number of occurrences of w in d (i.e., the number in the vector in (b)). TF stands for term frequency, and TF(d,w)=N(d,w)/W(d), where W(d) is the total number of words in d. IDF stands for inverted document frequency, and IDF(d,w)=log(D/C(w)), where D is the total number of documents, and C(w) is the total number of documents that contains the word w; the base for the logarithm is irrelevant, you can use e or 2. The TF-IDF weight for w in d is TF(d,w)*IDF(d,w); this is the number you should put in the vector in (c). TF-IDF is a clever heuristic to take into account of the "information content" that each word conveys, so that frequent words like "the" is discounted and document-specific ones are amplified. You can find more details about it online or in standard IR text.

4.       You should try k = 1, k = 3 and k = 5 with each of the representations above. Notice that with a distance measure, the k-nearest neighborhoods are the ones with the smallest distance from the test point, whereas with a similarity measure, they are the ones with the highest similarity scores.

 

 


Related Discussions:- K-nearest neighbor for text classification

What are the restrictions on subscreens, What are the restrictions on Subsc...

What are the restrictions on Subscreens? Subscreens have various restrictions.  They cannot: Set their own GUI status Have a named OK code Call another screen

Use of overlapped register windows, Q. Use of Overlapped Register Windows? ...

Q. Use of Overlapped Register Windows? Register file comprises 138 registers. Let them be called by register number 0 - 137.  Diagram demonstrates the use of registers: when

Explain about distributed systems, Q. Explain about distributed systems? ...

Q. Explain about distributed systems? A Distributed System in that Data, Process and Interface component of information System are distributed to many locations in a computer n

Describe memory and memory unit, Q. Describe Memory and Memory unit? In...

Q. Describe Memory and Memory unit? Input devices can fetch instructions or data only sequentially though a program may or may not be executed sequentially because looping, jum

Ia-32 support, In order to support IA-32, the Itanium can switch into 32-bi...

In order to support IA-32, the Itanium can switch into 32-bit mode with special jump escape instructions. The IA-32 instructions have been mapped to the Itanium's functional units.

State the concept of multiplicity, Multiplicity Multiplicity in an ass...

Multiplicity Multiplicity in an association specifies tells us about number of objects participate in a relationship. It decides the number of related objects. Multiplicity is

Which gates are called universal gates, Q. What is Gate? Explain Basic gat...

Q. What is Gate? Explain Basic gates with truth table and necessary circuits. Q. Which gates are called Universal Gates? Why? Q. Give the Dual of the rule 17. Q. Realize

Operation codes used in assembly instructions, Q. Operation codes used in a...

Q. Operation codes used in assembly instructions? Now let's describe various operation codes needed for this machine so that we can translate High level language instructions t

Which of the logic gates are known as universal gates, Which of the logic g...

Which of the logic gates are known as universal gates ? Ans. NAND and NOR are termed as universal gates, since any digital circuit can be realized completely by using either of

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd