This guide contains the talking points and code for my talk for the RubyDevSummit titled, Machine Learning on Rails.
What is Machine Learning?
“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.”
Dead simple definition:
The data determines the output.
Right tool for the right job
Shallow vs deep learning
: naive bayes, decision trees - straightforward implementation in a Rails app
: Neural networks - Tensorflow traditional framework
Practical Applications of Machine Learning
Custom route actions
Sport specific scouting.
Analyzing when a vehicle may need to be removed from a fleet based on historical trends.
Checking to see if an email is spam.
Verifying bank transactions.
Verifying medical diagnosis.
Google search engine
Etc, etc, etc
Why Ruby Isn’t Typically Used for Machine Learning
Misconceived notions about speed
Lack of libraries
Ease of passing responsibilities to other services
Assumption that all machine learning is deep learning
K Means Clustering Algorithm
Support Vector Machine Algorithm
Artificial Neural Networks
Supervised vs Unsupervised Learning
– Teaching a child that an electrical outlet is dangerous, and the child learns not to touch other electrical hazards.
– A child learns what’s dangerous by trial and error, eventually learning not to touch electrical hazards.
Ruby Machine Learning Examples
Continuous vs Discrete
– Items that can be measured, e.g. height, weight, product reviews.
– Items that have a set number of options: gender, or dice roll.
Decision Tree Example
Naive Bayes Example
Rails + Machine Learning
Machine learning process for Recommendation Engine
Content crawler / cleaning - Ruby excels at both tasks
Tokenization + Graph Rank Probability analysis
Save learning object to yml for persistence
Run Naive Bayes through knowledge base
Implementation Tools for Recommendation Engine
Rails Microservice API App
Sidekiq + Redis + ActiveJob
Notable Element of Recommendation Engine API
Service object <> Background jobs
Stop Words for Graph Rank
Instructions for Testing Locally