Skip to content

Analyzes sentiment of a given sentence as either pos or neg

Notifications You must be signed in to change notification settings

DanielPerezJensen/sentiment-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sentiment-analyzer

A machine learning application of sentiment classifying written in Python3.6.

Requirements
  1. Python3.6
  2. For pip modules run: pip install -r requirements.txt or pip install nltk scikit-learn scipy

By using the 5 classifiers:

  1. Naive Bayes Classifier
  2. Multinomial Naive Bayes Classifier
  3. Bernoulli Naive Bayes Classifier
  4. Logistic Regression Classifier
  5. Linear SVC Classifier

All classifiers were trained on 10.000 short reviews of movies that were either positive (pos) or negative (neg). By combining the votes of these 5 classifiers a custom Voted Classifier has been constructed. This Voted Classifier (VCLF) uses the votes of the 5 trained classifier to come to a classification of a given string.

If you wish to use this classifier for yourself do the following steps:

  1. git clone https://github.com/DanielPerezJensen/sentiment-analyzer.git
  2. cd sentiment-analyzer
  • If you want to train the classifiers on other data do this:
    1. Put positive reviews in "sentiment_data/positive" and negative reviews in "sentiment_data/negative". Separate every review by a newline.
  1. python3.6 train_clf.py
  2. If you get an error create these directories: pickled/data and pickled/algorithms
  3. Now you can import sentiment.py in files that are in the sentiment-analyzer directory.
  4. Usage:
    > from sentiment import sentiment
    > print(sentiment("This movie was great"))
    > pos 1
    > print(sentiment("I have had a really bad afternoon to be honest"))
    > neg 1
With thanks to Sentdex from pythonprogramming.net for coding examples and the training data.

About

Analyzes sentiment of a given sentence as either pos or neg

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages