Showing posts with label Kaggle. Show all posts
Showing posts with label Kaggle. Show all posts

Saturday, June 18, 2016

AWS Kaggle Machine – turnkey data science “Lab in a Box”



The advancement in data science and machine learning has not only brought breakthroughs like AlphaGO, but also starting to have broad impact in our everyday lives (Airbnb uses data to predict traveler’s destinations). Gone are the days when data science is only accessible by those in the ivory tower with million dollar proprietary software, new trends have emerged:
  • open source software and tools
  • compute capacity at cloud scale, with dramatic cost reduction
  • public data set, community based problem solving (Kaggle)

AWS provides both cost efficiency and scalable capabilities. It makes sense for data scientist to tap into the power of public cloud. An AWS image is developed here which:
  • Automates the installation and configuration of a comprehensive set of open source data science tools
  • Allows instance sizing based on needs
  • Control cost (shut down or terminate when done, launch in a few minutes)

What it is
An AWS AMI which provides “data science server in a box” with current open source toolkit (RStudio, Jupyter Notebook, Anaconda, Xgboost…). Builds automatically, fully configured ready for use in less than five minutes.

How to build a Kaggle Machine
Using the community AMI named “kaggle machine”,  build your Kaggle Machine in AWS, with one of the following method. Note the AMIs are currently available in us-east-1 and us-west-2. For other regions, you can build your machine in the above two regions, and copy AMI across regions.
Build Kaggle Machine from AWS console
Launch EC2 instance, search for “Kaggle-machine” in Community AMIs, specify a key pair. After instance creation, add a Security Group which allows port 8787, 9999 and 22 for ssh.

Build Kaggle Machine using CloudFormation Stack

A CloudFormation template can be used to build Kaggle Machine and Security Group automatically. Download the template and use it to build your stack in us-east-1 or us-west-2. The template can be found at http://github.com/seanxwang/kagglemachine/.

How to use it
After instance creation, note public DNS name of the machine, from any client on the internet, access services by pointing your browser to:
Rstudio: http://:8787 (default ruser/ruser)
Jupyter: http://:9999 (default password jupyter)

Change the default password immediately. The EC2 instance runs on Ubuntu, you can ssh to it
Cost
The cost is based on AWS EC2 usage. You only pay hourly when instance running, shutdown the instance when done. When you are done with your project and no longer need data to be saved on server, terminate the instance.

The development of Kaggle Machine originates from the needs of data scientists participating in Kaggle challenges, hope it will be provide you a useful toolset as well.

Monday, October 12, 2015

Evaluating Amazon Machine Learning - in a Kaggle competition


Cloud changes IT in many ways. A new class of platform, database, messaging and app services have emerged to enable the rapid delivery of cloud native apps.  IT architecture can no longer be satisfied with delivering compute, network and storage. It must expand “up the stack”, putting more capabilities more rapidly into the hands of developers and business users.

A primary example of new IT capacities in demand is in the area of Big Data and Machine learning. With elasticity and on-demand computing, cloud has dramatically lowered the cost of entry. With emerging open source tool sets (e.g., Distributed Machine Learning Common, Jupyter, Anaconda, Python...), even individuals are now capable of performing analytics on large data sets, at a fraction of the cost of traditional methods (SAS grid).

To gain insight and bridge the gap between IT and data science community, I have experimented with Amazon Machine Learning (AML) service, comparing with custom built open source tool sets. By participating in a Kaggle competition, the results are also benchmarked in the real world.

The particular Kaggle competition I used has the goal of predicting hazard score using a dataset of property information. The hazard score to be predicted is a numeric value.

Machine Learning “as a service” test
AWS has delivered a service that puts modeling and predictive analysis capabilities into the hands of a non-IT and non-data-scientist person. Its documentation provides sufficient information to build a model and perform analytics, and requires no prior modeling skills.

The first step is creating a data source. From input data, AWS infers attribute types and creates a schema, which can be further modified by user.

The second step is to build a ML model using the data source. Amazon supports only three Models (Binary classification, Multiclass classification, Numerical regression). Since the prediction result is a numeric value, the only Amazon model applicable is the regression model. Note that there are many more models, attribute selection techniques and sequencing variations than the three models offered by AWS, thus making data science equally an art than it is a science.

AWS’s built in regression model evaluation uses residual distribution to evaluate the model. In this particular case, the model has a tendency for negative residuals which indicates an overestimation (the actual target tends to be smaller than the predicted target). 


To further evaluate model’s performance, it is used to calculate Hazard score for the real data set in Kaggle competition. After the competition closed, the AWS ML model obtained a score of 0.343. Compared to all submission, it ranks 1830th (over a total of 2236). The winning submission scored 0.397.


Machine Learning “on a server” test
For comparison, a custom server is built on AWS infrastructure. A set of data science tools and libraries from the open source community are then deployed, with no additional cost. For the Kaggle competition, an emerging ML model called XGBoost is used (developed by Tianqi Chen, a PhD student at University of Washington). The resulting score is 0.392, which ranks 299th/2236.

For cost comparison, running evaluation on Amazon ML was quite expensive. I only ran a few times with a record size of 50000, and end up spending over $50. The cost of custom server is almost negligible, as the use of a mid-sized EC2 instance is quite adequate to run XGBoost Python code.

Amazon Machine Learning “as a service” delivers a very easy to use tool. It frees users from build, scale, and maintain machine learning infrastructure. However, in its current form, it is only suited to handle a narrow set of problems that matches the simple models provided. As large enterprises typically faces more sophisticated data analytical challenges, as those represented in Kaggle competitions, AML is of limited value to the data science community.

On the other hand, as data science is being revolutionized by open source, there seems to be huge opportunities for Amazon and AML to improve on.

I haven’t found much benchmarking work out there. Here are a couple of posts comparing AML with others including Google Prediction and Azure Machine Learning.