/hannari-python-5

Demonstration for Hannari Python #5 at Kyoto

Primary LanguagePython

Hannari Python #5 Demonstration

This project includes demonstration code for the presentation at Hannari Python #5 at Apr 20th 2018.

You can see sample code to bring your own algorithm to Amazon SageMaker. The implemented algorithm here is completely same to the one provided by awslabs but whole scripts have been simplified so that you can just focus on three scripts below.

  • Dockerfile
  • train
  • serve

Prerequisites

  • Docker

How to run in local

You need to build docker image at first.

docker build -t sagemaker-sklearn-example .

Then, create directories required to run train and serve scripts like this

mkdir -p test_dir/{model,output}

Thereafter, you can run train as follows

docker run -v $(pwd)/test_dir:/opt/ml --rm sagemaker-sklearn-example train

This will generate model under test_dir/model and serve will use it by

docker run -v $(pwd)/test_dir:/opt/ml --rm -p 8080:8080 sagemaker-sklearn-example serve

You can try to call API with 10 randomly selected samples from training data like this

awk '{print substr($1, 1+index($1, ","))}' test_dir/input/data/train/iris.csv | sort -R | head -10 | curl --data-binary @-  -H "Content-Type: text/csv" -v http://localhost:8080/invocations

Bring this to Amazon SageMaker

You can refer to my presentation slides. The required steps are same to the ones mentioned in this blog.

References