2. What is Machine Learning?
Agenda
When is Machine Learning (ML) the right tool?
How Azure Machine Learning Service tools will make your life
easier
Build a model with no code using Azure ML designer
Deploy, test and consume the model
5. What is AI, ML and DL?
Machine learning (ML) is a subset of artificial
intelligence that includes techniques (such as deep
learning) that enable machines to improve at tasks with
experience.
Deep learning (DL) is a subset of machine learning
based on artificial neural networks that permit a machine
to train itself.
aka.ms/DeepLearningVSMachineLearning
7. When is Machine Learning (ML) the right tool?
Start with a question to answer: What are the forecasted sales quantities per
item per store for the next 4 weeks?
8. Regression: how much / how many
When should you use machine learning?
Classification: which class does it belong to?
Clustering: are there different groups? Which does it belong
to?
Anomaly Detection: is this weird?
Recommendation: which option should I choose?
supervised
learning
unsupervised
learning
9. The Model Building Process
•Test Candidate Model
with unseen data
•Select good enough
model
•Deploy Chosen
Model
•Application posts to
API
•Apply learning
algorithm
•Select Candidate
model
•Find, Select and/or
Create Data
•Apply preprocessing
Prepare
Data
Train
Model
Test
Model
Deploy
Model
10. The Model Building Process
•Test Candidate Model
with unseen data
•Select good enough
model
•Deploy Chosen
Model
•Application posts to
API
•Apply learning
algorithm
•Select Candidate
model
•Find, Select and/or
Create Data
•Apply preprocessing
Prepare
Data
Train
Model
Test
Model
Deploy
Model
12. Find and validate if enough data is available
Find Features and Process Data
Gather external data to improve model performance
Add future dates to dataset to get prediction
13. Find and Validate Data
Starting Dataset
• Get store id, item id, time, and
quantities of items sold
• Validate there is data for at
least a year
• Fill in missing gaps in data
14. Add RDPI Index to data
Resulting Dataset
Add external data to improve
model performance
15. Date and Time features: year, month, week of month, etc.
Feature Engineering: Create Data Features
Season/Holiday features: New Year, U.S. Labor Day, U.S.
Black Friday, and Christmas
Fourier features to capture seasonality
Lag features: these are values at prior time steps (weeks)
16. Build Model with Azure Machine Learning
Designer
We are using C# but you can do these steps in any language!
19. The Model Building Process
•Test Candidate Model
with unseen data
•Select good enough
model
•Deploy Chosen
Model
•Application posts to
API
•Apply learning
algorithm
•Select Candidate
model
•Find, Select and/or
Create Data
•Apply preprocessing
Prepare
Data
Train
Model
Test
Model
Deploy
Model
22. Azure Machine Learning Service
A service that has all the tools needed to build, test and deploy amazing
machine learning solutions – aka.ms/AzureMLservice
23. Authoring tools: Automated ML, Azure ML designer,
Notebooks and Files
Azure Machine Learning Service
Assets: Datasets, Experiments, ML Workflow Pipelines,
Models, Deployments
Management: Compute, Datastores, Workspaces
24. The Model Building Process
•Test Candidate Model
with unseen data
•Select good enough
model
•Deploy Chosen
Model
•Application posts to
API
•Apply learning
algorithm
•Select Candidate
model
•Find, Select and/or
Create Data
•Apply preprocessing
Prepare
Data
Train
Model
Test
Model
Deploy
Model
26. The Model Building Process
•Test Candidate Model
with unseen data
•Select good enough
model
•Deploy Chosen
Model
•Application posts to
API
•Apply learning
algorithm
•Select Candidate
model
•Find, Select and/or
Create Data
•Apply preprocessing
Prepare
Data
Train
Model
Test
Model
Deploy
Model
30. Please Evaluate the session:
Power BI & AI: The Kingdom
of The Possibility
Aroh Shukla
Microsoft Certified Trainer, Singapore
Coming up next…
A Singapore SQL PASS Event
Start Building
Machine Learning
Models Faster than You Think
Eng Soon Cheah
Microsoft MVP - AI, Singapore
Notas do Editor
Here is an overview of what we will be covering today.
Using the right tool for the right job is very important in tech, machine Learning isn’t always the answer. We will talk about what questions it is good at answering.
We will be learning what machine learning is and how azure can make it much easier to start building with your current dev staff.
Then we will build a time series regression model with Azure Machine Learning Interface. This is a tool that allows you to build a model with drag and drop modules. Lastly, we will deploy the model we created and test it out!
Let's introduce our business use case:
Tailwind Traders is a retail store and they realized they are loosing sales due to empty shelves at one store and full at another. They want to be able to predict how many items each store will need to make sure they can accurately meet demand at each store and not over or understock each store and item.
They think machine learning can solve their issue. But what is machine learning and is it the right tool?
Additionally they don’t have a data science department, but they do have a data savvy team. The teams main skills are SQL and C# and they are currently building on the MSFT stack. They are excited to learn about new tech and machine learning but need it to fit within their current platform and Software Development Life Cycle.
So let's first try to understand what Machine Learning is --> (click on next slide)
Let’s start by answering the first question - What is Machine Learning? (You can ask to the audience – how many of you can define Machine Learning?)
In order to understand the difference between deep learning vs. machine learning vs. AI, learn about each of these fields of study:
Deep learning is a subset of machine learning based on artificial neural networks that permit a machine to train itself. In this case, the learning process is called deep, because the structure of artificial neural networks consists of multiple input, output, and hidden layers. Each layer contains units that transform the input data into information that the next layer can use to perform a certain predictive task. Thanks to this structure, a machine is able to learn through its own data processing.
A few deep learning examples are: Computer vision, natural language processing. More complex problems that need multiple layers.
Machine learning is a subset of artificial intelligence that includes techniques (such as deep learning) that enable machines to improve at tasks with experience. In this case, the learning process is based on the following steps:
Feed an algorithm with data by providing it with more information (for example, by performing feature extraction).
Use this data to train a model.
Test and deploy the model.
Consume the deployed model to perform a certain automated predictive task.
Artificial intelligence (AI) is a technique that enables computers to mimic human intelligence. It includes machine learning. It is important to understand the relationship between AI vs. machine learning vs. deep learning: Machine learning is a way of achieving artificial intelligence, which means by the use of machine learning and deep learning techniques you can build computer systems and applications that can perform tasks commonly associated with human intelligence, such as visual perception, speech recognition, decision-making, and translation between languages.
To learn more and understand this slide in more detail, read our article at www.aka.ms/DeepLearningVSMachineLearning
Probably many of you are more familiar with traditional programming logic…so let’s try to understand machine learning levering traditional programming logic: this graphic shows the difference in how traditional programming is created versus a machine learning model. Traditional program is statically programmed logic to get an output. Static results are generated based on the programmed logic in the algorithm.
In Machine Learning (and specific to supervised machine learning) you have data which are your features and the output which are your labels. That goes thru the algorithm computation and a model is created which at a basic level is a function created with data. This is called training your model.
Tailwind traders probably could try to build different rules engines with static logic to solve their problem however this would most likely take longer, be less accurate and take more time to adapt to future trends. With machine learning they can build a model that learns from their pervious sales data to predict the future.
When you start to build a model you generally think about what is the question I am trying to answer. Tailwind Traders wants to predict how many items it will sell of different products from different stores over the next four weeks. This will help Tailwind keep the shelves stocked and reduce the probability that a store will run out of an item. This allows them to maximize sales at each store.
Our question is “What are the forecasted sales quantities per item per store for the next 4 weeks?” This is a called a Time Series Sales Forecasting model.
When making the decision of if machine learning is the right tool. Here are some common machine learning algorithms and the questions they answer.
There are two main types of machine learning. Supervised and Unsupervised learning. Supervised means we are giving examples of both the data used to predict and the answer. For example Dog vs Cat. We would be giving the model tagged images of each and telling it what a cat and what is a dog. Then it would learn from the tagged data provided. Unsupervised learning is when we give an untagged dataset to learn from without giving it the answer of what we want it to learn.
The two main supervised machine learning model questions:
Regression: How much or how many of something do I need. This is the type of model we will build in the demo today. We want to know how many items.
Classification: Which class does this belong to? Is it a cat or a dog would be an example of a binary classification.
The main types of unsupervised machine learning model questions are:
Clustering: grouping like things together to groups or patterns in data
Anomaly detection: is it weird? You may get emails from your credit card company pointing out weird transactions. Those are probably the result of an anomaly detection algorithm and the transaction didn’t fit in your normal patterns.
Recommendation: which option should I choose?
Now that we have a bit of an understanding of what machine learning is and some common questions it is used to solve. Lets look at the model building process at a high level.
Explain the model building process (keep it brief as you will go into more detail as you build the model in AML Studio)
Lets talk about the model building process. Here we will discuss the high-level model building process.
Prepare Data: We need to find, select and/or create data, apply preprocessing and fill gaps in data.
Train Model: Once you have your prepared data its time to test different machine learning models to see which gets the best results for your data. This is iterative because you may need to change the data and/or the model until you think you have a candidate for the production model.
Test Model: Now you have a model that you think is going to perform well and you can test it with unseen data. You will process the unseen data the same way the data was processed for training and then test how well it predicts the labels. This is an iterative process as you may need to go back to the beginning and change data features or processing. Its a fail fast process so don’t overthink each step. Get out what you think will work and iterate through until you get a model that performs good enough on your unseen data.
Operationalize Model: Once you have the “chosen one” aka your chosen model. Its time to operationalize it so you can consume it from different applications. In azure machine learning interface this is a super simple process which you will see in our demo.
Lets start with preparing our data!
Starting with step one Tailwind Traders needs to do what’s called “Feature Engineering” which “is the process of using domain knowledge of the data to select and create features that make machine learning algorithms work.” And a Feature is just an additional variable that is used to help predict our label.
To select and create features we need to ask ourselves and our team: What data would I use to make a decision? Then do I have that data and do I have enough of it? Eighty percent of machine learning is data, if you don’t have the data you cant build a model.
Lets discuss the data processing that Tailwind Traders needs to do to get their data ready for machine learning.
1. They need to find and validate they have enough data. For Tailwind we want at least 1 year of data to create our model. Our customer is already collectingand storing weekly sales quantities by store and item. Then we applied business rules to select the data and verify we had at least one years worth of data (we actually have 3 years worth). Once we had data we needed to handle incomplete and missing data values.
2. Add external data to improve the model. They would like to include the economic index to get an idea of the buying power at the time of the sales numbers. We want to capture the economic index in addition to the actual sales to answer the question of what the current personal buying power is in addition to past sales trends. This is a separate data point called Real Disposable Personal Income and we are going to add this to our existing time series data to capture the economic index in our training dataset.
3. Add future dates to the dataset to get a prediction. They need to add the future dates that they need to get predictions for.
Lets look at these feature selection and processing in a bit more details.
Now we have the resulting dataset of store id, item id, time stamp, value (sales quantity) and RDPI
What data do we have and what data could we add to improve accuracy? Tailwind traders decided adding the economic index
We did the select part but not the create. For this time series model we need to create more data points to improve our model performance.
The goal of feature engineering is to provide strong and ideally simple relationships between new input features and the output label for the supervised learning algorithm to model.
We are going to exclude the actual time number as this is considered an index and not a variable in time series. Instead we will extract the time information from the time stamp and will create additional features with that information.
This means extracting values like year, month week, season and holiday feature, Fourier features and lag features.
You are familiar with the first 3 concepts of time but you may not have heard of Fourier terms and Lag features.
What are Fourier features to capture seasonality? Basically a number result of mathematical operation to capture the up and down patterns of seasonal effect on sales. Seasonality is an adaptable time measurement that can be changed for each model. In our example our seasonality is each week in the 52 weeks in a year.(Since our data is by week)
Lag features are values at prior time steps. For this model our lag will be 26 weeks for each date row. Lag features give context of sales happening around the same date which is also referred to as "autocorrelation"
NOTE: You don’t have to add all these feature however they greatly improve the accuracy of this model. Every model is a special snowflake that will need different features and processing to make it shine bright.
Notes: There are three options for completing this demo
Live demo with the IgniteAimlDataApp with VSCode (Recommended)
Slide 20 is a backup video of what would be shown in the live demo. If for some reason you can not show the live demo. Talk along side this video without sound.
Start at slide 21 and show the data prep in static slides and explain each step and code snippet
Tip: To go into hidden slides during a live demo hit “h” on the keyboard.
Our dataset now looks like this with our created features added. Let's have a closer look at it.
Additionally if you look at the value column it has changed. We conducted a log transformation on the values column.
Why process a log transformation? “The log transformation can be used to make highly skewed distributions less skewed. This can be valuable both for making patterns in the data more interpretable and for helping to meet the assumptions of inferential statistics.”
This is a type of “Normalization” –” The goal of normalization is to change the values of numeric columns in the dataset to a common scale, without distorting differences in the ranges of values. ”
"Normalization" is another big fancy machine learning term. How do we convince them to pay us all the money if we don’t put big fancy words on simple concepts!
We have now prepared our data and its time to select an algorithm to train our model.
Let's see together how you can start training your model and, most importantly, select the right algorithm for your data science problem.
One of the hardest things when starting out with machine learning is what algorithm do I use?
The answer to the question "What machine learning algorithm should I use?" is always "It depends." It depends on the size, quality, and nature of the data. It depends on what you want to do with the answer. It depends on how the math of the algorithm was translated into instructions for the computer you are using. And it depends on how much time you have. Even the most experienced data scientists can't tell which algorithm will perform best before trying them.
This is the Machine Learning Cheat Sheet and it is your best friend! From start you can think about what you are trying to predict and it will help you make decisions on what type of model you want to build.
We are trying to predict values so we want a regression model. There are different types of regression algorithms to choose from as display in this cheat sheet.
Azure Machine Learning is a cloud service that you use to train, deploy, automate, and manage machine learning models, all at the broad scale that the cloud provides.
Give an overview of the different tools in AML service workspace
(I pulled these descriptions for docs)
-Automated ML - Automated machine learning, also referred to as autoML, is the process of automating the tasks of machine learning model development.
-Visual Designer-The visual interface for Azure Machine Learning service enables you to prep data, train, test, deploy, manage, and track machine learning models without writing code.
-Notebooks – jupyter notebooks running on cloud vms for building and testing models with code
-Datasets – shared datasets across multiple azure ML tools
-Experiments - Group of Runs from a Script
-Data Pipelines – ML processing workflows
-Models – history and versioning of the trained models
-Deployments – Endpoints of deployed models to consume from an application
-Compute – a way to manage what compute is created and when its used. Helps with managing costs.
-Datastores – azure storage for azure ml workspace
-Workpaces – The azure resource that contains these amazing features.
We are going to be building with Visual designer which uses many of these features behind the scenes when you are building a model. We will show this in the demo
In the demo we will focus on how you can test and deploy your model.
We will now learn together how to build, test and deploy your machine learning model on Azure.
To conclude: you can see that in this session we have completed the 4 steps of the model building process.
Congratulations! You are now able to prepare you data, train, test and deploy your own machine learning models!