Professional Documents
Culture Documents
Introduction to Machine
Learning
What is machine learning?
• Machine learning is the idea that there are generic algorithms that can tell you something
interesting about a set of data without you having to write any custom code specific to the
problem.
• Instead of writing code, you feed data to the generic algorithm and it builds its own logic
based on the data.
• Machine Learning (ML) encompasses a lot of things. The field is vast and is expanding
rapidly. It is a branch of Artificial Intelligence(AI). Loosely speaking, ML is the field of study
that gives computer algorithms the ability to learn without being explicitly programmed.
The outcome we want from our computer algorithm is PREDICTION. This is different from
our previous problems where we wanted the algorithm to solve a specific problem such as
finding the best web page for our search, sorting a list of items, or generating a secure
means to computing a shared secret in cryptography. What are we going to use to predict?
An example application
• An emergency room in a hospital measures 17 variables (e.g., blood
pressure, age, etc.) of newly admitted patients.
• A decision is needed: whether to put a new patient in an intensive-care
unit.
• Due to the high cost of ICU, those patients who may survive less than a
month are given higher priority.
• Problem: to predict high-risk patients and discriminate them from low-
risk patients.
11
Another application
• A credit card company receives thousands of applications for new cards.
Each application contains information about an applicant,
• age
• Marital status
• annual salary
• outstanding debts
• credit rating
• etc.
• Problem: to decide whether an application should be approved, or to
classify applications into two categories, approved and not approved.
14
Machine Learning Types
• Supervised Learning
• Uses labeled data
• Results compared with the correct answer.
• Requires large amounts of data to refine the model and produce more
accurate results.
• Common Techniques: Classification , Regression
• Use Cases: Fraud Detection, Image Recognition
Unsupervised Learning
• Working with unlabeled data.
• A learning algorithm is used to detect patterns
• Most common unsupervised learning technique is clustering which
takes unlabeled data and uses algorithms to put similar items into
groups.
• Use cases: Customer segmentation, sentiment analysis
Reinforcement Learning
• Through this trial-and-error process
• learning was improved based on positive and negative reinforcement.
• Use Cases : Games, Robotics
Algorithm Us e Cas e Example Outcome
Uns upervis ed
K Means Clus tering Segment customers into groups by characteristics
Learning
Gaus s ian Mixture Model Segment customers based on less distinctive characteristics Predic tive
Us e d when we do n’t
know the clas s ification Hierarchical clus tering Inform product usage by grouping customers What Will Happen?
o f data and want the
Rec ommender Sys tem Recommend news article to a readers based on what they are
algo rithm to clas s ify
data
currently reading
Reinforc eme nt
Learning Balance the load on electricity grids in varying demand cycles
Us ed when we do n’t Optimize the driving behavior of self-driving cars Pre s c riptive
have training data and Finding real time pricing during a product auction What To Do?
o nly way to learn
about the
environme nt is to
learn with it
Mac hine Le arning to day is e xte ns ive ly us e d and has we ll de fine d 11
Alg o rithms , To o ls and Te c hno lo g y while o the r AI te c hno lo g ie s are c o nfine d
to ve ndo r pro vide d s o lutio ns …
Natural Lang uag e Pro c e s s ing Co mpute r Vis io n Ro bo tic Pro c e s s Auto matio n
37
An example
• Data: Loan application data
• Task: Predict whether a loan should be approved or not.
• Performance measure: accuracy.
Re g re s s io n
Models Models
From Business Problem to Machine Learning
Problem: A Recipe
Step-by-step “recipe” for qualifying a business problem as a machine
learning problem
1. Do you need machine learning?
2. Can you formulate your problem clearly?
3. Do you have sufficient examples?
4. Does your problem have a regular pattern?
5. Can you find meaningful representations of your data?
6. How do you define success?
When to use machine learning
Problem formulation
2. Can you formulate your problem clearly?
• What do you want to predict given which input?
• Pattern: “given X, predict Y”
o What is the input?
o What is the output?
Example: sentiment analysis
• Given a customer review, predict its sentiment
• Input: customer review text
• Output: positive, negative, neutral
Collecting data
3. Do you have sufficient examples?
Machine learning always requires data!
Generally, the more data, the better
Each example must contain two parts (supervised learning)
o Features: attributes of the example
o Label: the answer you want to predict
Example: sentiment analysis
• Thousands of customer reviews and ratings from the Web
Regularities in the data
4. Does your problem have a regular pattern?
• Machine learning learns regularities and patterns
• Hard to learn patterns that are rare or irregular
2. Train a model
on training set
Training Set
1. Split data into
Model
training & testing subsets
Data with
3. Make predictions
Inputs & labels
on the testing set
Testing Set
Underfitting Overfitting
Easy to be good
Predictor is too "simplistic"
Error
on the training data
Test set
Cannot capture the pattern Predictor is too "powerful"
Rote learning
Training set
Low High
Model complexity
54
An example: the learning task
• Learn a classification model from the data
• Use the model to classify future loan applications into
• Yes (approved) and
• No (not approved)
• What is the class for following case/instance?
55
Machine Learning : Supervised
and Unsupervised learning
Supervised learning vs. unsupervised learning
• Supervised learning: discover patterns in the data that relate data
attributes with a target (class) attribute.
• These patterns are then utilized to predict the values of the target attribute
in future data instances.
60
Differences between Supervised vs.
unsupervised Learning
• Supervised learning: classification is seen as supervised learning from
examples.
• Supervision: The data (observations, measurements, etc.) are labeled with
pre-defined classes. It is like that a “teacher” gives the classes (supervision).
• Test data are classified into these classes too.
• Unsupervised learning (clustering)
• Class labels of the data are unknown
• Given a set of data, the task is to establish the existence of classes or clusters
in the data
Difference between Classification and Clustering
Classification Clustering
• Classification is used in supervised learning technique • Clustering is used in unsupervised learning where similar
where predefined labels are assigned to instances by instances are grouped, based on their features or properties.
properties • Clustering is a technique of organising a group of data into
• Classification is the process of learning a model that classes and clusters where the objects reside inside a cluster
elucidate different predetermined classes of data. It is a will have high similarity and the objects of two clusters
two-step process, comprised of a learning step and would be dissimilar to each other.
a classification step. In learning step, a classification model • The main target of clustering is to divide the whole data into
is constructed and classification step the constructed multiple clusters. Unlike classification process, here the class
model is used to prefigure the class labels for given data. labels of objects are not known before, and clustering
• Classification Techniques: Decision Trees, KNN, Regression, pertains to unsupervised learning.
Naïve Bayes • In clustering, the similarity between two objects is
• Example: In a banking application, the customer who measured by the similarity function where the distance
applies for a loan may be classified as a safe and risky between those two object is measured. Shorter the distance
according to his/her age and salary. The produced model higher the similarity, conversely longer the distance higher
could be in the form of a decision tree or in a set of rules. the dissimilarity.
• Classification techniques : decision tree, neural networks, • Clustering Techniques: K Mean
logistic regression, etc. • Example: Customer Segmentation
Supervised learning process: two steps
Learning (training): Learn a model using the training data
Testing: Test the model using unseen test data to assess the
model accuracy
64
Machine Learning in Enterpris e Computing
Machine learning Machine learning
New
Model Result
Data
Update by Retraining
Traditional rule-based approach vs. machine
learning
Fundamental assumption of learning
Assumption: The distribution of training examples is identical to the
distribution of test examples (including future unseen examples).
Some 8s from the MNIST data set
If you think about it, everything is just numbers
The neural network we made in Part 2 only took in a three numbers as
the input (“3” bedrooms, “2000” sq. feet , etc.). But now we want to
process images with our neural network. How in the world do we feed
• To a computer, an image is really just a grid of
numbers that represent how dark each pixel is:
To feed an image into our neural network, we simply treat the
18x18 pixel image as an array of 324 numbers:
To handle 324 inputs, we’ll just enlarge our neural network to have 324 input
nodes:
Training Data
Mmm… sweet, sweet training data
Clustering (Unsupervised Learning)
• Clustering is a technique for finding similarity groups in data, called clusters.
I.e.,
• it groups data instances that are similar to (near) each other in one cluster and data
instances that are very different (far away) from each other into different clusters.
• Clustering is often called an unsupervised learning task as no class values
denoting an a priori grouping of the data instances are given, which is the
case in supervised learning.
• Due to historical reasons, clustering is often considered synonymous with
unsupervised learning.
• In fact, association rule mining is also unsupervised
An illustration
• The data set has three natural groups of data points, i.e., 3
natural clusters.
99
What is clustering for?
Let us see some real-life examples
• Example 1: groups people of similar sizes together to make “small”,
“medium” and “large” T-Shirts.
• Tailor-made for each person: too expensive
• One-size-fits-all: does not fit all.
• Example 2: In marketing, segment customers according to their
similarities
• To do targeted marketing.
What is clustering for?
• Example 3: Given a collection of text documents, we want to organize
them according to their content similarities,
• To produce a topic hierarchy
• In fact, clustering is one of the most utilized data mining techniques.
• It has a long history, and used in almost every field, e.g., medicine,
psychology, botany, sociology, biology, archeology, marketing, insurance,
libraries, etc.
• In recent years, due to the rapid increase of online documents, text clustering
becomes important.
Hierarchical Clustering
• Agglomerative Hierarchical clustering Technique: In this technique,
initially each data point is considered as an individual cluster. At each
iteration, the similar clusters merge with other clusters until one
cluster or K clusters are formed.
• The basic algorithm of Agglomerative is straight forward.
• Compute the proximity matrix
• Let each data point be a cluster
• Repeat: Merge the two closest clusters and update the proximity matrix
• Until only a single cluster remains
• Key operation is the computation of the proximity of two clusters
Hierarchical Clustering
Hierarchical Clustering Visualization using
Dendrogram
K-Means Clustering (Unsupervised Learning Clustering)
• The k-Means clustering algorithm, which is effective for large datasets, puts similar, unlabeled
data into different groups.
• The first step is to select k, which is the number of clusters; generally by visualizations of that
data to see if there are noticeable grouping areas.
Algorithm:
• Pick a number k of random cluster centers
• Assign every item to its nearest cluster center using a distance metric
• Move each cluster center to the mean of its assigned items
• Repeat 2-3 until convergence (change in cluster assignment less than a threshold)
• How to select K in a complex data set?
• Experiment with different k values and then measure the average distances.
By doing this multiple times, there should be more accuracy.
• Why not have a high number for k? When we compute the average,
after a point there will be only incremental improvements. Stop at the
point where this starts to occur.
• SPSS offers 3 types of Clustering:
• 2 Step Clustering: Really large Data Sets
• K Means – Moderate Data Sets
• Hierarchical – Small Data sets
Some applications:
• Games:
• They are ideal for reinforcement learning since there are clear-cut rules, scores, and various constraints (like a game board).
• Can be tested with millions of simulations
• Used in Go, Chess
• Robotics:
• A key is being able to navigate within a space
• Requires evaluating the environment at many different points.
• If it navigates successfully, there is positive reinforcement… If it runs into things, there will be a negative reinforcement action.
Applications of Reinforcement Learning…
• Resources management in computer clusters: Designing algorithms to
automatically allocate and schedule computer resources to waiting
jobs, with the objective to minimize the average job slowdown
• Traffic Light Control
• Chemistry : optimizing chemical reactions.
• Personalized Recommendations
• Bidding and Advertising. Alibaba Group has shown how Multi Agent
Reinforcement Learning can be used in multi-agent bidding solution
(DCMAB). Example: Taobao ad platform is a place for merchants to
place a bid in order to display ad to the customers.
Some Innovations driven by Reinforcement
Learning
• Osaro:
• The company develops systems that allow robots to learn quickly.
• Osaro describes this as “the ability to mimic behavior that requires learned sensor
fusion as well as high level planning and object manipulation. It will also enable the
ability to learn from one machine to another and improve beyond a human
programmer’s insights.”
• For example, one of its robots was able to learn, within only five seconds, how to lift
and place a chicken (the system is expected to be used in poultry factories).
• OpenAI:
• have created the Dactyl, which is a robot hand that has human-like dexterity
• One of the surprising results was that the system learned human hand actions that
were not preprogrammed—such as sliding of the finger.
Some Innovations driven by Reinforcement
Learning
• Google:
• Beginning in 2013, the company went on an M&A (mergers and acquisitions) binge for robotics companies but was not very successful.
• Google has focused on pursuing simpler robots that are driven by AI and the company has created a new division, called Robotics at
Google.
• For example, one of the robots can look at a bin of items and identify the one that is requested—picking it up with a three-fingered
hand— about 85% of the time. A typical person, on the other hand, was able to do this at about 80%.
• COBOTS …These are robots that work along with people… a much more powerful approach, as there can be
leveraging of the advantages of both machines and humans.
• Amazon:
• In 2012, the company shelled out $775 million for Kiva, a top industrial robot manufacturer.
• Since then, Amazon.com has rolled out about 100,000 systems across more than 25 fulfillment centers (because of this, the company
has seen 40% improvement in inventory capacity).
• Amazon Robotics automates fulfilment center operations using various methods of robotic technology including autonomous mobile
robots, sophisticated control software, language perception, power management, computer vision, depth sensing, machine learning,
object recognition, and semantic understanding of commands.
• Within the warehouses, robots quickly move across the floor helping to locate and lift storage pods. But people are also critical as they
are better able to identify and pick individual products.
Re info rc e me nt Le arning
Applications of machine learning
REINFORCEMENT
RL Fe e dbac k Lo o p
▪At each step the ag e nt
– Executes action: 𝐴𝑡
– Receives observation: 𝑂𝑡
– Receives reward: 𝑅𝑡
▪The e nviro nme nt
– Receives action: 𝐴𝑡
– Emits observation: 𝑂𝑡+1
– Emits reward: 𝑅𝑡+1
Environment
© 2017 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 6