Data Science in the Cloud: Amazon SageMaker

HomeInsightsBlogs | Last Updated August 4, 2021 - by samuel stiyer under data science & analytics

Published onSeptember 16, 2019

Amazon Web Services (AWS) offers a vast catalog of services and tools which ought to make even the most veteran Data Scientists or Engineer’s minds bubble with ideas of how to leverage the incredible potential available to them in Amazon’s cloud platform. One service has always stood out to me in terms of its potential to be harnessed to solve the challenge of deploying machine learning models into production – Amazon SageMaker. On AWS, the SageMaker service provides a platform for data scientists to deploy pre-packaged amazon models or their own custom models as an easily accessible and scalable API endpoint. One of my favorite examples of an organization utilizing SageMaker is the NFL utilizing the platform to deploy machine learning models which are capable of quickly breaking down gameplay to improve the fan experience with NFL Next-Gen Stats (NGS).

Here at Softcrylic we’ve explored SageMaker internally using a the Kaggle Telco Customer Churn dataset to explore the ins and outs of the machine learning service. We ultimately wanted to learn as much as we could about the service and see if we could easily deploy our own custom Sci-Kit Learn Random Forest customer churn classifier model. We were shocked at how easy it was to get up and running; it was literally one line of code after training the model to deploy it.

To perform all the coding for this project we used a SageMaker Notebook, which is a Jupyter notebook or JupyterLab frontend to one of AWS’s machine learning ec2s. This really enabled our team at Softcrylic to get rolling with the Scikit Learn SageMaker SDK in a familiar Jupyter coding environment. Once inside your Notebook environment you can import the SageMaker module along with the other python packages you will be using.

Data Science in the Cloud: Amazon SageMaker

After establishing your SageMaker session you can pre-process your data just like business as usual. Below we do some simple data cleaning and transformation prior to training our basic random forest classifier.

Data Science in the Cloud: Amazon SageMaker

After processing your data, we need to create a s3 subdirectory for all our modeling data. SageMaker uses this subdirectory location during the training process to read all the data into the training environment.

Data Science in the Cloud: Amazon SageMaker

Then we need to create the python script which will be executed by SageMaker to train the model. This requires us to define how SageMaker should parse the input arguments which represent the hyper parameters we plan to train the model with. We also need to tell SageMaker where to read the training data from and how to fit the model. Within the python script, we can also have SageMaker dump whatever model artifacts we want to another directory; in our testing we decided to have SageMaker drop the model coefficients.

Data Science in the Cloud: Amazon SageMaker

After the creation of the training script we then define the size of the machine, we wish to train our model in. params_rf is a python dictionary we created, which contains the values of the hyper parameters we are choosing to train our model with. Further, it is important to note that we are using the sklearn.estimator.SKLearn() method to train our model, if we wanted to use another modeling library we would need to use a separate estimator belonging to that respective library instead.

Data Science in the Cloud: Amazon SageMaker

Finally, with one line of code, we deploy our model as a SageMaker hosted API Endpoint.

Data Science in the Cloud: Amazon SageMaker

Through our experience with SageMaker we found the service has a ton of potential. Importantly, we discovered SageMaker offers us a managed platform where any machine learning use case can be worked on and deployed in, which means SageMaker has the flexibility to be used within any business vertical. Further, SageMaker streamlines the process of deploying models. Due to this ease, other team members, stakeholders, or clients can quickly leverage deployed models and immediately extract value from the models in their new production setting.

Hopefully this post encourages you to explore the capabilities of Amazon SageMaker and please feel free to reach out to myself (@SamStiyer on twitter) if you have any questions or feedback regarding the post!

Samuel Stiyer

Sam Stiyer is a Data Science Consultant at Softcrylic. He is a Machine Learning, R / Python Programming, Big Data & Tidy Data Enthusiast! He loves answering challenging data related questions and learning new things. Connect with him on <a href="https://www.linkedin.com/in/samuel-stiyer/">LinkedIn</a> and <a href="https://twitter.com/SamStiyer">Twitter (@SamStiyer)</a> where he actively discusses applications of Advanced Analytics.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search