You can buy the book here. You can read the book on O'Reilly OFPS now. Work the chapter code examples as you go. Don't forget to initialize your python environment. Try linux (apt-get, yum) or OS X (brew, port) packages if any of the requirements don't install in your virtualenv.
# From project root
# Setup python virtualenv
virtualenv -p `which python2.7` venv --distribute
source venv/bin/activate
pip install -r requirements.txt
Most of this chapter will involve running our Python/Flask web application.
python web/index.py
To calculate, run:
pig -l /tmp -x local -v -w p_reply_given_from_to.pig
This will create a mongodb store called from_to_reply_ratios.
Run mongo.js, or in the mongo terminal:
use agile_data
db.from_to_reply_ratios.ensureIndex({from: 1, to: 1});
db.from_to_reply_ratios.findOne();
{
"_id" : ObjectId("5111653f3004769d48b77a5b"),
"from" : "[email protected]",
"to" : "[email protected]",
"ratio" : 0.5
}
To calculate and fill in empty zeros in the distributions, run:
pig -l /tmp -x local -v -w p_reply_given_topics.pig
To publish this data, run:
pig -l /tmp -x local -v -w publish_topics_.pig
This will create a mongodb store: 'mongodb://localhost/agile_data.token_reply_rates_'
Run 'mongo.js', or in the mongo terminal:
mongo agile_data
db.token_reply_rates.ensureIndex({token: 1});
db.token_reply_rates.findOne();
{
"_id" : ObjectId("511700c330048b60597e7c04"),
"token" : "public",
"reply_rate" : 0.6969366812896153
}
db.p_token.ensureIndex({'token': 1})
db.p_token.findOne();
> db.p_token.findOne({'token': 'public'});
{
"_id" : ObjectId("518444db3004f7fadcb595d9"),
"token" : "public",
"prob" : 0.00041651697680944406
}
Run index.py to deploy classifier web service against MongoDB probability tables:
python ./index
To check it, enter well-known values for your own inbox as query parameters to /will_reply:
curl http://localhost:5000/[email protected]&to=*@****.com&message_body=hadoop