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

Path & Path Production, Take the following flow graph and use the procedure...

Take the following flow graph and use the procedure in chapter 8 to derive an equivalent regular expression. Show all intermediate graphs (to ensure that you follow the procedure,

How does VB.NET achieve polymorphism, How does VB.NET/C# achieve polymorphi...

How does VB.NET/C# achieve polymorphism?  VB.Net / C# give polymorphism through the following mechanisms: 1. Inheritance - base class gives overridable methods which are re-

Explain time sharing operating system, Explain Time sharing operating syste...

Explain Time sharing operating system. Time sharing: It is also called as multi tasking, is a logical execution of multiprogramming. Multiple jobs are executed through the C

Search methods and heuristics - artificial intelligence, Search Methods and...

Search Methods and Heuristics - Artificial intelligence: Here now we come to the question of how constraint solvers search for solutions -constraint preserving coursework of v

How to create user interfaces for lists, How to create user interfaces for ...

How to create user interfaces for lists? The R/3 system automatically, obtains a graphical user interface (GUI) for your lists that offers the basic functions for list process

Collision free network, Hello Sir/Mam, Actually i am trying to implement th...

Hello Sir/Mam, Actually i am trying to implement the concept of MAC layer protocols in NS2..... But unfortunately i am not able to do that.... and not even able to get the code fo

Explain the pdca cycle, Explain the PDCA cycle. PDCA is a four step pro...

Explain the PDCA cycle. PDCA is a four step problem solving method. The following are the description of each step: 1. P - Plan (Devise your Plan). Identify an opportunity a

Shared-memory programming model, Q. Shared-memory programming model? In...

Q. Shared-memory programming model? In shared-memory programming model tasks share a common address space that they read and write asynchronously. Several mechanisms like semap

How to create a new object order preference, 1. In an ASCII editor, make an...

1. In an ASCII editor, make an empty text file with the extension .ord. 2. Save the file in the Dat folder of the project. 3. Click To o l s > G UI R e c o r d O p t i o n s

QUELING SYSTEM, Q.SHOW THAT AVERAGE NUMBER OF UNIT IN A (M/M/1) QUELING SYT...

Q.SHOW THAT AVERAGE NUMBER OF UNIT IN A (M/M/1) QUELING SYTEM IS EQUAL TO P/(1-p). NOTE:P=ROW

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