Introduction to
Machine Learning and
AI
Matt Hamilton
Developer Advocate
SW Mobile
February 25, 2020
What is the difference
between Machine
Learning (ML) and
Artificial Intelligence
(AI)?
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 2
In short…
- If you are reading a Powerpoint: it is AI
- If you are reading Python: it is ML
[ Yes that is a flippant answer. Artificial Intelligence is a much broader
field, of which ML is just one aspect/implementation. But for now this is
a useful simplification ]
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 3
What is Machine
Learning?
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 4
Just a function that takes input and gives outputs, but the bit in the middle is ‘learned’ rather than explicitly coded. E.g.
What is Machine
Learning?
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 5
Just a function that takes input and gives outputs, but the bit in the middle is ‘learned’ rather than explicitly coded. E.g.
Types of
machine
learning
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 6
• Supervised learning
• Unsupervised learning
• Reinforcement learning
• Generative Adversarial Networks
Supervised
Learning
We train the algorithm with
“known” data then ask it to
predict unknown.
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 7
Classification
e.g. “Here is 100 pictures of cats, and
100 pictures of dogs, predict whether
this new image is a cat or a dog”
Regression
e.g. “Here is historical temperature data
for Bristol, predict what the
temperature will be tomorrow”
Unsupervised
learning
We have no ‘labels’ for the
data ahead of time
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 8
Clustering
e.g. “Find all towns on this map of
mobile phone towers”
Association
e.g. “What other alerts do we get when
we get a disk-full alert?”
Reinforcement
Learning
“Learning by playing or doing”
Rules are not defined at the start, but a
reward is given based on behaviour
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 9
Generative
Adversarial
Networks
Generating new data (images or text)
Two neural networks try to out-do each
other
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 10
Types of machine
learning algorithms
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 11
There are many types of machine
learning algorithms, eg:
• Naive Bayes Classifier
• Support Vector Machines
• Random Forest
• Neural Networks
Simple Neural Network
example (Keras)
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 12
# compile the model
model.compile(optimizer='adam', loss='mse')
# train the model on first 8 values of data
model.fit(X[:8], y[:8], epochs=7000,
batch_size=32, verbose=0)
# predict the last two (unseen) values
preds = model.predict(X[8:])
print(preds)
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
# define our data
X = np.array([0, 1, 2, 3, 4, 5, 6, 8, 9, 10])
y = np.array([0, 2, 4, 6, 8, 10, 12, 16, 18, 20])
# define out neural network model
model = Sequential()
model.add(Dense(5, input_shape=(1,))) # 5 hidden
neurons
model.add(Dense(1)) # 1 output neuron
Common issues starting
with ML
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 13
How do I frame the problem? Is it
classification? Is it regression? What do
I actually want to know?
• “What is the percentage chance of
rain tomorrow?”
Regression
• “Is there a greater than 60% chance
of rain tomorrow?”
Classification
Pre-processing data
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 14
Dealing with missing data
Making data stationary
Pre-processing data
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 15
De-trend data
Pre-processing data
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 16
Unbalanced sets (classification)
Feature Engineering
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 17
Using domain knowledge to feed some more meaningful
data to the algorithm
This is where much of the work and skill is in effectively
utilising ML.
’Mlle’ => ‘Miss’
‘Mme’ => ‘Mrs’
'Lady', 'Countess','Capt', ‘Dr', 'Major', 'Rev',
‘Sir', 'Jonkheer', ‘Dona' => ‘special’
What do we know of the cabin numbering and layout?
- Cabin A14 => Deck “A” = First class, amidships
Feature Engineering
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 18
Formatting data (e.g. financial limit order book data) as ‘graphical’ then use CNN to categorise
Toolkits
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 19
• Swift for Tensorflow
• CoreML
• Tensorflow lite for Android
• Scikit-learn
• Keras (now part of Tensorflow)
• Tensorflow
• Torch (pyTorch)
• Caffe
• Theano
IBM tools
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 20
• Watson Machine
Learning
• Watson AutoAI
• Watson Studio
Thank you.
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 21
Matt Hamilton
Developer Advocate
Matthew.Hamilton1@ibm.com
@hammertoe
IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 22

Intro to Machine Learning and AI

  • 1.
    Introduction to Machine Learningand AI Matt Hamilton Developer Advocate SW Mobile February 25, 2020
  • 2.
    What is thedifference between Machine Learning (ML) and Artificial Intelligence (AI)? IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 2
  • 3.
    In short… - Ifyou are reading a Powerpoint: it is AI - If you are reading Python: it is ML [ Yes that is a flippant answer. Artificial Intelligence is a much broader field, of which ML is just one aspect/implementation. But for now this is a useful simplification ] IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 3
  • 4.
    What is Machine Learning? IBMDeveloper Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 4 Just a function that takes input and gives outputs, but the bit in the middle is ‘learned’ rather than explicitly coded. E.g.
  • 5.
    What is Machine Learning? IBMDeveloper Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 5 Just a function that takes input and gives outputs, but the bit in the middle is ‘learned’ rather than explicitly coded. E.g.
  • 6.
    Types of machine learning IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 6 • Supervised learning • Unsupervised learning • Reinforcement learning • Generative Adversarial Networks
  • 7.
    Supervised Learning We train thealgorithm with “known” data then ask it to predict unknown. IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 7 Classification e.g. “Here is 100 pictures of cats, and 100 pictures of dogs, predict whether this new image is a cat or a dog” Regression e.g. “Here is historical temperature data for Bristol, predict what the temperature will be tomorrow”
  • 8.
    Unsupervised learning We have no‘labels’ for the data ahead of time IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 8 Clustering e.g. “Find all towns on this map of mobile phone towers” Association e.g. “What other alerts do we get when we get a disk-full alert?”
  • 9.
    Reinforcement Learning “Learning by playingor doing” Rules are not defined at the start, but a reward is given based on behaviour IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 9
  • 10.
    Generative Adversarial Networks Generating new data(images or text) Two neural networks try to out-do each other IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 10
  • 11.
    Types of machine learningalgorithms IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 11 There are many types of machine learning algorithms, eg: • Naive Bayes Classifier • Support Vector Machines • Random Forest • Neural Networks
  • 12.
    Simple Neural Network example(Keras) IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 12 # compile the model model.compile(optimizer='adam', loss='mse') # train the model on first 8 values of data model.fit(X[:8], y[:8], epochs=7000, batch_size=32, verbose=0) # predict the last two (unseen) values preds = model.predict(X[8:]) print(preds) import numpy as np import tensorflow as tf from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense # define our data X = np.array([0, 1, 2, 3, 4, 5, 6, 8, 9, 10]) y = np.array([0, 2, 4, 6, 8, 10, 12, 16, 18, 20]) # define out neural network model model = Sequential() model.add(Dense(5, input_shape=(1,))) # 5 hidden neurons model.add(Dense(1)) # 1 output neuron
  • 13.
    Common issues starting withML IBM Developer Advocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 13 How do I frame the problem? Is it classification? Is it regression? What do I actually want to know? • “What is the percentage chance of rain tomorrow?” Regression • “Is there a greater than 60% chance of rain tomorrow?” Classification
  • 14.
    Pre-processing data IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 14 Dealing with missing data Making data stationary
  • 15.
    Pre-processing data IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 15 De-trend data
  • 16.
    Pre-processing data IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 16 Unbalanced sets (classification)
  • 17.
    Feature Engineering IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 17 Using domain knowledge to feed some more meaningful data to the algorithm This is where much of the work and skill is in effectively utilising ML. ’Mlle’ => ‘Miss’ ‘Mme’ => ‘Mrs’ 'Lady', 'Countess','Capt', ‘Dr', 'Major', 'Rev', ‘Sir', 'Jonkheer', ‘Dona' => ‘special’ What do we know of the cabin numbering and layout? - Cabin A14 => Deck “A” = First class, amidships
  • 18.
    Feature Engineering IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 18 Formatting data (e.g. financial limit order book data) as ‘graphical’ then use CNN to categorise
  • 19.
    Toolkits IBM Developer Advocate/ Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 19 • Swift for Tensorflow • CoreML • Tensorflow lite for Android • Scikit-learn • Keras (now part of Tensorflow) • Tensorflow • Torch (pyTorch) • Caffe • Theano
  • 20.
    IBM tools IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 20 • Watson Machine Learning • Watson AutoAI • Watson Studio
  • 21.
    Thank you. IBM DeveloperAdvocate / Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 21 Matt Hamilton Developer Advocate Matthew.Hamilton1@ibm.com @hammertoe
  • 22.
    IBM Developer Advocate/ Intro to Machine Learning and AI / February 25th, 2020 / © 2020 IBM Corporation 22