This repo implements model for twitt sentiment classification (http://help.sentiment140.com/for-students)
- Installation
- install requirements
- testing
- Usage
- Prepare data
- Training
- Inference
- TODO list
Colab
Install required packages and test scripts
Clone repository and walk into working directory
git clone https://github.com/marekb-sci/twitter_sentiment_classification.gitcd twitter_sentiment_classificationInstall requirements
pip install -r requirements.txtPerform testing: (optional, partially implemented)
pytest tests/Download:
wget http://cs.stanford.edu/people/alecmgo/trainingandtestdata.zip
unzip trainingandtestdata.zip -d data
# alternative in Colab:
# !gdown '0B04GJPshIjmPRnZManQwWEdTZjg'
# !unzip /content/trainingandtestdata.zip -d /content/data
Preprocess data:
python prepare_train_data.py \
--input-path data/training.1600000.processed.noemoticon.csv \
--output-dir datapython train.py \
--train-data data/training.1600000.processed.noemoticon_train.csv \
--val-data data/training.1600000.processed.noemoticon_val.csv \
--epochs 3Write data for inference in text file. Each twitt should be in a separate line. Sample file with data ready for inference is located at sample_data/sample_for_inference.txt
cat sample_data/sample_for_inference.txtThe ouptput should be:
@RobCairns Thanx..I improved once, so I'm hopinng I will do so again..more function is still better than less. Thanx for understanding.
OK, I'm done ppl, I will not reply to anymore bball digs...its taken up my entire day so far! Let me get back to fashion and beauty
@imjstsayin I'm enjoying the sunshine! Maybe a beach day today How are you?
Run inference:
python inference.py \
--model-dir output_model \
--data sample_data/sample_for_inference.txt \
--output-file sample_data_infernece.txtCheck results:
cat sample_data_infernece.txtThe ouptput will look like:
LABEL_1 0.7134
LABEL_0 0.7452
LABEL_1 0.8012
where first column indicates the predicted label and the second column: score of this label
- test accuracy for different settigs
- make inference labels readable
- make tests