Personalize
π€ What is Amazon Personalize?¶
Amazon Personalize is a fully managed ML service that enables developers to build real-time personalized recommendation systems β without requiring ML expertise.
β Trained using your user behavior data (clicks, views, purchases) to deliver custom recommendations similar to those used by Amazon.com.
π― Core Use Cases¶
| Use Case | Example |
|---|---|
| E-commerce recommendations | βYou might also likeβ, product ranking, related items |
| Media streaming | Personalized playlists, next-watch suggestions |
| Marketing & email | Personalized content for email/newsletter |
| News & blogs | Article recommendation based on reading habits |
| Real-time personalization | Dynamic content or pricing for each user |
π§© Key Concepts & Components¶
| Component | Description |
|---|---|
| Dataset Group | A container for your data and models |
| Interactions | User behavior data: clicks, purchases, views |
| Users | Optional user metadata (e.g., age, location) |
| Items | Optional item metadata (e.g., category, price, release date) |
| Solution | A trained model using a chosen recipe |
| Campaign | Deployed solution for real-time recommendations |
| Batch Inference | Offline recommendation generation for large sets |
π Required Dataset Format¶
1. Interactions Dataset (Mandatory)¶
2. Items Dataset (Optional)¶
3. Users Dataset (Optional)¶
β All data is uploaded to Amazon S3 in CSV format.
π§ ML Recipes Available¶
| Recipe Name | Use Case |
|---|---|
HRNN |
Personalized ranking based on interactions |
HRNN-Metadata |
Uses item metadata for cold-start |
Popularity-Count |
Non-personalized trending recommendations |
Personalized-Ranking |
Re-rank items for a specific user |
SIMS |
Similar items (e.g., "related products") |
User-Personalization |
Most comprehensive personalization |
βοΈ Personalize Workflow¶
1. Prepare CSV data β Upload to S3
2. Create Dataset Group
3. Import datasets (interactions, items, users)
4. Create and train a Solution
5. Deploy Campaign (for real-time)
6. Call Personalize API for recommendations
π§ͺ Python Code Example (Boto3)¶
Step 1: Import Interactions Dataset¶
import boto3
personalize = boto3.client('personalize')
response = personalize.create_dataset_import_job(
jobName='import-interactions',
datasetArn='arn:aws:personalize:...:dataset/interactions',
dataSource={'dataLocation': 's3://my-bucket/interactions.csv'},
roleArn='arn:aws:iam::123456789012:role/service-role/AmazonPersonalize-Role'
)
Step 2: Get Real-Time Recommendations¶
runtime = boto3.client('personalize-runtime')
response = runtime.get_recommendations(
campaignArn='arn:aws:personalize:...:campaign/my-campaign',
userId='user123'
)
for item in response['itemList']:
print("Recommended item:", item['itemId'])
π§ͺ Sample Output¶
{
"itemList": [
{ "itemId": "productA", "score": 0.97 },
{ "itemId": "productC", "score": 0.92 }
]
}
β‘ Real-Time vs Batch¶
| Type | Use Case | Method |
|---|---|---|
| Real-time | Personal recommendations via API | get_recommendations() |
| Batch | Large-scale recommendations | Use create_batch_inference_job() |
π Security & Access¶
| Feature | Supported |
|---|---|
| IAM Policies | β |
| KMS Encryption for S3 | β |
| VPC Endpoint | β (Uses public endpoints) |
| Private dataset support | β S3 based |
π° Pricing (2024)¶
| Component | Cost |
|---|---|
| Training (solution) | ~$0.24 per training hour |
| Campaigns | ~~$0.05/hour per instance (~~$36/month) |
| Batch inference | ~$0.24 per hour |
| Free Tier | β Not included in free tier |
π§ Cost scales with:
-
Number of records
-
Training time
-
Campaign uptime
π§± Terraform Support¶
Direct support for Amazon Personalize in Terraform is limited. You can manage IAM roles and S3 buckets with Terraform, but model training and deployment is better done via Boto3 or CLI.
π Integrations¶
| AWS Service | Purpose |
|---|---|
| S3 | Store input datasets |
| Lambda | Trigger training or post-processing |
| API Gateway | Create custom endpoints for frontends |
| CloudWatch | Track metrics and monitor usage |
| Step Functions | Automate workflows |
β TL;DR Summary¶
| Feature | Amazon Personalize |
|---|---|
| Fully managed ML | β Yes |
| Requires ML skills? | β No |
| Recommender types | HRNN, SIMS, Popularity, Ranking |
| Real-time API support | β Yes |
| Cold start support | β With metadata |
| AutoML | β Automates recipe and tuning |
| Free tier | β Not included |
| Use cases | E-commerce, media, marketing |