CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
    • 1.Algorithm Selection: Mapping by Problem Type
    • 2.SageMaker Builtin 1: XGBoost, Linear Learner, K-Means, KNN
    • 3.SageMaker Builtin 2: Text, Images, Time Series, Recommendations
    • 4.Unsupervised Learning and Anomaly Detection: RCF, PCA, IP Insights, Topic Models (LDA/NTM)
    • 5.Week 6 Comprehensive Review: Algorithm Selection and SageMaker Builtin Algorithms
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 6/Day 3

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 6 · Day 3~30 min read

Day 3 - SageMaker Builtin 2: Text, Images, Time Series, Recommendations

📌 Key Takeaways

  • When a question mentions text, images, time series, or sparse data, the answer shifts away from XGBoost toward a specialized builtin.
  • BlazingText has two modes. If you have labels and are classifying documents, use supervised mode; if you want word vectors without labels, use Word2Vec.
  • The textbook answer for images + insufficient data is use_pretrained_model=1 transfer learning + data augmentation. If you also need object locations, use Object Detection.
  • DeepAR trains thousands of related time series together in one model so it can forecast new or short series too, and it outputs P10/P50/P90 probability intervals rather than point estimates.
  • Factorization Machines is dedicated to second-order interactions in ultra-high-dimensional sparse data blown up by one-hot encoding, and its recommended input is RecordIO-protobuf (float32).

Data Shape Decides the Algorithm

Yesterday we covered tabular-data algorithms. Today we organize the specialized builtins used when the data has a special shape: text, images, time series, and sparse interactions.

Data shapeGoalBuiltinInput formatReason
TextDocument classificationBlazingText (supervised)Text file, __label__<label> sentenceBased on fastText, very fast on large corpora
TextWord embeddingsBlazingText (Word2Vec)Text file (whitespace-tokenized)Learns a semantic space without labels
ImageLabel classificationImage ClassificationRecordIO or images (.jpg/.png) + .lstResNet-based CNN, supports transfer learning
ImageObject locationObject Detection—Location is needed, not just classification
ImagePixel levelSemantic Segmentation—Assigns a class to every pixel
Time seriesForecast future valuesDeepARJSON LinesShared learning across many related series, probabilistic forecasts
Sparse interactionsRecommendation, click predictionFactorization MachinesRecordIO-protobuf (float32)Optimized for sparse data
                  [Data is not tabular]
                            │
        ┌───────────┬───────┴────────┬─────────────┐
      Text        Image          Time series     User-item
        │            │               │            (very sparse)
   Labels?      What do you        Many related      │
   ├─ Yes →     want?              series?       Factorization
   │  supervised ├─ Label only →   ├─ Yes →      Machines
   │  (document  │  Image          │  DeepAR    (RecordIO-protobuf)
   │  classif.)  │  Classification └─ No →
   └─ No →       ├─ Location too →    Single-series statistical
      Word2Vec   │  Object            method or Forecast
      (embedding)│  Detection
                 └─ Pixel level →
                    Semantic Segmentation

BlazingText — Text Classification and Word Embeddings

A builtin that accelerates Word2Vec and text classification on GPUs. It has two modes.

  • Word2Vec (unsupervised): Embeds words as vectors. Used for finding similar words and generating features for downstream tasks
  • Text Classification (supervised): Document → label (sentiment, topic, etc.). Based on fastText
Mode decision:
  Labels exist and you classify documents → supervised (text classification)
  No labels and you only need word vectors → Word2Vec (cbow / skipgram / batch_skipgram)
  • Input: Text file (whitespace-tokenized). Supervised mode uses the __label__<label> sentence format
  • Strengths: Overwhelming speed on large corpora, multilingual support, and handling of OOV (out-of-vocabulary) words through subwords
Word2Vec modeTraining directionCharacteristics
cbowPredict the center word from the surrounding contextFast and strong on frequent words
skipgramPredict the surrounding context from the center wordBetter representations of rare words
batch_skipgramBatched, distributed training version of skipgramScalability on large corpora

BlazingText's Word2Vec places words with similar meanings close together in the vector space by either "guessing the center word from its context (CBOW)" or "guessing the context from the center word (skip-gram)." The learned embeddings themselves can be used for word similarity search, or passed to other models as input features. On the exam, "semantic similarity of words" / "embeddings" is the signal for Word2Vec mode, and "classify documents into categories" is the signal for supervised mode.

⚠️ Trap: In supervised mode, the label prefix in the training file must take the form __label__. An option that puts the label in a column like a regular CSV is wrong.

Image Classification — Image Classification

A builtin that classifies images into one or multiple labels using a CNN (ResNet).

  • Use: Single-label/multi-label image classification
  • Input: RecordIO or images (.jpg/.png) + a .lst list file
  • Key technique: Transfer learning — starting from ImageNet pretrained weights with use_pretrained_model=1 gives good performance even with little data
Key hyperparameters:
  num_classes, num_training_samples
  use_pretrained_model   0 (from scratch) | 1 (transfer learning)
  image_shape, learning_rate, mini_batch_size
  augmentation_type      image augmentation (crop/color, etc.)
  • When data is scarce, transfer learning + data augmentation is the textbook approach.
  • If you also need the location of objects, use the Object Detection builtin rather than classification; for pixel level, use Semantic Segmentation.
SituationChoiceReason
Fewer than a few thousand labeled imagesuse_pretrained_model=1 + augmentation_typeTraining from scratch overfits
Very many labeled images and a specialized domainConsider use_pretrained_model=0When the domain differs greatly from the pretraining domain
"Does this photo have a defect?"Image ClassificationOnly a label is needed
"Where is the defect?"Object DetectionBounding boxes are needed
"Paint the defect region pixel by pixel"Semantic SegmentationPixel-level classes

⚠️ Trap: Choosing "train a deeper network from scratch" for "images + insufficient data" is wrong. The less data you have, the more you should borrow pretrained weights and expand the data with augmentation rather than enlarge the model.

DeepAR — Time Series Forecasting

An RNN-based time series forecasting builtin. Its key strength is that it does not model each series separately but learns multiple related series together and shares patterns.

  • Use: Forecasting future values of demand, sales, and traffic, with probabilistic (quantile) forecasts
  • Input: JSON Lines — each time series has start, target, and optionally cat (category) and dynamic_feat (covariates)
  • Strengths: When there are many related series, such as thousands of stores, it is more accurate than modeling each one individually. New or short series (cold start) can also be forecast using patterns learned from similar series
Key hyperparameters:
  context_length      length of the past input window
  prediction_length   length of the forecast window
  epochs, num_cells, num_layers
  likelihood          output distribution (Gaussian, etc.)

Traditional ARIMA and exponential smoothing model each time series separately, whereas DeepAR trains multiple related series in a single model and cross-learns seasonality and trend. That is why a new item with a short history can borrow the patterns of similar items. Because the output is a distribution (quantiles) rather than a point estimate, it provides uncertainty intervals in the form of P10/P50/P90. On the exam, "thousands of related time series" / "new product demand" / "probabilistic forecast intervals" are DeepAR signals. If you need something more managed, Amazon Forecast is the answer.

Conditions Where DeepAR Beats Single-Series Techniques

ConditionDeepARSingle-series statistical techniques (ARIMA, etc.)
Thousands of related seriesAdvantageous (shares patterns)A separate model must be built for each series
New or short history (cold start)Advantageous (borrows from similar series)Cannot estimate without data
Only a single time seriesSmall advantageCompetitive enough
Uncertainty intervals neededProvides quantile forecastsSeparate interval estimation required
Reflecting covariates (promotions, price)Fed in via dynamic_featAwkward to extend

"Time series forecasting" does not automatically mean DeepAR. If there is only one series and the data is short, deep learning is overkill. DeepAR is confirmed only when there is a clue such as "many related series" or "probability intervals needed."

Factorization Machines — Sparse High-Dimensional Recommendation

It efficiently models second-order interactions between features in data that is very sparse and high-dimensional, such as user-item data.

  • Use: Recommendation (click prediction, rating prediction), sparse classification/regression
  • Input: RecordIO-protobuf (float32). It is optimized for sparse data, so CSV is not recommended
  • Strengths: It learns interactions efficiently even on ultra-high-dimensional sparse input blown up by one-hot encoding
Key hyperparameters:
  num_factors        dimension of the latent factors
  predictor_type     binary_classifier | regressor
  bias/linear/factors   per-term regularization and initialization settings

In a recommendation context, FM is a generalization of collaborative filtering. If you feed in user ID and item ID as one-hot vectors, it behaves like matrix factorization, and you can also feed additional features (time, context) alongside them.

ComparisonFactorization MachinesClassic collaborative filtering (matrix factorization)
InputArbitrary feature vector (one-hot + extra features)Only the user-item matrix
Side informationTime, context, demographics can be addedHard to add
Cold startPartly mitigated by extra featuresWeak on new users and items
Handling sparsityGeneralizes interactions through latent factorsFocuses on observed cells

An option that says to use CSV with FM is a wrong-answer signal. Representing sparse high-dimensional data as CSV produces a huge dense table that is mostly zeros, which is inefficient. RecordIO-protobuf (float32) is the correct answer.

Preprocessing and Evaluation Metrics

Specialized builtins have different preprocessing requirements from tabular algorithms. In some cases the very concept of "scaling" does not apply.

BuiltinPreprocessing requirementScaling
BlazingTextWhitespace tokenization; __label__ prefix for supervisedNot applicable (token input)
Image ClassificationResize (image_shape), augmentation, build RecordIO or .lstPixel normalization is handled by the container
DeepAROrganize start/target per series, handle missing intervals, align covariatesNot applicable (series scale is normalized internally)
Factorization MachinesOne-hot encode, then convert to a sparse representationScale cleanup recommended for numeric features
TaskMain metricWhat it tells youTrap
Text classification (imbalanced classes)F1, macro F1Whether minority categories are also caughtAccuracy is pulled toward the majority category
Image classification (multi-label)Per-label precision/recallPerformance variation across tagsOverall accuracy hides the variation
Time series forecasting (point estimate)RMSE, MAEAverage size of the errorSays nothing about the quality of interval forecasts
Time series forecasting (probability interval)Quantile loss familyWhether the P10/P50/P90 interval encloses the actual valueWith RMSE alone you cannot tell if the interval is too wide
Recommendation (click prediction)AUC, PR-AUCQuality of click-probability rankingAccuracy is meaningless when the click rate is under 1%
Recommendation (rating prediction)RMSERating errorA different matter from top-ranking quality

Recommendation and click-prediction data is a classic imbalance case, with very few positives (clicks). An option that picks accuracy as the metric here is wrong; AUC, which looks at ranking quality, or PR-AUC, which is honest about the minority class, is the correct direction.

Question Clue → Answer Mapping Table

Question clueAnswer directionAccompanying details
"Classify documents into categories"BlazingText supervised__label__ format
"Semantic similarity of words / embeddings"BlazingText Word2Veccbow / skipgram
"Images + little data"Image ClassificationTransfer learning + augmentation
"Object locations in images"Object DetectionNot classification
"Separate regions pixel by pixel"Semantic Segmentation—
"Thousands of related series / new product demand / P90 interval"DeepARJSON Lines, context_length
"Also reflect external variables such as promotions"DeepAR dynamic_featCovariate channel
"User-item / very sparse / recommendation"Factorization MachinesRecordIO-protobuf
"Fully managed and fast"Comprehend / Rekognition / Forecast / PersonalizeNot training it yourself

Tomorrow we cover the unsupervised and anomaly-detection builtins that work without labels (RCF, PCA, IP Insights, LDA/NTM).

📖 Glossary

  • fastText: A text classification and embedding technique that breaks words down into substrings (subwords). It is the basis of BlazingText's supervised mode.
  • OOV (out-of-vocabulary): A word that was not in the training vocabulary. With subword representations, a vector can be built even for a word seen for the first time.
  • cbow / skipgram: A method of guessing the center word from its context / a method of guessing the context from the center word. These are the two training directions of Word2Vec.
  • Transfer learning: A technique that starts from weights pretrained on large-scale data and fine-tunes them with a small amount of data.
  • Data augmentation: A technique that artificially expands the training images through cropping, color changes, and similar operations to reduce overfitting.
  • .lst file: A list file that records image paths and labels line by line, passed to Image Classification.
  • JSON Lines: A format that holds one JSON object per line. It is how DeepAR receives one time series per line.
  • context_length / prediction_length: The length of the past window DeepAR looks at / the length of the future window to forecast.
  • Quantile forecast (P10/P50/P90): A probabilistic forecast that returns the "10%, 50%, and 90% probability lines" together instead of a single value.
  • Latent factor: A hidden low-dimensional feature vector that describes users and items. FM's num_factors sets its dimension.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

You have daily sales data for 1,000 stores and want to forecast the next 4 weeks of demand, as P10/P50/P90 intervals, for a newly opened store with a short data history. Which built-in algorithm is MOST suitable?

Question 2

You want to train a model that classifies customer review documents as "positive/negative/neutral" on a large corpus very quickly. Which built-in algorithm and mode are MOST suitable?

Question 3

You want to classify product defects using a small image dataset of about 2,000 images. With so little data, you are worried about performance. Which approach is MOST recommended?

Question 4

You one-hot encoded user ID, item ID, and context features to create very sparse, high-dimensional click-through-rate prediction data. Which built-in algorithm efficiently learns the interactions, and what is the recommended input format?

Question 5

In which situation is it MOST appropriate to use BlazingText's Word2Vec mode?

PreviousSageMaker Builtin 1: XGBoost, Linear Learner, K-Means, KNNWeek 6 · Day 2Next Unsupervised Learning and Anomaly Detection: RCF, PCA, IP Insights, Topic Models (LDA/NTM)Week 6 · Day 4

Official references

  • MLS-C01 official exam page(opens in a new tab)

On this page

  • Key Takeaways
  • Data Shape Decides the Algorithm
  • BlazingText — Text Classification and Word Embeddings
  • Image Classification — Image Classification
  • DeepAR — Time Series Forecasting
  • Conditions Where DeepAR Beats Single-Series Techniques
  • Factorization Machines — Sparse High-Dimensional Recommendation
  • Preprocessing and Evaluation Metrics
  • Question Clue → Answer Mapping Table
  • Glossary
  • Practice Questions