- Python 2.7
- NumPy
- Scipy
This is a program that will go through the stages of preprocessing data, training the data using perceptron, naive bayes, knn and rocchio classifiers and testing the models using five-fold cross validation techniques. A preprocessing option to strip punctionuation, and/or stop words can also be specified. The features vectors of the data can be represented in either binary, bag of words, or tf-idf approach. These options can be configured by passing the respective parameters as arguments.
If none of the optional arguments are provided, the program will be run with default options of not stripping the punctuation, epoch of 1, using a binary feature vector model, KNN classifier with k=1 and the Euclidean distance metric.
The dataset used in this program is the v2.0 polarity dataset from Cornell. There are two classes in this dataset, positive and negative, each classes has 1000 files for a total of 2000 files. If you would like to train on a similar dataset, please make sure that the dataset follows this format:
txt_sentoken/
positive_folder/
file_1.txt file_2.txt ... file_42.txt
negative_folder/
file_43.txt file_44.txt ...
A sample run of the program might be:
python sentiment_classification.py review_polarity/txt_sentoken --nopunct
This would run the program with the default perceptron classifier using the binary model to create feature vectors after stripping out the punctuation from the dataset with the euclidean distance metric.
- KNN
- Bag of Words Model
- tf-idf
- Precision and Recall
- Stopwords
- Binary Independence Model
- Perceptron Binary Classifier
- Naive Bayes Probabilistic Model
- Log Likelihood for Logistic Regression
- default number of stopwords is 173, which is a bit high and gives lower accuracy
- try normalizing binary to see if better accuracy
- save and load data from csv files
- save weights of relevant classifiers (ie lr)