SageMaker recommendation engine demo
- On AWS SageMaker Console launch a new notebook instance.
- Run the python notebook sagemaker/factorisation_machines.ipynb. Please note this notebook is sourced from https://gitlab.com/juliensimon/dlnotebooks.
- Deploy the sagemaker endpoint. This is required to launch the cloudformation web app stack.
We use the MovieLens dataset.
F. Maxwell Harper and Joseph A. Konstan. 2015. The MovieLens Datasets: History and Context. ACM Transactions on Interactive Intelligent Systems (TiiS) 5, 4, Article 19 (December 2015), 19 pages. DOI=http://dx.doi.org/10.1145/2827872
- Download movies & upload to s3 with the right metadata. This metadata is later used to index elastic search
wget http://files.grouplens.org/datasets/movielens/ml-100k/u.item
aws s3 cp u.item s3://<yourbucketData>/movies.csv --metadata dataset_id=100KDS,type=movies
- Download users & upload to s3 with the right metadata. This metadata is later used to index elastic search
wget http://files.grouplens.org/datasets/movielens/ml-100k/u.user
aws s3 cp u.user s3://<yourbucketData>/users.csv --metadata dataset_id=100KDS,type=users
- Download ratings & upload to s3 with the right metadata. This metadata is later used to index elastic search
wget http://files.grouplens.org/datasets/movielens/ml-100k/u.data
aws s3 cp u.data s3://<yourbucketData>/ratings.csv --metadata dataset_id=100KDS,type=ratings
- Create a codepipeline stack using codebuild_cloudformation.json
- Start a build on codepipeline. This should upload the following artifacts in the s3 bucket you specified in the codepipeline stack
- Cloudformation template
- webapp
- lambda code
- Download the zip of webapp to your local file system and extract them.
- Upload the webfiles to your destination s3 bucket to serve as the content origin
aws s3 cp --recursive ~/Downloads/webapp/ s3://<yourbucket>/webapp
- Make sure you that you have metadata "dataset_id" (100KDS) & "type" ( movies, users, ratings) when you uploaded the datasets into s3 bucket. Run the indexElasticSearch function using the following sample test events to load the dataset into Elastic Search
- Sample Lambda Test Data - Load movies into elastic search
{
"Records": [
{
"s3": {
"object": {
"key": "movies.csv"
},
"bucket": {
"name": "<your-bucket-containing-movies.csv>"
}
}
}
]
}
- Sample Lambda Test Data - Load users into elastic search
{
"Records": [
{
"s3": {
"object": {
"key": "users.csv"
},
"bucket": {
"name": "<your-bucket-containing-movies.csv>"
}
}
}
]
}
- Sample Lambda Test Data -Load user ratings into elastic search
{
"Records": [
{
"s3": {
"object": {
"key": "rating.csv"
},
"bucket": {
"name": "<your-bucket-containing-movies.csv>"
}
}
}
]
}
Your recommendation engine web app is now ready to use, the url is the output of the cloudformation.