AWS Machine Learning Specialty (AWS) cheat sheet
AWS Machine Learning Specialty · Keep the key ideas within reach.
Data Engineering
Amazon S3 is the default landing zone for training data; SageMaker training jobs read from S3 via the training channel, and the IAM role attached to the job needs s3:GetObject on the bucket and prefix.
AWS Glue Data Catalog stores table schemas and partition metadata; Athena, Redshift Spectrum, and SageMaker Data Wrangler query it directly, so schema changes should be made in the catalog, not duplicated per engine.
Apache Parquet and ORC are columnar formats that support predicate pushdown and compression; converting CSV to Parquet typically reduces S3 scan volume and Athena cost, which is billed per byte scanned.
Partitioning by a low-cardinality column such as date or region lets Athena and Glue prune partitions; a table with 10,000+ small partitions is worse than a few hundred larger ones because of per-partition overhead.
AWS Glue ETL jobs run Apache Spark; Glue crawlers infer schemas and write to the Data Catalog, while Glue DataBrew is a no-code visual profiling and transformation tool for tabular data.
Amazon Kinesis Data Streams retains records 24 hours by default (up to 365 days), while Kinesis Data Firehose delivers to S3, Redshift, or OpenSearch with near-real-time buffering; Firehose is for delivery, not for custom consumers.
AWS DMS with the S3 target and a Glue job is the standard CDC pipeline for replicating an operational database into a data lake; DMS alone does not transform data.
SageMaker Feature Store has an online store (low-latency reads for inference, backed by DynamoDB) and an offline store (S3/Parquet for training); the online store is not a substitute for batch training reads.
Exploratory Data Analysis
Mean is sensitive to outliers; median and IQR are robust. A value is a common outlier candidate if it lies below Q1 - 1.5IQR or above Q3 + 1.5IQR.
Pearson correlation measures linear association only; Anscombe's quartet shows identical means, variances, and correlations with very different distributions, so always plot before trusting a correlation.
Class imbalance: accuracy is misleading. Use precision, recall, F1, ROC-AUC, or PR-AUC; PR-AUC is more informative than ROC-AUC when the positive class is rare.
Multicollinearity inflates variance of linear-model coefficients; detect with a correlation matrix or variance inflation factor (VIF > 5-10 is a common flag) and drop or combine features.
Skewed features can be transformed with log1p, Box-Cox, or Yeo-Johnson; Yeo-Johnson handles zero and negative values, Box-Cox requires strictly positive values.
SageMaker Data Wrangler produces a data-quality report covering missing values, duplicate rows, outliers, and target leakage; target leakage is a feature that encodes the label and inflates validation scores.
SageMaker Clarify runs bias metrics such as class imbalance (CI) and difference in positive proportions in labels, and explains predictions with SHAP values.
Train/serve skew arises when feature computation differs between training pipelines and the inference endpoint; Feature Store and shared transformation code reduce this risk.
Modeling
SageMaker built-in algorithms: XGBoost for tabular classification/regression, Linear Learner for scalable linear models, K-Means for clustering, DeepAR for probabilistic time-series forecasting, BlazingText for text classification and word vectors.
XGBoost is a gradient-boosted tree ensemble that handles non-linear interactions and missing values natively; it needs little feature scaling but requires tuning of max_depth, eta, and num_round.
Regularization: L1 (Lasso) drives coefficients to zero and performs feature selection; L2 (Ridge) shrinks coefficients smoothly; Elastic Net combines both with the l1_ratio parameter.
SageMaker Automatic Model Tuning uses Bayesian optimization by default; specify HyperParameterTuningJobObjective with a metric name, and set max_jobs and max_parallel_jobs to bound cost.
SageMaker Automatic Model Tuning supports early stopping so poorly performing trials are terminated before completing all epochs, reducing total training cost.
For imbalanced classification, use scale_pos_weight in XGBoost or adjust the classification threshold after training rather than resampling blindly.
Cross-validation with k folds trades compute for a lower-variance performance estimate; a single holdout split is cheaper but noisier, especially on small datasets.
SageMaker JumpStart provides pre-trained foundation and task models that can be fine-tuned or deployed directly, useful when labeled data is limited.
Machine Learning Implementation and Operations
SageMaker real-time endpoints are for low-latency synchronous inference; Serverless Inference scales to zero and suits intermittent traffic; Asynchronous Inference handles large payloads and long processing with a queue.
Batch Transform is for scoring large datasets where no persistent endpoint is needed; it writes output to S3 and charges only for the job duration.
SageMaker Model Monitor detects data drift, model-quality drift, and bias drift by comparing live endpoint traffic against a baseline computed from training data.
SageMaker Pipelines orchestrates steps (processing, training, evaluation, conditional, register) as a DAG; a model registry approval status gates deployment.
SageMaker Debugger captures tensors and system metrics during training and can emit built-in rules such as loss-not-decreasing or overtraining.
A/B testing with production variants splits endpoint traffic by weight; you can shift traffic gradually and compare metrics before promoting a new model.
CloudWatch alarms on endpoint metrics (ModelLatency, InvocationsPerInstance, 5XXError) trigger auto scaling or rollback; auto scaling policies target a utilization or invocation metric.
Provisioned throughput on an endpoint guarantees capacity and reduces cold-start latency for real-time inference; it is billed hourly regardless of traffic.
SageMaker training jobs support Spot instances with checkpointing to S3 so interrupted jobs resume instead of restarting from scratch.