How to run python script (which has some functions written in it) in sagemaker?

1.3k views Asked by At

I have python script.py, which is a KNN machine learning algorithm writer from scratch. Just using pandas and numpy libraries. Script contains all the functions. It takes some arguments such as train_data, test_data, k_val etc. And I want to run this in the sagemaker. Looking for a solution how I can put this script in docker image and invoke it in sagemaker from ECR container.

1

There are 1 answers

0
Shitij Mathur On

What you need is called SageMaker BYOC (Bring Your Own Container).

SageMaker has pre-built containers for most of the ML algorithms, however for custom algorithms and custom code it provides support for creating custom containers.

They are basically of 2 types: If your goal is to train a model, run validation & save the model file. -Training Container

If your goal is to use an existing model for inference, with SageMaker Endpoint Hosting or Batch Transform. -Serving Container

Refer to this repository for detailed steps. The files predictor.py & serve are the most important, which contain your custom code.

References: Link1 Link2