Giter VIP home page Giter VIP logo

text-to-feature-vectors's Introduction

Feature-Vectorize-Text

Want to use SVM to classify your text? Want kNN? Convert your text sets into feature vectors, so that you can use machine learning algorithms to classify. Given a file in the form:

isSpam, positive ,text
1,0,Ugh, blah blah blah

This program will output a series of feature vectors for a given category, where the order of occurence of the word is the feature id, and the frequency of the word in the example is the value. The -p option allows using word pair occurences and frequencies instead of individual words.

The term category is used to describe the different classification jobs (e.g. is spam, is positive, etc.); CATEGORY_NUM for spam is 1 in the example above. This program assumes binary classification (converting 0s to -1s), however it can convert for multi-class data sets as well by using the -m option. Runs on Python 2.7+.

Usage

The usage for this program is:

text-to-svm.py [-h] [-p] [-m] [-lang LANGUAGE] [-stop] [-lemma | -stem]
               -train_set input_file [CATEGORY_NUM] [output_file]
               [-val_set input_file [CATEGORY_NUM] [output_file]]
               -test_set input_file [CATEGORY_NUM] [output_file]

Running the program with any of the help options (-?, -h, --help) will provide a brief help message.

An example run is:

./text-to-svm.py -stop -lemma -train_set train.train output.train -test_set test.test

NLTK Tools

While the basic functionality requires no outside software installation, this program uses NLTK tools to remove stopwords, stem, and lemmatize. These tools work across languages as well which can be input via the -lang option (with the exception of the lemmatizer, which only works for English).

To see more:

text-to-feature-vectors's People

Contributors

bigfav avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.