ML in Ruby

ML in Ruby

Recording (in Polish): https://youtu.be/zSfXh-Qul1s
TRUG#59 - Short intro to Machine Learning in Ruby

4cf300db4be834dfb4ddd76337205946?s=128

Michał Poczwardowski

February 15, 2017
Tweet

Transcript

  1. 15th Feb 2017 - TRUG Michal Poczwardowski michal.poczwardowski@netguru.co dmp @

    3cityIT slack
  2. f Machine learning - field of study that gives computers

    the ability to learn without being explicitly programmed. Arthur Samuel, 1959
  3. gathered data determines output supervised vs unsupervised

  4. • Recommendations • Expert systems • Spam filters • Classifications

    • Google Search
  5. • Decision Tree - ID3 • Jaccard Index • K-means

    clustering • Naive Bayes • Artificial Neural Networks • + more more more
  6. ? • Complicated written using unknown symbols might be discouraging

    • Use prepared tools / libraries
  7. ? • lack of stuff • speed (historical) • old

    gems / not so many resources • ML and AI experts mosty use Java and Python, Ruby hasn't got much love - most of them come from Universities and more scientific studies - Ruby is just not used in such environments
  8. • github.com/igrigorik/decisiontree • github.com/reddavis/K-Means • github.com/francois/jaccard • github.com/davidcelis/recommendable (for models)

  9. #1 1: require 'decisiontree' 2: 3: attributes = ['Temperature'] 4:

    training = [ 5: [36.6, 'healthy'], 6: [37, 'sick'], 7: [38, 'sick'], 8: [36.7, 'healthy'], 9: [40, 'sick'], 10: [50, 'really sick'], 11: ]
  10. #2 12: dec_tree = DecisionTree::ID3Tree.new(attributes, training, 'sick', :continuous) 13: dec_tree.train

    14: 15: test = [37.5, 'sick'] 16: decision = dec_tree.predict(test) 17: puts "Predicted: #{decision} ... True decision: #{test.last}" # => Predicted: sick ... True decision: sick
  11. 1: a = ["likes:jeans", "likes:blue"] 2: b = ["likes:jeans", "likes:women",

    "likes:red"] 3: c = ["likes:women", "likes:red"] 4: 5: # Determines how similar a pair of sets are 6: Jaccard.coefficient(a, b) 7: #=> 0.25 8: 9: Jaccard.coefficient(a, c) 10: #=> 0.0 11: 12: Jaccard.coefficient(b, c) 13: #=> 0.6666666666666666 14: 15: # According to the input data, b and c have the most similar likes.
  12. -

  13. - 1: require 'k_means' 2: 3: data = [[1,1], [1,2],

    [1,1], [1000, 1000], [500, 500]] 4: kmeans = KMeans.new(data, centroids: 2) 5: kmeans.inspect 6: => [[3, 4], [0, 1, 2]]
  14. - f : • K-means exaple HERE •

  15. None
  16. • https://www.toptal.com/machine-learning/machine-learning-theory-an-introductory-primer • http://otobrglez.opalab.com/ruby/2014/03/23/simple-ruby-recommendation-system.html • https://en.wikipedia.org/wiki/Jaccard_index • https://en.wikipedia.org/wiki/K-means_clustering • https://en.wikipedia.org/wiki/ID3_algorithm

  17. thanks!