The sentiment predictor is built with a Convolutional Neural Network model realized by Keras API running Tensorflow as backend. The feature embedding is using pretrained sentiment140 model.
-
Required packages
Package Version Installation keras 1.0.3 PIP theano 0.8.2 PIP tensorflow 0.12.0rc0 PIP pandas 0.19.1 PIP sklearn 0.08.1 PIP flask 0.11.1 PIP tweepy 3.5.0 PIP h5py 2.6.0 PIP -
Installation script for deep learning modules
pip install keras==1.0.3 pip install theano==0.8.2 pip install tensorflow==0.12.0rc0 pip install pandas==0.19.1 pip install sklearn==0.08.1 pip install flask==0.11.1 pip install tweep==3.5.0 pip install h5py==2.6.0
Web service is built with Python Flask.
-
Install virtual environment
sudo python install virtualenv
-
Set up a new virtual environment with name venv
virtualenv venv
-
Activate the virtual environment
souce ./venv/Scripts/activate
-
Install all requirement Python packages
pip install keras==1.0.3 pip install theano==0.8.2 pip install tensorflow==0.12.0rc0 pip install pandas==0.19.1 pip install sklearn==0.08.1 pip install flask==0.11.1 pip install tweep==3.5.0 pip install h5py==2.6.0
-
Create a dependency file requirement.txt which include all packages and patterns. We do this via
pip freeze > requirement.txt
-
Tensorflow needs some special treatment (revision) to the requirement file. So remove the tensor flow line, something like
tensorflow==0.10.0
and add one line
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
-
Create a runtime.txt file and add the following line to declare python version used in this web app
python-2.7.12
-
Create a Procfile file and add the following line to specify how to run the application when deployed
web: bin/web
also create the bin/web file with the following content
python app.py
-
Version control via Git all required files.
-
Push to Heroku repository
git push -u heroku master