Giter Club home page Giter Club logo

lt2212-v20-a1's Introduction

LT2212 V20 Assignment 1

Part 1

I decided to split the text into words just by spaces. I didn't lemmatize them, since we are not allowed to use nltk for this assignment, and any manual approaches to this seem excessively laborious and not very promising. However, I excluded all punctuation and all numbers, in order to get only actual words. This is not perfect, for example I get a high number of "s", probably from contractions with removed apostrophes, but it still yields more useful results than leaving those in the data. My function assumes that the first two arguments are the full paths to the directories, in case they are not already in the same directory.

Part 4

In the plot before tf-idf, the top words were mostly content-free (except for #9, oil) and relatively evenly distributed between the two classes. Crude generally has higher numbers, which might be because it's the bigger corpus of the two. After tf-idf the plot changes drastically. While a few of the function words from the last plot still appear (e.g. "the"), there are also content words which appear almost exclusively in one of the classes. For example, "tonnes", "mil", and "wheat" appear overwhelmingly frequently in the grain class, while "oil" and "opec" appear mostly in the crude class. I was a bit surprised to see that some of the function words did not get eliminated, but it seems that e.g. "the", "in", or "that" are so frequent, that they still have a high count after the tf-idf normalization.

Part Bonus

I chose to create a classifier using SVM, since they are known to work well with high-dimensional data such as language. For the purpose of this assignment it seemed the easiest to write a function that takes a dataframe as input and then trains and evaluates the model. It returns the accuracy score (as asked for in the assignment) and additionally prints precision, recall, and a confusion matrix, to get more detailed information about the performance. Comparing the results with and without tf-idf, the model without performs very slightly worse than the model with tf-idf. However, the difference is minimal since the basic model already has a very high performance, so there is not a lot of room for improvement. This result confirms my expectation that the model works better with tf-idf, as this should take less general (function) and more class-specific (content) words into regard. I did expect a bigger difference though.

lt2212-v20-a1's People

Contributors

juliaklezl avatar asayeed avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.