Microsoft Certified Azure AI Fundamentals
Microsoft Certified Azure AI Fundamentals
Fundamentals
Introduction to AI
AI enables us to build amazing software that can improve health care, enable
people to overcome physical disadvantages, empower smart infrastructure,
create incredible entertainment experiences, and even save the planet!
What is AI?
Data scientists can use all of that data to train machine learning models that
can make predictions and inferences based on the relationships they find in
the data.
Machine learning models try to capture the relationship between data. For
example, suppose an environmental conservation organization wants
volunteers to identify and catalog different species of wildflower using a
phone app. The following animation shows how machine learning can be
used to enable this scenario.
Most computer vision solutions are based on machine learning models that
can be applied to visual input from cameras, videos, or images. The following
table describes common computer vision tasks.
Expand table
Task Description
Image classification
Image classification involves training a machine learning model to classify images based on their cont
traffic monitoring solution you might use an image classification model to classify images based on th
contain, such as taxis, buses, cyclists, and so on.
Object detection
Object detection machine learning models are trained to classify individual objects within an image, a
location with a bounding box. For example, a traffic monitoring solution might use object detection to
of different classes of vehicle.
Task Description
Semantic
segmentation
Semantic segmentation is an advanced machine learning technique in which individual pixels in the im
according to the object to which they belong. For example, a traffic monitoring solution might overlay
"mask" layers to highlight different vehicles using specific colors.
Image analysis
You can create solutions that combine machine learning models with advanced image analysis techni
information from images, including "tags" that could help catalog the image or even descriptive capti
the scene shown in the image.
Task Description
Face detection,
analysis, and
recognition
Face detection is a specialized form of object detection that locates human faces in an image. This can
classification and facial geometry analysis techniques to recognize individuals based on their facial fea
Optical character
recognition (OCR)
Optical character recognition is a technique used to detect and read text in images. You can use OCR
photographs (for example, road signs or store fronts) or to extract information from scanned docume
invoices, or forms.
Analyze and interpret text in documents, email messages, and other sources.
Interpret spoken language and synthesize speech responses.
Automatically translate spoken or written phrases between languages.
Interpret commands and determine appropriate actions.
For example, Starship Commander is a virtual reality (VR) game from Human Interact that takes
place in a science fiction world. The game uses natural language processing to enable players to
control the narrative and interact with in-game characters and starship systems.
You can use Microsoft's Azure AI Language to build natural language processing solutions.
Some features of Azure AI Language include understanding and analyzing text, training
conversational language models that can understand spoken or text-based commands, and
building intelligent applications.
Microsoft's Azure AI Speech is another service that can be used to build natural language
processing solutions. Azure AI Speech features include speech recognition and synthesis, real-
time translations, conversation transcriptions, and more.
You can explore Azure AI Language features in the Azure Language Studio and Azure AI
Speech features in the Azure Speech Studio. The service features are available for use and
testing in the studios and other programming languages.
Understand document
intelligence and knowledge
mining
Document Intelligence is the area of AI that deals with managing,
processing, and using high volumes of a variety of data found in forms and
documents. Document intelligence enables you to create software that can
automate processing for contracts, health documents, financial forms and
more.
Knowledge Mining
Knowledge mining is the term used to describe solutions that involve
extracting information from large volumes of often unstructured data
to create a searchable knowledge store.
Tip
Understand generative AI
Generative AI describes a category of capabilities within AI that create
original content. People typically interact with generative AI that has been
built into chat applications. Generative AI applications take in natural
language input, and return appropriate responses in a variety of formats
including natural language, image, code, and audio.
Azure OpenAI Service supports many generative model choices that can
serve different needs. You can use Azure AI Studio to create generative AI
solutions, such as custom copilot chat-based assistants that use Azure
OpenAI Service models
In this example, an Azure OpenAI Service model is used to power a copilot
application that can be used to generate original content in response to
user prompts, such as a request to write a cover letter.
Tip
The following table shows some of the potential challenges and risks facing
an AI application developer.
Understand Responsible AI
At Microsoft, AI software development is guided by a set of six principles, designed to ensure
that AI applications provide amazing solutions to difficult problems without any unintended
negative consequences.
Fairness
AI systems should treat all people fairly. For example, suppose you create a machine learning
model to support a loan approval application for a bank. The model should predict whether the
loan should be approved or denied without bias. This bias could be based on gender, ethnicity, or
other factors that result in an unfair advantage or disadvantage to specific groups of applicants.
Azure Machine Learning includes the capability to interpret models and quantify the extent to
which each feature of the data influences the model's prediction. This capability helps data
scientists and developers identify and mitigate bias in the model.
Another example is Microsoft's implementation of Responsible AI with the Face service, which
retires facial recognition capabilities that can be used to try to infer emotional states and identity
attributes. These capabilities, if misused, can subject people to stereotyping, discrimination or
unfair denial of services.
Reliability and safety
AI systems should perform reliably and safely. For example, consider an AI-based software
system for an autonomous vehicle; or a machine learning model that diagnoses patient symptoms
and recommends prescriptions. Unreliability in these kinds of systems can result in substantial
risk to human life.
AI systems should be secure and respect privacy. The machine learning models on which AI
systems are based rely on large volumes of data, which may contain personal details that must be
kept private. Even after the models are trained and the system is in production, privacy and
security need to be considered. As the system uses new data to make predictions or take action,
both the data and decisions made from the data may be subject to privacy or security concerns.
Inclusiveness
AI systems should empower everyone and engage people. AI should bring benefits to all parts of
society, regardless of physical ability, gender, sexual orientation, ethnicity, or other factors.
Transparency
AI systems should be understandable. Users should be made fully aware of the purpose of the
system, how it works, and what limitations may be expected.
Accountability
People should be accountable for AI systems. Designers and developers of AI-based solutions
should work within a framework of governance and organizational principles that ensure the
solution meets ethical and legal standards that are clearly defined.
The principles of responsible AI can help you understand some of the challenges facing
developers as they try to create ethical AI solutions.
Further resources
For more resources to help you put the responsible AI principles into practice,
see https://www.microsoft.com/ai/responsible-ai-resources.
To see these policies in action you can read about Microsoft’s framework for building AI
systems responsibly.
Summary
Artificial Intelligence enables the creation of powerful solutions to many
kinds of problems. AI systems can exhibit human characteristics to analyze
the world around them, make predictions or inferences, and act on them in
ways that we could only imagine a short time ago.
Machine learning is the basis for most modern artificial intelligence solutions.
A familiarity with the core concepts on which machine learning is based is an
important foundation for understanding AI.
Learning objectives
After completing this module, you will be able to:
Describe core concepts of machine learning
Identify different types of machine learning
Describe considerations for training and evaluating machine learning
models
Describe core concepts of deep learning
Use automated machine learning in Azure Machine Learning service
Introduction
Machine learning is in many ways the intersection of two disciplines - data
science and software engineering. The goal of machine learning is to use
data to create a predictive model that can be incorporated into a software
application or service. To achieve this goal requires collaboration between
data scientists who explore and prepare the data before using it to train a
machine learning model, and software developers who integrate the models
into applications where they're used to predict new data values (a process
known as inferencing).
In this module, you'll explore some of the core concepts on which machine
learning is based, learn how to identify different kinds of machine learning
models, and examine the ways in which machine learning models are trained
and evaluated. Finally, you'll learn how to use Microsoft Azure Machine
Learning to train and deploy a machine learning model, without needing to
write any code.
Note
Machine learning is based on mathematical and statistical techniques, some
of which are described at a high level in this module. Don't worry if you're
not a mathematical expert though! The goal of the module is to help you
gain an intuition of how machine learning works - we'll keep the mathematics
to the minimum required to understand the core concepts.
The proprietor of an ice cream store might use an app that combines
historical sales and weather records to predict how many ice creams
they're likely to sell on a given day, based on the weather forecast.
A doctor might use clinical data from past patients to run automated
tests that predict whether a new patient is at risk from diabetes based
on factors like weight, blood glucose level, and other measurements.
A researcher in the Antarctic might use past observations automate the
identification of different penguin species (such as Adelie, Gentoo,
or Chinstrap) based on measurements of a bird's flippers, bill, and other
physical attributes.
y = f(x)
4. Now that the training phase is complete, the trained model can be
used for inferencing. The model is essentially a software program
that encapsulates the function produced by the training process.
You can input a set of feature values, and receive as an output a
prediction of the corresponding label. Because the output from the
model is a prediction that was calculated by the function, and not
an observed value, you'll often see the output from the function
shown as ŷ (which is rather delightfully verbalized as "y-hat").
Supervised machine learning is a general term for machine learning algorithms in which the
training data includes both feature values and known label values. Supervised machine learning
is used to train models by determining a relationship between the features and labels in past
observations, so that unknown labels can be predicted for features in future cases.
Regression
Regression is a form of supervised machine learning in which the label predicted by the model is
a numeric value. For example:
The number of ice creams sold on a given day, based on the temperature, rainfall, and
windspeed.
The selling price of a property based on its size in square feet, the number of bedrooms it
contains, and socio-economic metrics for its location.
The fuel efficiency (in miles-per-gallon) of a car based on its engine size, weight, width,
height, and length.
Classification
In binary classification, the label determines whether the observed item is (or isn't) an instance
of a specific class. Or put another way, binary classification models predict one of two mutually
exclusive outcomes. For example:
Whether a patient is at risk for diabetes based on clinical metrics like weight, age, blood
glucose level, and so on.
Whether a bank customer will default on a loan based on income, credit history, age, and
other factors.
Whether a mailing list customer will respond positively to a marketing offer based on
demographic attributes and past purchases.
In all of these examples, the model predicts a binary true/false or positive/negative prediction for
a single possible class.
Multiclass classification
Multiclass classification extends binary classification to predict a label that represents one of
multiple possible classes. For example,
In most scenarios that involve a known set of multiple classes, multiclass classification is used to
predict mutually exclusive labels. For example, a penguin can't be both a Gentoo and an Adelie.
However, there are also some algorithms that you can use to train multilabel classification
models, in which there may be more than one valid label for a single observation. For example, a
movie could potentially be categorized as both science fiction and comedy.
Unsupervised machine learning involves training models using data that consists only
of feature values without any known labels. Unsupervised machine learning algorithms
determine relationships between the features of the observations in the training data.
Clustering
The most common form of unsupervised machine learning is clustering. A clustering algorithm
identifies similarities between observations based on their features, and groups them into discrete
clusters. For example:
Group similar flowers based on their size, number of leaves, and number of petals.
Identify groups of similar customers based on demographic attributes and purchasing
behavior.
In some cases, clustering is used to determine the set of classes that exist before training a
classification model. For example, you might use clustering to segment your customers into
groups, and then analyze those groups to identify and categorize different classes of customer
(high value - low volume, frequent small purchaser, and so on). You could then use your
categorizations to label the observations in your clustering results and use the labeled data to
train a classification model that predicts to which customer category a new customer might
belong.
Regression
Regression models are trained to predict numeric label values based on
training data that includes both features and known labels. The process for
training a regression model (or indeed, any supervised machine learning
model) involves multiple iterations in which you use an appropriate algorithm
(usually with some parameterized settings) to train a model, evaluate the
model's predictive performance, and refine the model by repeating the
training process with different algorithms and parameters until you achieve
an acceptable level of predictive accuracy.
The diagram shows four key elements of the training process for supervised
machine learning models:
1. Split the training data (randomly) to create a dataset with which to train
the model while holding back a subset of the data that you'll use to
validate the trained model.
2. Use an algorithm to fit the training data to a model. In the case of a
regression model, use a regression algorithm such as linear regression.
3. Use the validation data you held back to test the model by predicting
labels for the features.
4. Compare the known actual labels in the validation dataset to the labels
that the model predicted. Then aggregate the differences between
the predicted and actual label values to calculate a metric that indicates
how accurately the model predicted for the validation data.
After each train, validate, and evaluate iteration, you can repeat the process
with different algorithms and parameters until an acceptable evaluation
metric is achieved.
Example - regression
For our example, let's stick with the ice cream sales scenario we discussed
previously. For our feature, we'll consider the temperature (let's assume the
value is the maximum temperature on a given day), and the label we want to
train a model to predict is the number of ice creams sold that day. We'll start
with some historic data that includes records of daily temperatures (x) and
ice cream sales (y):
Expand table
51 1
52 0
67 14
65 14
70 23
69 20
72 23
75 26
73 22
81 30
78 26
83 36
We'll start by splitting the data and using a subset of it to train a model.
Here's the training dataset:
Expand table
51 1
65 14
69 20
Temperature (x) Ice cream sales (y)
72 23
75 26
81 30
To get an insight of how these x and y values might relate to one another,
we can plot them as coordinates along two axes, like this:
Now we're ready to apply an algorithm to our training data and fit it to a
function that applies an operation to x to calculate y. One such algorithm
is linear regression, which works by deriving a function that produces a
straight line through the intersections of the x and y values while minimizing
the average distance between the line and the plotted points, like this:
The line is a visual representation of the function in which the slope of the
line describes how to calculate the value of y for a given value of x. The line
intercepts the x axis at 50, so when x is 50, y is 0. As you can see from the
axis markers in the plot, the line slopes so that every increase of 5 along
the x axis results in an increase of 5 up the y axis; so when x is 55, y is 5;
when x is 60, y is 10, and so on. To calculate a value of y for a given value
of x, the function simply subtracts 50; in other words, the function can be
expressed like this:
f(x) = x-50
You can use this function to predict the number of ice creams sold on a day
with any given temperature. For example, suppose the weather forecast tells
us that tomorrow it will be 77 degrees. We can apply our model to
calculate 77-50 and predict that we'll sell 27 ice creams tomorrow.
To validate the model and evaluate how well it predicts, we held back some
data for which we know the label (y) value. Here's the data we held back:
Temperature (x) Ice cream sales (y)
52 0
67 14
70 23
73 22
78 26
83 36
We can use the model to predict the label for each of the observations in this
dataset based on the feature (x) value; and then compare the predicted
label (ŷ) to the known actual label value (y).
Using the model we trained earlier, which encapsulates the function f(x) =
x-50, results in the following predictions:
52 0 2
67 14 17
70 23 20
73 22 23
78 26 28
83 36 33
We can plot both the predicted and actual labels against the feature values
like this:
The predicted labels are calculated by the model so they're on the function
line, but there's some variance between the ŷ values calculated by the
function and the actual y values from the validation dataset; which is
indicated on the plot as a line between the ŷ and y values that shows how
far off the prediction was from the actual value.
Based on the differences between the predicted and actual values, you can
calculate some common metrics that are used to evaluate a regression
model.
The variance in this example indicates by how many ice creams each
prediction was wrong. It doesn't matter if the prediction
was over or under the actual value (so for example, -3 and +3 both indicate
a variance of 3). This metric is known as the absolute error for each
prediction, and can be summarized for the whole validation set as the mean
absolute error (MAE).
In the ice cream example, the mean (average) of the absolute errors (2, 3, 3,
1, 2, and 3) is 2.33.
The mean absolute error metric takes all discrepancies between predicted
and actual labels into account equally. However, it may be more desirable to
have a model that is consistently wrong by a small amount than one that
makes fewer, but larger errors. One way to produce a metric that "amplifies"
larger errors by squaring the individual errors and calculating the mean of
the squared values. This metric is known as the mean squared
error (MSE).
In our ice cream example, the mean of the squared absolute values (which
are 4, 9, 9, 1, 4, and 9) is 6.
The mean squared error helps take the magnitude of errors into account, but
because it squares the error values, the resulting metric no longer
represents the quantity measured by the label. In other words, we can say
that the MSE of our model is 6, but that doesn't measure its accuracy in
terms of the number of ice creams that were mispredicted; 6 is just a
numeric score that indicates the level of error in the validation predictions.
All of the metrics so far compare the discrepancy between the predicted and
actual values in order to evaluate the model. However, in reality, there's
some natural random variance in the daily sales of ice cream that the model
takes into account. In a linear regression model, the training algorithm fits a
straight line that minimizes the mean variance between the function and the
known label values. The coefficient of determination (more commonly
referred to as R2 or R-Squared) is a metric that measures the proportion of
variance in the validation results that can be explained by the model, as
opposed to some anomalous aspect of the validation data (for example, a
day with a highly unusual number of ice creams sales because of a local
festival).
The calculation for R2 is more complex than for the previous metrics. It
compares the sum of squared differences between predicted and actual
labels with the sum of squared differences between the actual label values
and the mean of actual label values, like this:
R2 = 1- ∑(y-ŷ)2 ÷ ∑(y-ȳ)2
Don't worry too much if that looks complicated; most machine learning tools
can calculate the metric for you. The important point is that the result is a
value between 0 and 1 that describes the proportion of variance explained
by the model. In simple terms, the closer to 1 this value is, the better the
model is fitting the validation data. In the case of the ice cream regression
model, the R2 calculated from the validation data is 0.95.
Iterative training
After multiple iterations, the model that results in the best evaluation metric
that's acceptable for the specific scenario is selected.
Binary classification
Completed100 XP
12 minutes
Expand table
67 0
103 1
114 1
72 0
116 1
65 0
To train the model, we'll use an algorithm to fit the training data to a function
that calculates the probability of the class label being true (in other words,
that the patient has diabetes). Probability is measured as a value between
0.0 and 1.0, such that the total probability for all possible classes is 1.0. So
for example, if the probability of a patient having diabetes is 0.7, then
there's a corresponding probability of 0.3 that the patient isn't diabetic.
There are many algorithms that can be used for binary classification, such
as logistic regression, which derives a sigmoid (S-shaped) function with
values between 0.0 and 1.0, like this:
Note
f(x) = P(y=1 | x)
For three of the six observations in the training data, we know that y is
definitely true, so the probability for those observations that y=1 is 1.0 and
for the other three, we know that y is definitely false, so the probability
that y=1 is 0.0. The S-shaped curve describes the probability distribution so
that plotting a value of x on the line identifies the corresponding probability
that y is 1.
The diagram also includes a horizontal line to indicate the threshold at which
a model based on this function will predict true (1) or false (0). The threshold
lies at the mid-point for y (P(y) = 0.5). For any values at this point or above,
the model will predict true (1); while for any values below this point it will
predict false (0). For example, for a patient with a blood glucose level of 90,
the function would result in a probability value of 0.9. Since 0.9 is higher
than the threshold of 0.5, the model would predict true (1) - in other words,
the patient is predicted to have diabetes.
As with regression, when training a binary classification model you hold back
a random subset of data with which to validate the trained model. Let's
assume we held back the following data to validate our diabetes classifier:
Expand table
66 0
107 1
112 1
71 0
87 1
89 1
Expand table
Blood glucose (x) Actual diabetes diagnosis (y) Predicted diabetes diagnosis (ŷ)
66 0 0
107 1 1
112 1 1
71 0 0
87 1 0
89 1 1
Accuracy
The simplest metric you can calculate from the confusion matrix
is accuracy - the proportion of predictions that the model got right. Accuracy
is calculated as:
(TN+TP) ÷ (TN+FN+FP+TP)
(2+3) ÷ (2+1+0+3)
=5÷6
= 0.83
So for our validation data, the diabetes classification model produced correct
predictions 83% of the time.
Accuracy might initially seem like a good metric to evaluate a model, but
consider this. Suppose 11% of the population has diabetes. You could create
a model that always predicts 0, and it would achieve an accuracy of 89%,
even though it makes no real attempt to differentiate between patients by
evaluating their features. What we really need is a deeper understanding of
how the model performs at predicting 1 for positive cases and 0 for negative
cases.
Recall
Recall is a metric that measures the proportion of positive cases that the
model identified correctly. In other words, compared to the number of
patients who have diabetes, how many did the model predict to have
diabetes?
TP ÷ (TP+FN)
3 ÷ (3+1)
=3÷4
= 0.75
Precision
TP ÷ (TP+FP)
3 ÷ (3+0)
=3÷3
= 1.0
F1-score
F1-score is an overall metric that combined recall and precision. The formula
for F1-score is:
= 1.5 ÷ 1.75
= 0.86
Another name for recall is the true positive rate (TPR), and there's an
equivalent metric called the false positive rate (FPR) that is calculated
as FP÷(FP+TN). We already know that the TPR for our model when using a
threshold of 0.5 is 0.75, and we can use the formula for FPR to calculate a
value of 0÷2 = 0.
In the case of our diabetes model, the curve above is produced, and
the area under the curve (AUC) metric is 0.875. Since the AUC is higher
than 0.5, we can conclude the model performs better at predicting whether
or not a patient has diabetes than randomly guessing.
Multiclass classification
Completed100 XP
12 minutes
0: Adelie
1: Gentoo
2: Chinstrap
Note
Expand table
167 0
172 0
225 2
197 1
189 1
232 2
158 0
f0(x) = P(y=0 | x)
f1(x) = P(y=1 | x)
f2(x) = P(y=2 | x)
Multinomial algorithms
The elements in the vector represent the probabilities for classes 0, 1, and 2
respectively; so in this case, the class with the highest probability is 2.
Regardless of which type of algorithm is used, the model uses the resulting
function to determine the most probable class for a given set of features (x)
and predicts the corresponding class label (y).
Evaluating a multiclass classification model
Let's assume that we've validated our multiclass classifier, and obtained the
following results:
Expand table
165 0 0
171 0 0
205 2 1
195 1 1
183 1 1
221 2 2
214 2 2
From this confusion matrix, we can determine the metrics for each individual
class as follows:
Expand table
Class TP TN FP FN Accuracy Recall Precision F1-Score
To calculate the overall accuracy, recall, and precision metrics, you use the
total of the TP, TN, FP, and FN metrics:
The overall F1-score is calculated using the overall recall and precision
metrics:
Clustering
Completed100 XP
10 minutes
Example - clustering
Expand table
0 5
0 6
1 3
1 3
1 6
1 8
2 3
2 7
2 8
There are multiple algorithms you can use for clustering. One of the most
commonly used algorithms is K-Means clustering, which consists of the
following steps:
Since there's no known label with which to compare the predicted cluster
assignments, evaluation of a clustering model is based on how well the
resulting clusters are separated from one another.
There are multiple metrics that you can use to evaluate cluster separation,
including:
12 minutes
Expand table
Neurons fire in response to electrochemical stimuli. When fired, Each neuron is a function that operates on an input value
the signal is passed to connected neurons. The function is wrapped in an activation function that de
pass the output on.
Just like other machine learning techniques discussed in this module, deep
learning involves fitting training data to a function that can predict a label (y)
based on the value of one or more features (x). The function (f(x)) is the
outer layer of a nested function in which each layer of the neural network
encapsulates functions that operate on x and the weight (w) values
associated with them. The algorithm used to train the model involves
iteratively feeding the feature values (x) in the training data forward through
the layers to calculate output values for ŷ, validating the model to evaluate
how far off the calculated ŷ values are from the known y values (which
quantifies the level of error, or loss, in the model), and then modifying the
weights (w) to reduce the loss. The trained model includes the final weight
values that result in the most accurate predictions.
To better understand how a deep neural network model works, let's explore
an example in which a neural network is used to define a classification model
for penguin species.
The label we're trying to predict (y) is the species of the penguin, and that
there are three possible species it could be:
Adelie
Gentoo
Chinstrap
This is an example of a classification problem, in which the machine learning
model must predict the most probable class to which an observation
belongs. A classification model accomplishes this by predicting a label that
consists of the probability for each class. In other words, y is a vector of
three probability values; one for each of the possible classes: [P(y=0|x),
P(y=1|x), P(y=2|x)].
The process for inferencing a predicted penguin class using this network is:
1. The feature vector for a penguin observation is fed into the input layer
of the neural network, which consists of a neuron for each x value. In
this example, the following x vector is used as the input: [37.3, 16.8,
19.2, 30.0]
2. The functions for the first layer of neurons each calculate a weighted
sum by combining the x value and w weight, and pass it to an activation
function that determines if it meets the threshold to be passed on to the
next layer.
3. Each neuron in a layer is connected to all of the neurons in the next
layer (an architecture sometimes called a fully connected network) so
the results of each layer are fed forward through the network until they
reach the output layer.
4. The output layer produces a vector of values; in this case, using
a softmax or similar function to calculate the probability distribution for
the three possible classes of penguin. In this example, the output vector
is: [0.2, 0.7, 0.1]
5. The elements of the vector represent the probabilities for classes 0, 1,
and 2. The second value is the highest, so the model predicts that the
species of the penguin is 1 (Gentoo).
While it's easier to think of each case in the training data being passed
through the network one at a time, in reality the data is batched into
matrices and processed using linear algebraic calculations. For this reason,
neural network training is best performed on computers with graphical
processing units (GPUs) that are optimized for vector and matrix
manipulation.
Azure Machine Learning
Completed100 XP
6 minutes
After you've provisioned an Azure Machine Learning workspace, you can use
it in Azure Machine Learning studio; a browser-based portal for managing
your machine learning resources and jobs.
The screenshot shows the Metrics page for a trained model in Azure
Machine Learning studio, in which you can see the evaluation metrics for a
trained multiclass classification model.
If you don't already have one, you can sign up for an Azure subscription,
which includes free credits for the first 30 days.
4. Select Launch studio (or open a new browser tab and navigate
to https://ml.azure.com, and sign into Azure Machine Learning studio
using your Microsoft account). Close any messages that are displayed.
5. In Azure Machine Learning studio, you should see your newly created
workspace. If not, select All workspaces in the left-hand menu and then
select the workspace you just created.
Basic settings:
o Data type:
Name: bike-rentals
Description: Historic bike rental data
Type: Table (mltable)
o Data source:
Select From local files
o Destination storage type:
Datastore type: Azure Blob Storage
Name: workspaceblobstore
o MLtable selection:
Upload folder: Download and unzip the folder that
contains the two files you need to
upload https://aka.ms/bike-rentals
Task settings:
o Max trials: 3
o Max nodes: 3
o eXPERIMENT Timeout: 15
o Iteration timeout: 15
o Enable early termination: Selected
Compute:
4. Wait for the job to finish. It might take a while — now might be a good
time for a coffee break!
When the automated machine learning job has completed, you can review
the best model it trained.
1. On the Overview tab of the automated machine learning job, note the
best model
summary.
Note You may see a message under the status “Warning: User specified exit score
reached…”. This is an expected message. Please continue to the next step.
2. Select the text under Algorithm name for the best model to view its
details.
1. On the Model tab for the best model trained by your automated machine
learning job, select Deploy and use the Real-time endpoint option to
deploy the model with the following settings:
o Virtual machine: Standard_DS3_v2
o Instance count: 3
o Endpoint: New
o Endpoint name: Leave the default or make sure it’s globally unique
o Deployment name: Leave default
o Inferencing data collection: Disabled
o Package Model: Disabled
2. Wait for the deployment to start - this may take a few seconds. The Deploy
status for the predict-rentals endpoint will be indicated in the main part of
the page as Running.
3. Wait for the Deploy status to change to Succeeded. This may take 5-10
minutes.
3. In the Input data to test endpoint pane, replace the template JSON
with the following input data:
codeCopy
{
"input_data": {
"columns": [
"day",
"mnth",
"year",
"season",
"holiday",
"weekday",
"workingday",
"weathersit",
"temp",
"atemp",
"hum",
"windspeed"
],
"index": [0],
"data": [[1,1,2022,2,0,1,1,2,0.3,0.3,0.3,0.3]]
}
}
[
352.3564674945718
]
The test pane took the input data and used the model you trained to
return the predicted number of rentals.
Let’s review what you have done. You used a dataset of historical bicycle
rental data to train a model. The model predicts the number of bicycle
rentals expected on a given day, based on seasonal and
meteorological features.
Clean-up
The web service you created is hosted in an Azure Container Instance. If you
don’t intend to experiment with it further, you should delete the endpoint to
avoid accruing unnecessary Azure usage.
1. In the Azure portal, in the Resource groups page, open the resource group
you specified when creating your Azure Machine Learning workspace.
2. Click Delete resource group, type the resource group name to confirm you
want to delete it, and select Delete.
Summary
Machine learning is the foundation on which artificial intelligence is built. In
this module, you've learned about some of the core principles and concepts
on which machine learning is based, and about the different kinds of model
you can train and evaluate.
The module also introduced Azure Machine Learning; a cloud platform for
end-to-end machine learning operations, and gave you the opportunity to
use automated machine learning in Azure Machine Learning for yourself.
Tip
To learn more about Azure Machine Learning and its capabilities, see
the Azure Machine Learning page.
In this module, you learn the fundamentals of how Azure AI services can be
used to build applications.
Learning objectives
Understand applications Azure AI services can be used to build
Understand how to access Azure AI services in the Azure portal
Understand how to use Azure AI services keys and endpoint for
authentication
Create and use an Azure AI services resource in a Content Safety Studio
setting
Introduction
Completed100 XP
2 minutes
Artificial Intelligence (AI) is changing our world and there’s hardly an industry
that hasn't been affected. From better healthcare to online safety, AI is
helping us to tackle some of society’s biggest issues.
In this module you will learn what Azure AI services are, and how you can
use them in your own applications.
4 minutes
Azure AI services are AI capabilities that can be built into web or mobile
applications, in a way that's straightforward to implement. These AI services
include image recognition, natural language processing, speech, AI-powered
search, and more. There are over a dozen different services that can be used
separately or together to add AI power to applications.
Let's take a look at some examples of what can be done with Azure AI
services. The Azure AI Content Safety service can be used to detect harmful
content within text or images, including violent or hateful content, and report
on its severity. The Azure AI Language service can be used to summarize
text, classify information, or extract key phrases. The Azure AI Speech
service provides powerful speech to text and text to speech capabilities,
allowing speech to be accurately transcribed into text, or text to natural
sounding voice audio.
AI has been prohibitive for all but the largest technology companies because
of several factors, including the large amounts of data required to train
models, the massive amount of computing power needed, and the budget to
hire specialist programmers. Azure AI services make AI accessible to
businesses of all sizes by using pre-trained machine learning models to
deliver AI as a service. Azure AI services use high-performance Azure
computing to deploy advanced AI models as resources, making decades of
research available to developers of all skill levels.
Azure AI services are a portfolio of services, with capabilities suitable for use
cases across sectors and industries.
For example, in sport, athletes, and coaches are customizing Azure AI Vision
to improve performance and reduce injury. One application allows surfers to
upload a video and receive AI-generated insights and analysis. These
insights can then be used by coaches, medics, judges, and event
broadcasters.
Note
3 minutes
Azure AI services are cloud-based, and like all Azure services you need to
create a resource to use them. There are two types of AI service resources:
multi-service or single-service. Your development requirements and how you
want costs to be billed determine the types of resources you need.
You can create a resource several ways, such as in the Azure portal.
3 minutes
Once you create an Azure AI service resource, you can build applications using the REST API,
software development kits (SDKs), or visual studio interfaces.
Using service studio interfaces
Studio interfaces provide a friendly user interface to explore Azure AI services. There are
different studios for different Azure AI services, such as Vision Studio, Language Studio, Speech
Studio, and the Content Safety Studio. You can test out Azure AI services using the samples
provided, or experiment with your own content. A studio-based approach allows you to explore,
demo, and evaluate Azure AI services regardless of your experience with AI or coding.
Before you can use an AI service resource, you must associate it with the studio you want to use
on the Settings page. Select the resource, and then select Use Resource. You are then ready to
explore the Azure AI service within the studio.
As an example, let's look at the Azure AI Content Safety service, which identifies harmful text or
images. To explore what the Content Safety service does, let's use the Content Safety Studio.
First create either a multi-service Azure AI services resource, or a single-service Content Safety
resource. Then, on the Content Safety Studio Settings page, select the resource, and select Use
Resource. The AI service you created is now associated with the Content Safety Studio, and
ready to be used.
Note
When developers incorporate an AI service into their applications, they often use a SDK or
the REST API.
The endpoint describes how to reach the AI service resource instance that
you want to use, in a similar way to the way a URL identifies a web site.
When you view the endpoint for your resource, it will look something like:
Copy
https://myaiservices29.cognitiveservices.azure.com/
The resource key protects the privacy of your resource. To ensure this is
always secure, the key can be changed periodically. You can view the
endpoint and key in the Azure portal under Resource Management and Keys
and Endpoint.
When you write code to access the AI service, the keys and endpoint must
be included in the authentication header. The authentication header sends
an authorization key to the service to confirm that the application can use
the resource. Learn more about different authentication requests to Azure AI
services here.
When you use a studio interface with Azure AI services, your credentials are
authenticated when you sign in, and a similar process is happening in the
background.
Exercise - Explore Azure AI
Services
In this exercise, use the Content Safety Studio to explore one of many Azure
AI services.
Note
If you don't already have one, you can sign up for an Azure subscription,
which includes free credits for the first 30 days.
The Content Safety Studio enables you to explore how text and image
content can be moderated. You can run tests on sample text or images and
get a severity score ranging from safe to high for each category. In this lab
exercise you will create a single-service resource in the Content Safety
Studio and test its functionalities.
Note The goal of this exercise is to get a general sense of how Azure AI services are
provisioned and used. Content Safety is used as an example, but you are not expected to
gain a comprehensive knowledge of content safety in this exercise!
Navigate the Content Safety Studio
1. Open the Content Safety Studio. If you are not logged in, you will need
to sign in. Select Sign In on the top right of the screen. Use the email
and password associated with your Azure subscription to sign in.
2. The Content Safety Studio is set up like many other studios for Azure AI
services. On the menu at the top of the screen, click on the icon on the
left of Azure AI. You will see a drop-down list of other studios designed
for development with Azure AI services. You can click on the icon again
to hide the list.
Associate a resource with the studio
Before using the studio, you need to associate an Azure AI services resource
with the studio. Depending on the studio, you may find you need a specific
single-service resource, or can use a general multi-service resource. In the
case of the Content Safety Studio, you can use the service by creating a
single-service Content Safety resource or Azure AI services general multi-
service resource. In the steps below, we will create a single-service Content
Safety resource.
1. On the Settings page, you will see a Directory tab and Resource tab. On
the Resource tab, select Create a new resource. This takes you to page to
create a resource in the Azure Portal.
Note The Directory tab allows users to select different directories from which to create
resources. You do not need to change its settings unless you wish to use a different
directory.
1. On the Create Content Safety page in the Azure Portal, you need to configure
several details to create your resource. Configure it with the following
settings:
o Subscription: Your Azure subscription.
o Resource group: Select or create a resource group with a unique
name.
o Region: Choose any available region. If in eastern US, use “East US 2”.
o Name: Enter a unique name.
o Pricing tier: Free F0
2. Select Review + Create and review the configuration. Then select Create.
The screen will indicate when the deployment is complete.
2. Select the Settings icon on the top right of the screen again. This time
you should see that your newly created resource has been added to
the list.
Note: If you are using a Cloud Slice subscription, you can skip steps #7-12 and go to step
#13. Otherwise, continue with step #7.
1. Search for Cognitive Services User in the list of roles, and select it.
Then select Next.
2. Use the following settings to assign yourself to the role:
o Assign access to: select user, group, or service principal
o Members: click on select members
o On the open Select members pane, find your name. Click on the
plus icon next to your name. Then click Select.
3. Select Review and Assign, then select Review and Assign again to
add the role assignment.
4. Return to the Content Safety Studio
at https://contentsafety.cognitive.azure.com. Then select the Settings icon
on the top right of the screen.
1. Select the Azure AI service resource you just created. Make sure
under Current role assignments you see both Cognitive services user,
and Owner.
1. Click Use resource on the bottom of the screen. You will be taken back to
the studio home page. Now you can begin using the studio with your newly
created resource.
1. On the Content Safety Studio home page, under Run moderation tests,
navigate to the Moderate text content box and click Try it out.
2. Under run a simple test, click Safe Content. Notice that text is displayed in
the box below.
3. Click Run test. Running a test calls the Content Safety Service’s deep
learning model. The deep learning model has already been trained to
recognize un-safe content.
4. In the Results panel, inspect the results. There are four severity levels from
safe to high, and four types of harmful content. Does the Content Safety AI
service consider this sample to be acceptable or not? What’s important to
note is that the results are within a confidence interval. A well-trained model,
like one of Azure AI’s out-of-the-box models, can return results that have a
high probability of matching what a human would label the result. Each time
you run a test, you call the model again.
5. Now try another sample. Select the text under Violent content with
misspelling. Check that the content is displayed in the box below.
6. Click Run test and inspect the results in the Results panel again.
You can run tests on all the samples provided, then inspect the results.
1. In the Content Safety Studio, navigate back to the Settings page, with
the Resources tab selected. Look for the resource you used. Scroll across to
see the endpoint and key for your resource.
2. In the Azure Portal, you will see that these are the same endpoint
and different keys for your resource. To check it out, head to the Azure Portal.
Search for Content Safety on the top search bar. Find your resource and click
on it. On the left-hand menu, look under Resource Management for Keys and
Endpoints. Select Keys and Endpoints to view the endpoint and keys for
your resource.
After you have finished, you can delete the Content Safety resource from the
Azure Portal. Deleting the resource is a way to reduce costs that accrue
when the resource exists in the subscription. To do this, navigate to
the Overview page of your Content Safety resource. Select Delete at the
top of the screen.
Summary
Completed100 XP
3 minutes
You can find out more about Azure AI services in the service documentation.