Please read Train machine learning models using Amazon Keyspaces as a data source blog for more detailed instructions to run this notebook.
We provides step-by-step instructions to use SageMaker to ingest customer data from Amazon Keyspaces and train a clustering model that enables you to segment customers. This information can be used for targeted marketing, greatly improving your business KPI.
- First, we install Sigv4 driver to connect to Amazon Keyspaces
The Amazon Keyspaces SigV4 authentication plugin for Cassandra client drivers enables you to authenticate calls to Amazon Keyspaces using IAM access keys instead of user name and password. To learn more about how the Amazon Keyspaces SigV4 plugin enables
IAM users, roles, and federated identities
to authenticate in Amazon Keyspaces API requests, seeAWS Signature Version 4 process (SigV4)
- Next, we establish a connection to Amazon Keyspaces
- Next, we create new Keyspace blog_(yyyymmdd) and a new table online_retail
- Next, we download retail data about customers.
- Next, we ingest retail data about customers into Keyspaces.
- Next, we use a notebook available within SageMaker Studio to collect data from the Keyspaces database, and prepare data for training using KNN Algorithm. Most of our customers use SageMaker Studio for end-to-end development of ML Use Cases. They use this notebook as a starting point and customize it for their use case. Also, they are able to share this with other collaborators without requiring them to install any additional software.
- Next, we train the data for clustering.
- When the training is completed, we can view the mapping between customers and their associated clusters.
- And finally, we run a Cleanup Step to drop Keyspaces table to avoid future charges.
Contributers
Vadim Lyakhovich (AWS)
Ram Pathangi (AWS)
Parth Patel (AWS)
Arvind Jain (AWS)
The notebook execution role must include permissions to access Amazon Keyspaces and Assume the role.
-
To access Amazon Keyspaces database - use
AmazonKeyspacesReadOnlyAccess
orAmazonKeyspacesFullAccess
managed policies. Use the least privileged approach for your production application.
See more atAWS Identity and Access Management for Amazon Keyspaces
. -
To assume the role, you need to have
sts:AssumeRole action
permissions.{ "Version": "2012-10-17", "Statement": [ { "Action": [ "sts:AssumeRole" ], "Effect": "Allow", "Resource": "*" } ] }
This notebook was tested with conda_python3
kernel and should work with Python 3.x
.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved
SPDX-License-Identifier: MIT-0