Download - Practical Machine Learning
Practical Machine LearningDavid Jones
“Field of study that gives computers the ability to learn without being explicitly programmed”
Arthur Samuel, 1959
“Write a program to make this helicopter hover”
Pitch
Yaw
Roll
helicopter.rb
while helicopter.flying
if helicopter.pitch < 0 helicopter.pitchBy(0.1) else helicopter.pitchBy(-0.1) end
end
helicopter.rb
while helicopter.flying
if helicopter.pitch < 0 helicopter.pitchBy(0.1) else helicopter.pitchBy(-0.1) end
if helicopter.yaw < 0 helicopter.yawBy(0.1) else helicopter.yawBy(-0.1) end
end
helicopter.rbwhile helicopter.flying
if helicopter.pitch < 0 helicopter.pitchBy(0.1) else helicopter.pitchBy(-0.1) end
if helicopter.yaw < 0 helicopter.yawBy(0.1) else helicopter.yawBy(-0.1) end
if helicopter.roll < 0 helicopter.rollBy(0.1) else helicopter.rollBy(-0.1) end
end
OK, but what if…• it’s about to hit a tree?
• one of the main rotor blades is broken?
• power is running low?
• there is wind?
What if the helicopter was upside down?
helicopter.rbwhile helicopter.flying
if helicopter.pitch < 0 helicopter.pitchBy(0.1) else helicopter.pitchBy(-0.1) end
if helicopter.yaw < 0 helicopter.yawBy(0.1) else helicopter.yawBy(-0.1) end
if helicopter.roll < 0 helicopter.rollBy(0.1) else helicopter.rollBy(-0.1) end
end
Fail
Observe new exception case
Write code to handle exception
Helicopter Flying CodebaseHelicopter Flying Codebase
You will soon realise you can’t explicitly handle every
exception.
“Field of study that gives computers the ability to learn without being explicitly programmed”
Arthur Samuel, 1959
Autonomous RC HelicopterFlown using machine learning algorithms
That was 8 years ago…How good is machine learning today?
Germany wins
All 15 match outcomes predicted correctlyNo “luck” here.
Google SearchNetflix
Face DetectionSpam Detection
Medical Diagnosis AdvertisingFraud Detection
Product Recommendations
Siri
OCR
Priority Inbox
Dictation
Autonomous Cars
Video Games
Finance
Sentiment Analysis
So, how does it work?
Collect Data
Train Model
Make Predictions
Two distinct algorithm types• Supervised algorithms
• Unsupervised algorithms
Supervised
Supervised Learning
Trai
ning
Dat
a
estimate_sales_price.rbdef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood) price = 0 # In my area, the average house costs $200 per sqft price_per_sqft = 200
if neighborhood == "hipsterton": # but some areas cost a bit more price_per_sqft = 400 elsif neighborhood == "skid row": # and some areas cost less price_per_sqft = 100 end
# start with a base price estimate based on how big the place is price = price_per_sqft * sqft
# now adjust our estimate based on the number of bedrooms if num_of_bedrooms == 0 # Studio apartments are cheap price = price - 20000 else # places with more bedrooms are usually # more valuable price = price + (num_of_bedrooms * 1000) end
priceend
estimate_sales_price_ml.rbdef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood) do_some_maths(num_of_bedrooms, sqft, neighborhood)end
estimate_sales_price_ml.rbdef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood) price = 0 # a little pinch of this price += num_of_bedrooms * .841231951398213 # and a big pinch of that price += sqft * 1231.1231231 # maybe a handful of this price += neighborhood * 2.3242341421 # and finally, just a little extra salt for good measure price += 201.23432095end
estimate_sales_price_ml.rbdef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood) price = 0 # a little pinch of this price += num_of_bedrooms * 1.0 # and a big pinch of that price += sqft * 1.0 # maybe a handful of this price += neighborhood * 1.0 # and finally, just a little extra salt for good measure price += 1.0end
…500
Square Feet
Number of Bedrooms
estimate_sales_price_ml.rbdef estimate_house_sales_price(num_of_bedrooms, sqft, neighborhood) price = 0 # a little pinch of this price += num_of_bedrooms * .841231951398213 # and a big pinch of that price += sqft * 1231.1231231 # maybe a handful of this price += neighborhood * 2.3242341421 # and finally, just a little extra salt for good measure price += 201.23432095end
$300,000
Unsupervised
“Computer, tell me what’s interesting about this data”
Trai
ning
Dat
a
Machine Learning>
Explicit Programming
x = sqr feety = price
Selecting Features
Force applied, weight, colour, wind, material, who threw it, day of week
Force applied, weight, colour, wind, material, who threw it, day of week
Practical Machine LearningHow do I use this as a developer?
Algorithm SelectionHow do I know what algorithm to use?
Algorithm ImplementationHow do I implement an algorithm? Don’t.
Algorithm PerformanceLarge amounts of training data changing in
realtime
HostingHow am I going to run special software
required to successfully use ML?
No Data?Start logging today.
ML for DevelopersSo you don’t need to get a PHD in maths
Prediction.IO• Open Source
• Deploy on your own servers or instantly on Amazon’s Cloud
• Cheap to run
• Developer friendly API
• Easy to use admin UI
Prediction.IO• Ignore the maths
• Helps you find the best algorithm for your problem
• Easily hosted and performant
• Uses scalable services such as MapReduce and Hadoop.
• You don’t need to know how to work this stuff though.
Prediction.IO• Specialises in two use cases
• recommendations
• similarity
• more being added…
Product ratingProduct viewsPurchases
Selecting Features
Selecting Features
Selecting Features
Selecting Features
Ruby SDK
A/B Test Results• 45% longer average session
• 22% increase in conversion rate
• 37% increase in average order value
• 71% increase in revenue
Machine Learning• Extremely powerful at solving complex
problems
• Increasingly important for developers to know about it
• Don’t need to know the maths to get the benefit
More InformationStanford Machine Learning https://www.coursera.org/course/ml
Bootstrapping Machine Learning http://www.louisdorard.com/machine-learning-book/
Machine Learning is Fun https://medium.com/@ageitgey/machine-learning-is-fun-80ea3ec3c471
Building The Smart Shophttp://info.resolvedigital.com/building-the-smart-spree-shop
David Jones@d_jones
Questions?