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

Processing elements (pes) -array processing, Processing elements (PEs)  : E...

Processing elements (PEs)  : Every processing element consists of ALU, local memory and its registers  for storage of distributed data. This PEs has been interconnected via an inte

Explain advantageand disadvantages of a dynamic document, Explain advantage...

Explain advantageand disadvantages of a dynamic document.   The chief advantages of a dynamic document lie in its capability to report current information. For illustratio

What is XMS, What is XMS Memory system is divided into 3 main parts. TP...

What is XMS Memory system is divided into 3 main parts. TPA (transient program area), system area and XMS (extended memory system). Type of microprocessor in your computer sign

Name the languages introduced in second generation, Name the languages intr...

Name the languages introduced in second  generation During  the time of  second  generation  many  high  level  programming  languages  were introduced, such as FORTRAN (1956),

Client server using c, client server or multithreaded client-server, where ...

client server or multithreaded client-server, where server will create pool of worker threads (say 5) to provide services to pool of clients (say 5 ).Server should be behaving as a

Explain the term - computer aided software engineering, Explain the term - ...

Explain the term - Computer Aided Software Engineering Production of software became much commercial. Software development tools were devised. Concept of Computer Aided Softwar

How can we convert infix expression to a postfix expression, One can change...

One can change an infix expression to a postfix expression using a By using Stack you can convert infix expression to a postfix expression

What is machine language, What is Machine Language? To write program fo...

What is Machine Language? To write program for a computer we need to specify, directly or indirectly the sequence of machine instructions.  These instructions  inside  computer

What are vectored interrupts, What are vectored interrupts? To decrease...

What are vectored interrupts? To decrease the time involved in the polling process, a device requesting an interrupt may recognize itself directly to the processor. Then the pr

Purpose of pointer phrase in string command, The Purpose of POINTER phrase ...

The Purpose of POINTER phrase is to verify the leftmost position within receiving field where the first transferred character will be kept

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