Twitter Sentiment Analysis
- Make sure you have python 3, pip and virtualenv installed.
- Go to https://apps.twitter.com/, log in, and create a new app to get a consumer key and a consumer secret.
- Perform the following steps (remember to insert your key and secret):
git clone https://github.com/frederikgdl/tsabl.git
cd tsabl
virtualenv venv -p python3
echo 'export TSABL_CONSUMER_KEY="<YOUR CONSUMER KEY HERE>"' >> venv/bin/activate
echo 'export TSABL_CONSUMER_SECRET="<YOUR CONSUMER KEY SECRET>"' >> venv/bin/activate
echo 'export PYTHONPATH="$PYTHONPATH:$PWD"' >> venv/bin/activate
echo 'export KERAS_BACKEND=theano' >> venv/bin/activate
source venv/bin/activate
pip install -r requirements.txt
Before running any commands make sure the virtual environment is activated by running:
source venv/bin/activate
- Edit
embeddings/config.py
to use the data files you want. - Run
python embeddings/main.py
to train and save the embeddings using CPU.
- Edit
classifiers/config.py
to use the data files you want. - Run
python classifiers/train_and_test.py
to train and test the models and save the results.
- Edit
scripts/config.py
to use the data files you want. - Run
python scripts/test_all_epochs
to test all epochs in selected folder and write results and print graph.
Embeddings can be trained on GPU using either Theano or TensorFlow backend.
- Make sure CUDA is installed if using NVIDIA GPU.
- Make sure libgpuarray is installed.
- Edit
run_gpu.sh
: theKERAS_BACKEND
variable must be set totheano
and paths to libgpuarray and CUDA must be specified. - Run by typing (may need to give permission first):
./run_gpu.sh
- Make sure GPU version of TensorFlow is installed.
- Edit
run_gpu.sh
: theKERAS_BACKEND
variable must be set totensorflow
. - Run by typing (may need to give permission first):
./run_gpu.sh
python -m unittest