Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Machine learning

1,579 views

Published on

A brief overview of making recommendations using the K nearest neighbour algorithm and the Euclidean distance. Given at a Forward First Tuesday evening.

Published in: Technology, Business
  • Be the first to comment

Machine learning

  1. 1. Machine Learning
  2. 2. Machine Learning A n Intro duction
  3. 3. Automated Insights
  4. 4. Spam
  5. 5. You might like ...
  6. 6. The World
  7. 7. People you should follow...
  8. 8. People you may know...
  9. 9. People you may know...
  10. 10. Classifying ClusteringRecommending
  11. 11. Classifying
  12. 12. Clustering
  13. 13. Recommending
  14. 14. ItemsUsers
  15. 15. ItemsUsers
  16. 16. ItemsUsers
  17. 17. ItemsUsers
  18. 18. ItemsUsers
  19. 19. Modeling
  20. 20. Similarity
  21. 21. Movies
  22. 22. Collaborative
  23. 23. How to represent our data?
  24. 24. Data User A User B User CItem 1 1.0 3.0 5.0
  25. 25. Similarity? User A User B User CItem 1 1.0 3.0 5.0Item 2 2.0 5.0 2.0Item 3 1.0 3.0 1.0
  26. 26. Euclidean Distance
  27. 27. Euclidean Distance q 1.0 2.0 1.0 p 2.0 5.0 3.0
  28. 28. Euclidean Distance User A User B User C dItem 1 1.0 3.0 5.0 4Item 2 2.0 5.0 2.0 2.45Item 3 1.0 3.0 1.0
  29. 29. Euclidean Distance(defn euclidean-distance [v m] (let [num-of-rows (first (dim m)) difference (minus (matrix (repeat num-of-rows v)) m)] (sqrt (map sum-of-squares difference)))) Clojure #ftw
  30. 30. Content Based
  31. 31. Distance User A User B User CItem 1 1.0 3.0 5.0Item 2 2.0 5.0 2.0Item 3 1.0 3.0 1.0
  32. 32. Distance Feature A Feature B Feature CItem 1 1.0 3.0 5.0Item 2 2.0 5.0 2.0Item 3 1.0 3.0 1.0
  33. 33. Classification Algorithm
  34. 34. k-nearest neighbours
  35. 35. Our Data A B C dItem 1 1.0 3.0 5.0 4Item 2 2.0 5.0 2.0 2.45Item 3 1.0 3.0 1.0
  36. 36. Our Model A B C d Label {Trained Item 1 1.0 3.0 5.0 4 Spam Item 2 2.0 5.0 2.0 2.45 Ham Item 3 1.0 3.0 1.0
  37. 37. Our Model Label d {Trained Item 1 Spam 4 Item 2 Ham 2.45 Item 3
  38. 38. k-nn Classifier(defn knn-classify [xs k m labels] (let [sorted-labels (take k (map (partial nth labels) (sorted-indexes (euclidean-distance xs m)))) category (mode sorted-labels)] (if (seq? category) (first category) category))) Clojure #ftw
  39. 39. Evaluation
  40. 40. Our Model Label d {Trained Item 1 Spam 4 Item 2 Ham 2.45 Item 3
  41. 41. Our Model Observed Label Calculated Label {Trained Item 1 Spam Item 2 HamTest Item 3 Ham Ham
  42. 42. kʼthx

×