Tuesday, June 3, 2025

Aurora Machine Learning

 

Amazon Aurora Machine Learning (ML) – Overview

Amazon Aurora Machine Learning allows twtech to invoke ML models directly from SQL queries, without having to write application code or move data outside of twtech Aurora database.

This integration brings the power of AWS ML services like Amazon SageMaker and Amazon Comprehend directly to Aurora, enabling real-time in-database inference.

 Key Highlights

Feature

Details

No data movement

Avoids ETL — queries run ML models from within Aurora.

In-SQL integration

Use SQL functions to call SageMaker or Comprehend.

Real-time predictions

Useful for fraud detection, recommendation engines, etc.

Supports

Aurora MySQL and Aurora PostgreSQL (specific versions).

Model types

Pretrained (e.g., NLP, sentiment) and custom models (SageMaker).

 Supported AWS ML Services

1.     Amazon SageMaker

o   Run custom ML models trained and hosted in SageMaker.

o   Great for use cases like image classification, regression, fraud detection.

2.     Amazon Comprehend

o   Built-in NLP tasks like sentiment analysis, entity recognition.

o   No model training required.

 Use Cases

·         Personalized product recommendations

·         Document classification / summarization

·         Fraud detection

·         Sentiment analysis on user reviews

·         Named entity recognition from customer messages

 How It Works

Aurora communicates with SageMaker or Comprehend over AWS PrivateLink, keeping data within the AWS network for low latency and high security.

You use SQL functions to call ML models from within queries.

 Example: Using SageMaker from SQL

MySQL:

# sql

SELECT ml.predict_sagemaker(
  endpoint_name => 'my-sagemaker-endpoint',
  payload => json_object('feature1', val1, 'feature2', val2)
) AS prediction;

PostgreSQL:

# sql
SELECT aws_ml.predict_sagemaker(
  'my-sagemaker-endpoint',
  json_build_object('feature1', val1, 'feature2', val2)
);

Example: Using Comprehend (Sentiment Analysis)

# sql
  SELECT aws_ml.comprehend_detect_sentiment(
'I love using Aurora ML!',
  'en'
);

Returns:

# json
{
  "Sentiment": "POSITIVE",
  "SentimentScore": {
    "Positive": 0.998,
    "Negative": 0.001,
    "Neutral": 0.001,
    "Mixed": 0.0
  }
}

 Supported Versions

Engine

Minimum Version

Aurora MySQL

2.09+ (MySQL 5.7 compatible)

Aurora PostgreSQL

11.9+, 12.4+, 13.3+, 14.3+

 Permissions & Setup

To use Aurora ML:

1.     Enable Aurora ML integration.

2.     Create and authorize IAM role for Aurora to invoke SageMaker/Comprehend.

3.     Use SQL functions to call models.

Example IAM policy needs:

# json
{
  "Effect": "Allow",
  "Action": [
    "sagemaker:InvokeEndpoint",
    "comprehend:DetectSentiment"
  ],
  "Resource": "*"
}

Attach this IAM role to the Aurora cluster using the aws rds add-role-to-db-cluster command.

 Pricing

·        No extra cost from Aurora.

·        Pay for:

o   SageMaker endpoint usage

o   Comprehend API calls

o   Data transfer if across regions (unlikely with PrivateLink)

 Limitations

·        Only inference is supported (not training).

·        Limited to specific Aurora versions.

·        Model input/output must be JSON format.

·        Cannot chain ML calls within stored procedures or triggers (best used in queries).


No comments:

Post a Comment

Kubernetes Clusters | Upstream Vs Downstream.

  The terms "upstream" and "downstream" in the context of Kubernetes clusters often refer to the direction of code fl...