Amazone runs the internet as we know it. Amazon Web Services (AWS) offers a comprehensive suite of machine learning (ML) services that cater to various needs and expertise levels. Follow along and learn the 23 most common AWS machine-learning interview questions and answers for your next ML Interview.
There are several AWS services available for machine learning. Some of the notable ones include:
Amazon Forecast uses forecast types to create predictions and evaluate predictors. Forecast types come in two forms:
Mean forecast type: A forecast using the mean as the expected value. Typically used as point forecasts for a given time point.
Quantile forecast type: A forecast at a specified quantile. Typically used to provide a prediction interval, which is a range of possible values to account for forecast uncertainty. For example, a forecast at the 0.65 quantile will estimate a value that is lower than the observed value 65% of the time.
Amazon SageMaker is a fully managed service by AWS that enables developers and data scientists to build, train, and deploy machine learning models at scale. It provides a comprehensive set of tools and services to streamline the entire machine learning workflow, from data preparation and model training to deployment and inference.
The typical steps involved in the machine learning workflow using Amazon SageMaker are:
Generate example data—To train a model, you need example data. The type of data that you need depends on the business problem that you want the model to solve. Often takes a lot of time exploring and preprocessing, or "wrangling," example data before using it for model training. To preprocess data, you typically do the following:
In SageMaker, you preprocess example data in a Jupyter notebook on your notebook instance. You use your notebook to fetch your dataset, explore it, and prepare it for model training.
Train a model—Model training includes both training and evaluating the model, as follows:
Training the model—SagesMaker provides built-in algorithms and supports custom algorithms. Depending on the size of your training dataset and how quickly you need the results, you can use resources ranging from a single general-purpose instance to a distributed cluster of GPU instances.
Evaluating the model—After you've trained your model, you evaluate it to determine whether the accuracy of the inferences is acceptable. In SageMaker, you use either the AWS SDK for Python (Boto) or the high-level Python library that SageMaker provides to send requests to the model for inferences.
Deploy the model— With SageMaker hosting services, you can deploy your model independently from your application code.
Monitor the model— Machine learning is a continuous cycle. After deploying a model, you monitor the inferences, collect "ground truth," and evaluate the model to identify drift.
Amazon Rekognition is a service that makes it easy to add powerful visual analysis to your applications. It provides two API sets:
Rekognition Image: that lets you easily build powerful applications to search, verify, and organize millions of images. It detects objects, scenes, activities, landmarks, faces, dominant colors, and image quality. Rekognition Image also extracts text, recognizes celebrities, and identifies inappropriate content in images. It also allows you to search and compare faces.
Rekognition Video: that lets you extract motion-based context from stored or live stream videos and helps you analyze them. Detects activities understands the movement of people in frame, and recognizes objects, celebrities, and inappropriate content in videos stored in Amazon S3 and live video streams.
A label refers to any of the following:
Amazon Rekognition can detect labels in images and videos. Amazon Rekognition also lets you set Custom labels to identify the objects and scenes in images that are specific to your business needs by training a machine learning model.
Amazon SageMaker and Amazon Machine Learning (Amazon ML) are both machine learning services offered by AWS, but they have some key differences in their features and target user bases:
Amazon ML:
It’s a cloud-based service that uses helpful wizards and visualization tools to guide developers of all levels through the ML model creation process. It then takes the models and obtains predictions using simple application programming interfaces (APIs). Throughout this process, you never need to manage complicated infrastructure or write custom code to generate the predictions;
When given data, Amazon ML chooses which methods to use automatically. This is followed by preprocessing such as dimensionality reducing and whitening, thus allowing for the creation of ML models that can generate predictions based on extracted patterns from the data. Predictions are easy to obtain using simple APIs without the need to implement custom prediction code or manage infrastructure.
With the automated process, you can easily go from models to prediction in a matter of seconds without taking the time to learn the details of ML methods.
Amazon SageMaker:
Provides various tools to create custom ML processes. This creation starts with spinning up a “notebook instance” to host the Jupyter Notebook application that holds all files, notebooks, and auxiliary scripts. Within the application, you create a new notebook to collect and prepare data, define your model, and begin the ML process.
Supports Python ML libraries as built-in algorithms like XGBoost, PCA, and K-Means, to name just a few. These algorithms are optimized on Amazon’s platform to deliver much higher performance than what they deliver running anywhere else.
Also, supports bringing in your favorite frameworks or work in a different programming language if you prefer that customization. It just involves packaging any ML algorithm into a Docker container, followed by plugging it into the training-service pipeline.
After launching training, Amazon SageMaker will spin up one or more “training instances” and upload all necessary data and scripts to run the training. The model is then ready for deployment to a production-ready cluster, and you can serve predictions via the HTTP API. Additionally, it includes built-in capabilities for A/B testing to experiment with different versions of models and find the best results.
In summary, the primary difference between the two lies in their target user bases. While Amazon ML’s high level of automation makes predictive analytics with ML accessible even for the layman, Amazon SageMaker’s openness to customized usage makes it a better fit for experienced data scientists.
For each dataset that you create in Amazon Forecast, you associate a dataset domain and a dataset type:
A dataset domain specifies a pre-defined dataset schema for a common use case, and does not impact model algorithms or hyperparameters. Amazon Forecast supports the following dataset domains: RETAIL Domain – For retail demand forecasting, WEB_TRAFFIC Domain – For estimating future web traffic, among others.
The dataset types are based on the type of data that you have and what you want to include in training. Each domain can have one to three dataset types, such as:
One can evaluate the machine learning model using historical data (offline) or live data:
Offline testing: here we use historical, -not live-, data to send requests to the model for inferences. First, we must deploy the trained model to an alpha endpoint, and use historical data to send inference requests to it. To send the requests, we use a Jupyter Notebook in your Amazon SageMaker notebook instance and either the AWS SDK for Python (Boto) or the high-level Python library provided by SageMaker. Options for offline model evaluation include Validating using a holdout set and k-fold validation.
Online testing with live data: SageMaker supports A/B testing for models in production by using production variants. Production variants are models that use the same inference code and are deployed on the same SageMaker endpoint. You configure the production variants so that a small portion of the live traffic goes to the model that you want to validate. For example, you might choose to send 10% of the traffic to a model variant for evaluation. After you are satisfied with the model's performance, you can route 100% of traffic to the updated model.
The number of images required to train a custom model depends on the variability of the custom labels you want the model to predict and the quality of the training data. For example, a distinct logo overlaid on an image can be detected with 1-2 training images, while a more subtle logo required to be detected under many variations (scale, viewpoint, deformations) may need in the order of tens to hundreds of training examples with high-quality annotations. If there is a high number of labeled images, the recommendation is to train the model with as many images as are available.
Although hundreds of images may sometimes be required to train a custom model with high accuracy, with Custom Labels you can first train a model with tens of images per label, review the test results to understand where it does not work, and accordingly add new training images and train again to iteratively improve the model.
Amazon SageMaker supports two types of deployments to update models in production: blue/green deployments and rolling deployments.
Amazon Forecast provides six built-in algorithms for you to choose from. These range from commonly used statistical algorithms like Autoregressive Integrated Moving Average (ARIMA), to complex neural network algorithms like CNN-QR and DeepAR+.
Autoregressive Integrated Moving Average (ARIMA): is especially useful for datasets that can be mapped to stationary time series. Datasets with stationary time series usually contain a combination of signal and noise. ARIMA acts like a filter to separate the signal from the noise, and then extrapolates the signal in the future to make predictions.
Convolutional Neural Network - Quantile Regression (CNN-QR): is a sequence-to-sequence (Seq2Seq) model for probabilistic forecasting that tests how well a prediction reconstructs the decoding sequence, conditioned on the encoding sequence. Works best when trained with large and complex datasets and it does not require related time series to contain data points within the forecast horizon.
Exponential Smoothing (ETS): is especially useful for datasets with seasonality and other prior assumptions about the data. ETS computes a weighted average over all observations in the input time series dataset as its prediction. The weights are exponentially decreasing over time and are dependent on a constant parameter, which is known as the smoothing parameter.
DeepAR+: is a supervised learning algorithm for forecasting scalar (one-dimensional) time series using recurrent neural networks (RNNs). When the dataset contains hundreds of feature time series, the DeepAR+ algorithm outperforms the standard ARIMA and ETS methods.
SageMaker provides multiple inference types so that one can pick the option that best suits the workload:
Real-Time Inference: is ideal for online inferences that have low latency or high throughput requirements. Use real-time inference for a persistent and fully managed endpoint (REST API) that can handle sustained traffic, backed by the instance type of your choice.
Serverless Inference: is ideal when you have intermittent or unpredictable traffic patterns. SageMaker manages all of the underlying infrastructure, so there’s no need to manage instances or scaling policies. You pay only for what you use and not for idle time.
Batch Transform: is suitable for offline processing when large amounts of data are available upfront and you don’t need a persistent endpoint. You can also use batch transform for pre-processing datasets. It can support large datasets that are GBs in size and processing times of days.
Asynchronous Inference: is ideal when you want to queue requests and have large payloads with long processing times. Asynchronous Inference can support payloads up to 1 GB and long processing times up to one hour. You can also scale down your endpoint to 0 when there are no requests to process.
Custom classification in Amazon Comprehend supports two types of classifier models: plain-text models and native document models. A plain-text model classifies documents based on their text content. A native document model also classifies documents based on text content but can also use additional signals, such as from the layout of the document.
Plain-text models have the following characteristics:
whereas Native document models have the following characteristics:
You train the model using semi-structured documents, which includes the following document types:
You train the model using English documents.
Amazon Comprehend supports three document processing modes:
Single-document processing: works by synchronous operations that return the results of the document analysis directly to your application. This is best suited when you are creating an interactive application that works on one document at a time.
Multiple document synchronous processing: is used when you have up to 25 documents that you want to process in each request. Amazon Comprehend sends back a list of responses, one for each document in the request. Requests made with these operations are synchronous so your application calls the operation and then waits for the response from the service.
Asynchronous batch processing: is used to analyze large documents and large collections of documents. For this, we put the documents into an Amazon S3 bucket and start an asynchronous job, Amazon Comprehend then stores the results of the analysis in the S3 bucket/folder that you specify in the request.
In Amazon Comprehend, both entity lists and annotation lists are used for training custom entity recognition models. However, they serve different purposes and provide different types of information. Here's the difference between entity lists and annotation lists in Amazon Comprehend:
Entity List:
Annotation List:
Predictor Explainability:
Helps you better understand how the attributes in your datasets impact your target variable.
Uses a metric called Impact scores to quantify the relative impact of each attribute and determine whether they increase or decrease forecast values. In the console, Impact scores range from 0 to 1, where a score of 0 denotes no impact, and a score close to 1 denotes a significant impact. In the SDKs, Impact scores range from -1 to 1, where the sign denotes the direction of the impact.
For example, consider a forecasting scenario where the target is sales and there are two related attributes: price and color. Forecast may find that an item’s price significantly impacts sales (high Impact score), while the item’s color has a negligible effect (low Impact score).
Forecast Explainability:
Helps you better understand how the attributes in your datasets impact forecasts for specific time series and time points. When you specify time series (item and dimension combinations) for Forecast Explainability, Amazon Forecast calculates Impact scores for attributes for only those specific time series.
Here, Impact scores have a similar meaning than before but it come in two forms: Normalized impact scores and Raw impact scores. Raw impact scores are useful for combining and comparing scores across different Explainability resources and they are not bounded. Normalized impact scores scale the raw scores to a value between -1 and 1.
In the forecasting scenario where the target is sales and there are two related attributes: price and color. Forecast may find that the item’s color has a high impact on sales for certain items, but a negligible effect for other items.
In the context of AWS, production variants, and shadow variants are used in the deployment and testing of machine learning models. Here's the difference between the two:
Production Variants:
Shadow Variants:
Shadow variants, on the other hand, are deployed alongside production variants but do not serve predictions to end-users or applications.
They are used for testing and validation purposes, allowing developers to compare the performance and behavior of different model versions or configurations.
They receive the same input data as the production variants but do not impact the actual predictions or outcomes. The purpose of shadow variants is to provide a way to evaluate the impact of changes or updates to the model without affecting the production environment.
By comparing the predictions and metrics of shadow variants with those of the production variants, developers can assess the potential impact of changes before deploying them to the live system.
Serverless Inference in the context of Amazon SageMaker refers to a purpose-built inference option that allows you to deploy and scale ML models without the need for manual configuration or management. It is designed to handle real-time inference requests and provides automatic scaling based on the incoming traffic. Serverless Inference is suitable for use cases with frequent or unpredictable traffic patterns, where you want to optimize cost and resource utilization while maintaining low latency for real-time predictions.
Asynchronous Inference, allows you to queue incoming inference requests and process them asynchronously. Instead of waiting for immediate responses, the requests are placed in a queue and processed in the background. Asynchronous Inference is suitable for use cases where the response time is not critical, and you can tolerate some delay in receiving the predictions. It can be particularly useful for batch processing or scenarios where the inference tasks require significant computation time.
Batch Transform in Amazon SageMaker is a feature that allows you to perform large-scale, offline inference on a dataset using a trained machine learning model. Some scenarios where Batch Transform can be useful are:
Preprocessing datasets: You can apply transformations or remove noise from the data using custom inference code and generate the preprocessed dataset for further analysis or model training.
Inference on large dataset: When a batch transform job starts on a large dataset, SageMaker initializes compute instances and distributes the inference or preprocessing workload between them.
Using outputs from one model as the inputs to another: For example, we may want to use a pre-processing step like word embeddings, principal components, or clustering, before training a second model to generate predictions from that information.
When predictions will ultimately be served outside of Amazon SageMaker: For example, we may have a large, but finite, set of predictions to generate which we then store in a fast-lookup datastore for serving.
More current data: When you have new data available that you want to incorporate into your forecasts, you need to retrain the predictor. Retraining allows the predictor to learn from the updated data and generate more accurate forecasts.
Predictor improvements: Amazon Forecast periodically releases updates and improvements to its algorithms and models. To take advantage of these improvements, you need to retrain your predictor using the latest version of the model.
Amazone runs the internet as we know it. Amazon Web Services (AWS) offers a comprehensive suite of machine learning (ML) services that cater to various needs and expertise levels. Follow along and learn the 23 most common AWS machine-learning intervi...
Azure Machine Learning (Azure ML) is a cloud-based service for creating and managing machine learning solutions. It’s designed to scale, distribute, and deploy machine learning models to the cloud. Follow along and learn the 23 most common Azure Mach...
Hadoop is an open-source big data processing framework. It leverages distributed computing to store and process large datasets in a fault-tolerant manner. According to recent reports, Apache Hadoop is one of the most sought-after big data skills with...