SlideShare a Scribd company logo
Machine Learning
Boris Nadion
boris@astrails.com
@borisnadion
@borisnadion
boris@astrails.com
astrails
http://astrails.com
awesome web and mobile apps
since 2005
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
Machine Learning: Make Your Ruby Code Smarter
terms
AI (artificial intelligence)
- the theory and development of computer systems
able to perform tasks that normally require human
intelligence, such as visual perception, speech
recognition, decision-making, and translation
between languages
ML (machine learning)
- is a type of artificial intelligence (AI) that provides
computers with the ability to learn without being
explicitly programmed. Machine learning focuses
on the development of computer programs that
can teach themselves to grow and change when
exposed to new data.
without being explicitly programmed
FF NN cost function
FF NN Cost Function
I’m kidding
cost function with regularization
2 types of ML
supervised learning
unsupervised learning
supervised
the training data is labeled,
eg. we know the correct answer
unsupervised
the training data is not labeled,
eg. we would figure out hidden correlations by ourselves
linear regression
supervised learning
(x(1)
, y(1)
), (x(2)
, y(2)
)…(x(m)
, y(m)
)
m training examples of (x(i)
, y(i)
)
x(i)
- feature
y(i)
- label
x(i)
y(i)
training set
learning algorithm
hθ(x)x(new data)
y(prediction)
training set
learning algorithm
hθ(x)x(new data)
y(prediction)
hθ(x) = hypothesis
(x, y)
y = hθ(x) = θ0 + θ1x
find θ0 and θ1
hθ(x) = θ0 + θ1x1 + θ2x2 + …+ θnxn
many features, n - number of features
size, sq.m
x1
# rooms
x2
age
x3
price
y
80 3 22 2.9M
90 4 24 3.1M
75 3 28 2.5M
110 5 20 3.3M
1 USD = 3.85 NIS
hθ(x) = θ0 + θ1x1
summate the prediction error on training set
Linear Regression Cost Function
minimize J(θ)
funding a minimum of cost function = “learning”
gradient descent
batch, stochastic, etc, or advanced optimization algorithms
to find a global (sometimes local) minimum of cost function J
𝞪 - learning rate, a parameter of gradient descent
(x(1)
, y(1)
), (x(2)
, y(2)
)…(x(m)
, y(m)
)
gradient descent
θ0, θ1, θ2, …, θn
magic
inside
hθ(x) = θ0 + θ1x1 + θ2x2 + …+ θnxn
we’re ready to predict
features scaling
0 ≤ x ≤ 1
size, sq.m
size, sq.m / 110
x1
80 0.72
90 0.81
75 0.68
110 1
mean normalization
average value of the feature is ~0
-0.5 ≤ x ≤ 0.5
size, sq.m
(size, sq.m / 110) - 0.8025
x1
80 -0.0825
90 0.075
75 -0.1226
110 0.1975
matrix manipulations
X = n x 1 vector, ϴ = n x 1 vector
hθ(x) = θ0 + θ1x1 + θ2x2 + …+ θnxn
hθ(x) = ϴT
X
GPU
Machine Learning: Make Your Ruby Code Smarter
logistic regression
supervised learning
classifier
y = 1, true
y = 0, false
hθ(x) = g(ϴT
X)
hθ(X) - estimated probability that y = 1 on input X
g(z) - logistic non-linear function
logistic function g(z)
there is a few: sigmoid, tahn, ReLUs, etc
image source: Wikipedia
(x(1)
, y(1)
), (x(2)
, y(2)
)…(x(m)
, y(m)
)
minimize the cost
function
vector θ
y = {0, 1}
training set
learning algorithm
hθ(x)x(new data)
y(prediction)
hθ(x) = g(ϴT
X) y ≥ 0.5 - true
y < 0.5 - false
one-vs-all
supervised learning
Machine Learning: Make Your Ruby Code Smarter
y = 1, true
y = 0, false
y = 0, false
don’t implement it at home
use libsvm, liblinear, and others
neural networks
supervised learning
neuron
a0
a1
a2
computation hθ(a)
feed forward neural network
input layer
hidden layer
output layer
estimates
size, sq.m
# rooms
age
e0
e1
e2
e3
estimates
final
estimate
multiclass classifiers
logistic unit
x0
x1
x2
θ1
θ2
θ3 hθ = g(x0θ0 + x1θ1 + x2θ2)
θ - weights
g - activation function
logistic function g(z)
there is a few: sigmoid, tahn, ReLUs, etc
image source: Wikipedia
output: probabilities
0.4765 that y = 2
0.7123 that y = 1
net with no hidden layers
no hidden layers = one-vs-all logistic regression
cost function
sometimes called loss function of NN,
a representation of an error between
a real and a predicted value
training set
learning algorithm
θx(new data)
y(prediction)
backprop
backward propagation of errors
gradient descent + backprop
“deep learning” - is training a neural net
“deep” - because we have many layers
convolutional neural nets
widely used for image processing and object recognition
recurrent neural nets
widely used for natural language processing
CPU/GPU expensive
image source: https://xkcd.com/303/
image source: http://www.falsepositives.com/index.php/2008/01/31/the-real-reason-for-no-increased-productivity-behind-scripting-languages-reveled/
2008
2016
destination suggestion
tangledpath/ruby-fann
Ruby library for interfacing with FANN
(Fast Artificial Neural Network)
require './neural_network'
LOCATIONS = [:home, :work, :tennis, :parents]
LOCATIONS_INDEXED = LOCATIONS.map.with_index { |x, i| [x, i] }.to_h
XX = [
# week 1
# 1st day of week, 8am
[:work, 1, 8], [:tennis, 1, 17], [:home, 1, 20],
[:work, 2, 8], [:home, 2, 18],
[:work, 3, 8], [:tennis, 3, 17], [:home, 3, 20],
[:work, 4, 8], [:home, 4, 18],
[:work, 5, 8], [:home, 5, 18],
[:parents, 7, 13], [:home, 7, 18],
# week 2
[:work, 1, 8], [:home, 1, 18],
[:work, 2, 8], [:home, 2, 18],
[:work, 3, 8], [:tennis, 3, 17], [:home, 3, 20],
[:work, 4, 8], [:home, 4, 18],
[:work, 5, 8], [:home, 5, 18],
XX.each do |destination, day, time|
yy << LOCATIONS_INDEXED[destination]
xx << [day.to_f/7, time.to_f/24]
end
features scaling
2 ➞ 25 ➞ 4
one hidden layer with 25 units
100% accuracy
on training set
[
[1, 16.5], [1, 17], [1, 17.5], [1, 17.8],
[2, 17], [2, 18.1],
[4, 18],
[6, 23],
[7, 13],
].each do |day, time|
res = nn.predict_with_probabilities([
[day.to_f/7, time.to_f/24]
]).first.
select {|v| v[0] > 0} # filter zero probabilities
puts "#{day} #{time} t #{res.map {|v| [LOCATIONS[v[1]], v[0]]}.inspect}"
end
1 16.5 [[:tennis , 0.97]]
1 17 [[:tennis , 0.86], [:home , 0.06]]
1 17.5 [[:home , 0.52], [:tennis, 0.49]]
1 17.8 [[:home , 0.82], [:tennis, 0.22]]
2 17 [[:tennis , 0.85], [:home , 0.06]]
2 18.1 [[:home , 0.95], [:tennis, 0.07]]
4 18 [[:home , 0.96], [:tennis, 0.08]]
6 23 [[:home , 1.00]]
[:work, 1, 8], [:tennis, 1, 17], [:home, 1, 20],
[:work, 2, 8], [:home, 2, 18],
[:work, 3, 8], [:tennis, 3, 17], [:home, 3, 20],
[:work, 4, 8], [:home, 4, 18],
[:work, 5, 8], [:home, 5, 18],
[:parents, 7, 13], [:home, 7, 18],
# week 2
[:work, 1, 8], [:home, 1, 18],
[:work, 2, 8], [:home, 2, 18],
[:work, 3, 8], [:tennis, 3, 17], [:home, 3, 20],
[:work, 4, 8], [:home, 4, 18],
[:work, 5, 8], [:home, 5, 18],
borisnadion/suggested-destination-demo
ruby code of the demo
tensorflow
but you will need to learn Python
clustering
unsupervised learning
{X(i)
}
no labels
Machine Learning: Make Your Ruby Code Smarter
anomaly detection
unsupervised learning
Machine Learning: Make Your Ruby Code Smarter
collaborative filtering
unsupervised learning
Jane Arthur John
Star Wars VII 5 5 1
Dr. Strange 5 5 ?
Arrival 5 ? 1
automatic features
and their weights detection
based on the user votes
similarity between users
and between items
what to google
http://astrails.com
thanks!
Boris Nadion
http://astrails.com

More Related Content

What's hot (20)

PPS
A Tutorial On Ip 1
ankuredkie
 
PDF
Image Restoration (Digital Image Processing)
VARUN KUMAR
 
PPTX
Variational Autoencoder Tutorial
Hojin Yang
 
PDF
Generative modeling with Convolutional Neural Networks
Denis Dus
 
PDF
Week 6
AliHassan1274
 
PDF
NTHU AI Reading Group: Improved Training of Wasserstein GANs
Mark Chang
 
PPT
Dip Morphological
Mubbasher Khaliq
 
PDF
Neural networks - BigSkyDevCon
ryanstout
 
PDF
Learning Deep Learning
simaokasonse
 
PDF
Computational Linguistics week 5
Mark Chang
 
PDF
Eight Regression Algorithms
guestfee8698
 
PDF
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Pooyan Jamshidi
 
PDF
present_merged
Anthi Orfanou
 
PDF
MUMS Opening Workshop - An Overview of Reduced-Order Models and Emulators (ED...
The Statistical and Applied Mathematical Sciences Institute
 
PPTX
Deep Residual Hashing Neural Network for Image Retrieval
Edwin Efraín Jiménez Lepe
 
PDF
Blur Filter - Hanpo
Hanpo Cheng
 
PDF
Sparse autoencoder
Devashish Patel
 
PDF
Conditional neural processes
Kazuki Fujikawa
 
PPTX
Gaussian Image Blurring in CUDA C++
Darshan Parsana
 
PDF
Output Units and Cost Function in FNN
Lin JiaMing
 
A Tutorial On Ip 1
ankuredkie
 
Image Restoration (Digital Image Processing)
VARUN KUMAR
 
Variational Autoencoder Tutorial
Hojin Yang
 
Generative modeling with Convolutional Neural Networks
Denis Dus
 
NTHU AI Reading Group: Improved Training of Wasserstein GANs
Mark Chang
 
Dip Morphological
Mubbasher Khaliq
 
Neural networks - BigSkyDevCon
ryanstout
 
Learning Deep Learning
simaokasonse
 
Computational Linguistics week 5
Mark Chang
 
Eight Regression Algorithms
guestfee8698
 
Ensembles of Many Diverse Weak Defenses can be Strong: Defending Deep Neural ...
Pooyan Jamshidi
 
present_merged
Anthi Orfanou
 
MUMS Opening Workshop - An Overview of Reduced-Order Models and Emulators (ED...
The Statistical and Applied Mathematical Sciences Institute
 
Deep Residual Hashing Neural Network for Image Retrieval
Edwin Efraín Jiménez Lepe
 
Blur Filter - Hanpo
Hanpo Cheng
 
Sparse autoencoder
Devashish Patel
 
Conditional neural processes
Kazuki Fujikawa
 
Gaussian Image Blurring in CUDA C++
Darshan Parsana
 
Output Units and Cost Function in FNN
Lin JiaMing
 

Viewers also liked (17)

PPT
algorithm
kokilabe
 
PPTX
Algorithm - Introduction
Madhu Bala
 
PPT
N5 Computing Science - Machine Code
Forrester High School
 
PPT
Introduction To Algorithm [2]
ecko_disasterz
 
PPTX
visual basic 6.0
lesly53
 
PPT
Machine language
Ripal Dhruv
 
PPTX
Visual basic 6.0
maiker perez
 
PPTX
Visual basic 6
mohamedsaad24
 
PDF
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
PPTX
Assembly and Machine Code
Project Student
 
PPT
Visual Basic 6.0
Palitha Baddegama
 
PDF
Visual Basic 6.0
Anjan Mahanta
 
PPTX
Presentation on visual basic 6 (vb6)
pbarasia
 
PPT
Introduction to visual basic programming
Roger Argarin
 
PPTX
Computer Languages.
Aditya Sheoran
 
PPT
Visual basic ppt for tutorials computer
simran153
 
algorithm
kokilabe
 
Algorithm - Introduction
Madhu Bala
 
N5 Computing Science - Machine Code
Forrester High School
 
Introduction To Algorithm [2]
ecko_disasterz
 
visual basic 6.0
lesly53
 
Machine language
Ripal Dhruv
 
Visual basic 6.0
maiker perez
 
Visual basic 6
mohamedsaad24
 
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Assembly and Machine Code
Project Student
 
Visual Basic 6.0
Palitha Baddegama
 
Visual Basic 6.0
Anjan Mahanta
 
Presentation on visual basic 6 (vb6)
pbarasia
 
Introduction to visual basic programming
Roger Argarin
 
Computer Languages.
Aditya Sheoran
 
Visual basic ppt for tutorials computer
simran153
 
Ad

Similar to Machine Learning: Make Your Ruby Code Smarter (20)

PPTX
Introduction to Neural Netwoks
Abdallah Bashir
 
PDF
EssentialsOfMachineLearning.pdf
Ankita Tiwari
 
PDF
Capstone paper
Muhammad Saeed
 
PPTX
Neural Networks - How do they work?
Accubits Technologies
 
PDF
Neural Nets Deconstructed
Paul Sterk
 
PDF
AIML2 DNN 3.5hr (111-1).pdf
ssuserb4d806
 
PDF
Integrating Artificial Intelligence with IoT
bplay2086
 
PPTX
Nimrita deep learning
Nimrita Koul
 
PPTX
Deep Learning
MoctardOLOULADE
 
PDF
Artificial Neural Network for machine learning
2303oyxxxjdeepak
 
PDF
super-cheatsheet-artificial-intelligence.pdf
ssuser089265
 
PPTX
Machine learning ppt unit one syllabuspptx
VenkateswaraBabuRavi
 
PDF
Deep learning
Rouyun Pan
 
PDF
Survey on Artificial Neural Network Learning Technique Algorithms
IRJET Journal
 
PPTX
Deep learning from scratch
Eran Shlomo
 
PPTX
lecture15-neural-nets (2).pptx
anjithaba
 
PPT
tutorial.ppt
Vara Prasad
 
PDF
Lesson_8_DeepLearning.pdf
ssuser7f0b19
 
PPTX
Introduction to Machine Learning basics.pptx
srimathihss
 
PPTX
Neural network basic and introduction of Deep learning
Tapas Majumdar
 
Introduction to Neural Netwoks
Abdallah Bashir
 
EssentialsOfMachineLearning.pdf
Ankita Tiwari
 
Capstone paper
Muhammad Saeed
 
Neural Networks - How do they work?
Accubits Technologies
 
Neural Nets Deconstructed
Paul Sterk
 
AIML2 DNN 3.5hr (111-1).pdf
ssuserb4d806
 
Integrating Artificial Intelligence with IoT
bplay2086
 
Nimrita deep learning
Nimrita Koul
 
Deep Learning
MoctardOLOULADE
 
Artificial Neural Network for machine learning
2303oyxxxjdeepak
 
super-cheatsheet-artificial-intelligence.pdf
ssuser089265
 
Machine learning ppt unit one syllabuspptx
VenkateswaraBabuRavi
 
Deep learning
Rouyun Pan
 
Survey on Artificial Neural Network Learning Technique Algorithms
IRJET Journal
 
Deep learning from scratch
Eran Shlomo
 
lecture15-neural-nets (2).pptx
anjithaba
 
tutorial.ppt
Vara Prasad
 
Lesson_8_DeepLearning.pdf
ssuser7f0b19
 
Introduction to Machine Learning basics.pptx
srimathihss
 
Neural network basic and introduction of Deep learning
Tapas Majumdar
 
Ad

More from Astrails (12)

PDF
Building and deploying React applications
Astrails
 
PDF
Accounting For Hackers
Astrails
 
PDF
Migrating from Flux to Redux. Why and how.
Astrails
 
PDF
Engineering esthetics
Astrails
 
PDF
Lean Software Development
Astrails
 
PDF
RubyMotion: Put your Dreams in Motion with Ruby
Astrails
 
PDF
WTF is NoSQL
Astrails
 
PDF
Cassandra intro
Astrails
 
PDF
Ruby is an Acceptable Lisp
Astrails
 
PDF
Ruby is Awesome
Astrails
 
PDF
Rails missing features
Astrails
 
PDF
Performance - When, What and How
Astrails
 
Building and deploying React applications
Astrails
 
Accounting For Hackers
Astrails
 
Migrating from Flux to Redux. Why and how.
Astrails
 
Engineering esthetics
Astrails
 
Lean Software Development
Astrails
 
RubyMotion: Put your Dreams in Motion with Ruby
Astrails
 
WTF is NoSQL
Astrails
 
Cassandra intro
Astrails
 
Ruby is an Acceptable Lisp
Astrails
 
Ruby is Awesome
Astrails
 
Rails missing features
Astrails
 
Performance - When, What and How
Astrails
 

Recently uploaded (20)

PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
July Patch Tuesday
Ivanti
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Designing Production-Ready AI Agents
Kunal Rai
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Machine Learning: Make Your Ruby Code Smarter