bbm406
play

BBM406 Fundamentals of Machine Learning Lecture 2: Machine Learning - PowerPoint PPT Presentation

photo:@rewardyfahmi // Unsplash BBM406 Fundamentals of Machine Learning Lecture 2: Machine Learning by Examples, Nearest Neighbor Classifier Aykut Erdem // Hacettepe University // Fall 2019 When Do We Use Machine Learning? ML is


  1. 50 Image Classification : a core task in Computer Vision slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  2. 51 The problem : semantic gap slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  3. 52 Challenges: Viewpoint Variation slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  4. 53 Challenges: Illumination slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  5. 54 Challenges: Deformation slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  6. 55 Challenges: Occlusion slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  7. 56 Challenges: Background clutter slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  8. 57 Challenges: Intraclass variation slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  9. An image classifier slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson Unlike e.g. sorting a list of numbers, no obvious way to hard-code the algorithm for recognizing a cat, or other classes. 58

  10. 59 Attempts have been made slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  11. Data-driven approach: 1.Collect a dataset of images and labels 2.Use Machine Learning to train an image classifier 3.Evaluate the classifier on a withheld set of test images slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson 60

  12. First classifier: Nearest Neighbor Classifier Remember all training images and their labels slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson Predict the label of the most similar training image 61

  13. 62 slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  14. 63 slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  15. How do we compare the images? What is the distance metric ? slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson 64

  16. Nearest Neighbor classifier slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson 65 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 65

  17. Nearest Neighbor classifier remember the training data 66 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 66

  18. Nearest Neighbor classifier slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson for every test image: - find nearest train image with L1 distance - predict the label of nearest training 67 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 image 67

  19. Nearest Neighbor classifier Q: how does the classification speed depend on the size of slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson the training data? 68 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 68

  20. Nearest Neighbor classifier Q: how does the classification speed depend on the size of the slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson training data? linearly :( 69 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 69

  21. Aside: Approximate Nearest Neighbor find approximate nearest neighbors quickly slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson 70 Lecture 2 - Lecture 2 - 6 Jan 2016 6 Jan 2016 70

  22. 71 slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  23. k-Nearest Neighbor find the k nearest images, have them vote on the label slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson 72

  24. K-Nearest Neighbor (kNN) โ€ข Given: Training data {( ๐‘ฆ 1 , ๐‘ง 1 ),โ€ฆ, ( ๐‘ฆ n , ๐‘ง n )} โ€จ โ€“ Attribute vectors: ๐‘ฆ ๐‘— โˆˆ ๐‘Œ โ€จ โ€“ Labels: ๐‘ง ๐‘— โˆˆ ๐‘ ( ๐‘ฆ โƒ— ๏ฟฝ , ๐‘ง ๏ฟฝ , โ€ฆ , x ๏ฟฝ , ๐‘ง ๏ฟฝ ) โ€ข ๐‘ฆ โƒ— ๏ฟฝ โˆˆ ๐‘Œ โ€“ โ€ข Parameter: โ€จ ๐‘ง ๏ฟฝ โˆˆ ๐‘ โ€“ โ€“ Similarity function: ๐ฟ โˆถ ๐‘Œ ร— ๐‘Œ โ†’ R โ€จ โ€ข โ€“ Number of nearest neighbors to consider: k ๐ฟ โˆถ ๐‘Œ ร— ๐‘Œ ยก โ†’ ยกโ„œ โ€“ โ€“ โ€ข Prediction rule โ€จ โ€ข โ€“ New example ๐‘ฆโ€ฒ โ€จ โ€“ xโ€™ โ€“ K-nearest neighbors: k train examples with largest ๐ฟ ( ๐‘ฆ ๐‘— , ๐‘ฆโ€ฒ ) โƒ— ๏ฟฝ ) ๐ฟ(๐‘ฆ โƒ— ๏ฟฝ , ๐‘ฆ โ€“ slide by Thorsten Joachims 73

  25. 74 1-Nearest Neighbor slide by Thorsten Joachims

  26. 75 4-Nearest Neighbors slide by Thorsten Joachims

  27. 4-Nearest Neighbors Sign slide by Thorsten Joachims 76

  28. 4-Nearest Neighbors Sign For binary classification problems, โ€จ why is it a good idea to use an odd slide by Thorsten Joachims number of K ? 77

  29. 78 slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  30. 79 We will talk about this later! slide by Fei-Fei Li & Andrej Karpathy & Justin Johnson

  31. If we get more data โ€ข 1 Nearest Neighbor - Converges to perfect solution if clear separation - Twice the minimal error rate 2 p (1- p ) for noisy problems โ€ข k-Nearest Neighbor - Converges to perfect solution if clear separation ( but needs more data ) - Converges to minimal error min( p , 1- p ) for noisy problems if k increases 80

  32. Demo 81

  33. Weighted K-Nearest Neighbor โ€ข Given: Training data {( ๐‘ฆ 1 , ๐‘ง 1 ),โ€ฆ, ( ๐‘ฆ n , ๐‘ง n )} โ€จ โ€“ Attribute vectors: ๐‘ฆ ๐‘— โˆˆ ๐‘Œ โ€จ ๐‘ฆ โƒ— ๏ฟฝ , ๐‘ง ๏ฟฝ , โ€ฆ , ๐‘ฆ โƒ— ๏ฟฝ , ๐‘ง ๏ฟฝ โ€ข โ€“ Target attribute ๐‘ง ๐‘— โˆˆ ๐‘ ๐‘ฆ โƒ— ๏ฟฝ โˆˆ ๐‘Œ โ€“ ๐‘ง ๏ฟฝ โˆˆ ๐‘ โ€“ โ€ข Parameter: โ€จ โ€ข โ€“ Similarity function: ๐ฟ โˆถ ๐‘Œ ร— ๐‘Œ โ†’ R โ€จ ๐ฟ โˆถ ๐‘Œ ร— ๐‘Œ ยก โ†’ ยกโ„œ โ€“ โ€“ Number of nearest neighbors to consider: k โ€“ โ€ข โ€ข Prediction rule โ€จ โ€“ xโ€™ โ€“ New example ๐‘ฆโ€ฒ โ€จ โƒ— ๏ฟฝ ๐ฟ ๐‘ฆ โƒ— ๏ฟฝ , ๐‘ฆ โ€“ โ€“ K-nearest neighbors: k train examples with largest ๐ฟ ( ๐‘ฆ ๐‘— , ๐‘ฆโ€ฒ ) 82

  34. More Nearest Neighbors โ€จ in Visual Data 83

  35. Where in the World? [Hays & Efros, CVPR 2008] A nearest neighbor โ€จ recognition example slide by James Hays 84

  36. Where in the World? [Hays & Efros, CVPR 2008] slide by James Hays 85

  37. Where in the World? [Hays & Efros, CVPR 2008] slide by James Hays 86

  38. 6+ million geotagged photos โ€จ by 109,788 photographers slide by James Hays Annotated by Flickr users 87

  39. 6+ million geotagged photos โ€จ by 109,788 photographers slide by James Hays Annotated by Flickr users 88

  40. 89 89 slide by James Hays

  41. 90 Scene Matches slide by James Hays

  42. 91 slide by James Hays

  43. 92 Scene Matches slide by James Hays

  44. 93 slide by James Hays

  45. 94 Scene Matches slide by James Hays

  46. 95 slide by James Hays

  47. The Importance of Data slide by James Hays 96

  48. Scene Completion [Hays & Efros, SIGGRAPH07] slide by James Hays 97

  49. slide by James Hays โ€ฆ 200 total 98 Hays and Efros, SIGGRAPH 2007

  50. Context Matching slide by James Hays 99 Hays and Efros, SIGGRAPH 2007

  51. slide by James Hays Graph cut + Poisson blending 100 100 Hays and Efros, SIGGRAPH 2007

Recommend


More recommend