Amazon Machine Learning を使ってみた

Amazon Machine Learning を使ってみた

画面を指さしながら説明するために作った背景画像の上に、簡単な説明テキストを追加したやつです。

7cca11c5257fda526eeb4b1ada28f904?s=128

Kenta Murata

April 21, 2015
Tweet

Transcript

  1. Amazon ML Λ
 ࢖ͬͯΈͨ Kenta Murata 2015.04.21

  2. ػցֶश

  3. ػցֶशͰͰ͖Δ͜ͱ 1. ճؼ 2. ෼ྨ 3. ΫϥελϦϯά

  4. ػցֶशͰͰ͖Δ͜ͱ 1. ճؼ 2. ෼ྨ 3. ΫϥελϦϯά → ࣮਺஋ͷ༧ଌ http://commons.wikimedia.org/wiki/File:Linear_regression.svg

    http://commons.wikimedia.org/wiki/File:Polyreg_scheffe.svg
  5. ػցֶशͰͰ͖Δ͜ͱ 1. ճؼ 2. ෼ྨ 3. ΫϥελϦϯά → ࣮਺஋ͷ༧ଌ →

    ͔̋×͔Λ༧ଌ http://en.wikipedia.org/wiki/File:SVM_with_soft_margin.pdf
  6. ػցֶशͰͰ͖Δ͜ͱ 1. ճؼ 2. ෼ྨ 3. ΫϥελϦϯά → ࣮਺஋ͷ༧ଌ →

    ͔̋×͔Λ༧ଌ → ࣗಈάϧʔϓ෼͚ http://commons.wikimedia.org/wiki/File:KMeans-density-data.svg
  7. Amazon Machine Learning

  8. Amazon Machine Learning ͰͰ͖Δ͜ͱ 1. ճؼ 2. ೋ஋෼ྨ 3. ଟ஋෼ྨ

  9. Amazon Machine Learning ͰͰ͖Δ͜ͱ 1. ճؼ 2. ೋ஋෼ྨ 3. ଟ஋෼ྨ

    ΍ͬͯΈͨ
  10. Amazon Machine Learning Ͱ
 ଟ஋෼ྨثΛ࡞Δ

  11. σʔλͷ४උ ↓ σʔλιʔε࡞੒ ↓ Ϟσϧ࡞੒ ↓ (σʔλιʔεͷࣗಈ෼ׂ) ↓ Ϟσϧͷֶश ↓

    ϞσϧͷධՁ ଟ஋෼ྨثͷ࡞੒खॱ
  12. σʔλͷ४උ

  13. None
  14. 70,000ݸͷखॻ͖਺ࣈ http://myselph.de/neuralNet.html 28px 28px

  15. 60,000ݸ → ֶश༻ 10,000ݸ → ධՁ༻ ֶश༻ͱධՁ༻ʹ༧Ί෼͚ͯ഑෍͞Ε͍ͯΔ

  16. όΠφϦσʔλͳͷͰ CSV ΁ม׵͢Δ

  17. 28px 28px y, x1, x2,ɾɾɾ, x_k,ɾɾɾ, x784 8, 0, 0,ɾɾɾ,

    221,ɾɾɾ, 0 256֊ௐάϨΠεέʔϧ ਖ਼ղϥϕϧ ϐΫηϧ஋
  18. μ΢ϯϩʔυ͢Δ

  19. https://rubygems.org/gems/mnist

  20. $ gem install mnist $ mnist2csv train-images-idx3-ubyte.gz train-labels-idx1-ubyte.gz > mnist_train.csv

    $ mnist2csv t10k-images-idx3-ubyte.gz t10k-labels-idx1-ubyte.gz > mnist_test.csv
  21. CSV ϑΝΠϧΛ S3 ʹΞοϓϩʔυ͢Δ

  22. σʔλιʔεΛ࡞Δ

  23. None
  24. Ξοϓϩʔυͨ͠
 CSV ϑΝΠϧ

  25. None
  26. None
  27. None
  28. None
  29. ෼ྨର৅ͷΧϥϜΛબ୒ͯ͠Ͷὑ

  30. σʔλΛݟͯࣗಈ൑ఆ

  31. ༧ଌ݁Ռ͕σʔλιʔεͷͲͷߦʹରԠ͢Δ͔Λ
 ࣝผ͢ΔͨΊͷ ID ͕͋Ε͹ࢦఆ͢Δ ࠓճ͸ແ͍ͷͰࢦఆ͠ͳ͍

  32. None
  33. None
  34. None
  35. None
  36. ϞσϧΛ࡞Δ

  37. None
  38. ೖྗσʔλΛબ୒

  39. બͿ

  40. None
  41. None
  42. σʔλΛ 7:3 ʹ෼ׂͯ͠ 7 ͷํΛ܇࿅ʹɺ3 ͷํ ΛϞσϧͷධՁʹ࢖͏

  43. ͍Ζ͍Ζࣗ෼Ͱࢦఆ͢Δ ࠓճ͸ͬͪ͜

  44. None
  45. σʔλͷલॲཧํ๏ͳͲ Λ JSON Ͱࢦఆ͢Δ ϑΟʔϧυɻ ࠓճ͸ CSV ʹม׵ͨ͠ ͚ͩͰલॲཧ͕׬ྃͯ͠ ΔͷͰσϑΥϧτͷ··

    Ͱ͓̺
  46. None
  47. Regularization (ਖ਼ଇԽ) ͸ɺϞσϧͷաֶश (܇࿅σʔ λʹద߹͗ͯ͢͠͠·͏ࣄ) Λ๷͙ͨΊʹߦ͏ɻ L1 (Lasso ճؼ) ͸ɺෆཁͳύϥϝʔλΛ࡟ͬͯϞσϧΛ

    γϯϓϧʹ͍ͨ͠ͱ͖ʹ࢖͏ɻ L2 (Ridge ճؼ) ͸׈Β͔ͳϞσϧ͕ཉ͍͠ͱ͖ʹ࢖͏ɻ (ײ૝: L1 ͱ L2 ΛࠞͥΒΕΕ͹΋ͬͱྑ͍ͷʹ)
  48. None
  49. Ϟσϧͷ࡞੒ޙʹࣗಈతʹධՁ΋࣮ࢪ͢Δ͔Ͳ͏͔ɻ ࠓճ͸ผʹධՁΛ΍ΔͷͰ No ΛબͿɻ

  50. None
  51. None
  52. ϞσϧΛ࡞Δ

  53. ֶशδϣϒ͸ࣗಈతʹ։࢝͢Δ

  54. None
  55. 60,000 ڭࢣσʔλ → ໿20෼

  56. ϞσϧΛධՁ͢Δ

  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. None
  64. 10,000 ςετσʔλ → 1ʙ2෼

  65. None
  66. ҎԼͷࣜͰܭࢉ͞ΕΔϞσϧͷ༏ल͞ΛଌΔྔ 2 × ద߹཰ × ࠶ݱ཰
 ద߹཰ + ࠶ݱ཰

  67. ਅͷ෼ྨ 1 ͦͷଞ ༧
 ଌ
 ݁
 Ռ 1 True Positive

    False Positive ͦ
 ͷ
 ଞ False Negative True Negative ద߹཰ ʹ ࠶ݱ཰ ʹ True Positive
 True Positive + False Positive True Positive
 True Positive + False Negative TP FP FN TN TP FP FN TN
  68. None
  69. 1,000 ڭࢣσʔλͰ࡞ͬͨϞσϧͷ৔߹

  70. None
  71. ڭࢣσʔλ͕ଟ͍΄ͲϞσϧͷੑೳ͕ྑ͘ͳΔ

  72. ϞσϧΛ࢖͏

  73. Ϟσϧͷ࢖͍ํ 1. όον༧ଌ 2. ϦΞϧλΠϜ༧ଌ

  74. Ϟσϧͷ࢖͍ํ 1. όον༧ଌ 2. ϦΞϧλΠϜ༧ଌ → ·ͱ·ͬͨσʔλΛ·ͱΊͯ༧ଌ

  75. Ϟσϧͷ࢖͍ํ 1. όον༧ଌ 2. ϦΞϧλΠϜ༧ଌ → ·ͱ·ͬͨσʔλΛ·ͱΊͯ༧ଌ → API Λ࢖ͬͯ1ͭͣͭ༧ଌ

  76. Amazon Machine Learning ͷྉۚମܥ

  77. Amazon Machine Learning ͷྉۚମܥ

  78. 1,000 σʔλͰϞσϧΛ࡞ͬͨͱ͖

  79. 70,000 σʔλͰϞσϧΛ࡞ͬͨͱ͖

  80. S3 price

  81. Amazon Machine Learning Λ࢖ͬͯΈͨײ૝ 1. Α͘Ͱ͖ͯΔ 2. ͬ͘͞ͱϓϩτλΠϓ͍ͨ࣌͠ʹศརͦ͏ 3. ֶशࡁΈͷϞσϧΛΤΫεϙʔτͰ͖ͳ͍

  82. Amazon Machine Learning Λ࢖ͬͯΈͨײ૝ 1. Α͘Ͱ͖ͯΔ 2. ͬ͘͞ͱϓϩτλΠϓ͍ͨ࣌͠ʹศརͦ͏ → ΞϧΰϦζϜΛදʹग़ͣ͞ʹ্ख͘؆ུԽͯ͠Δ

    3. ֶशࡁΈͷϞσϧΛΤΫεϙʔτͰ͖ͳ͍
  83. Amazon Machine Learning Λ࢖ͬͯΈͨײ૝ 1. Α͘Ͱ͖ͯΔ 2. ͬ͘͞ͱϓϩτλΠϓ͍ͨ࣌͠ʹศརͦ͏ → ΞϧΰϦζϜΛදʹग़ͣ͞ʹ্ख͘؆ུԽͯ͠Δ

    → ࣮ӡ༻લʹ༷ʑͳಛ௃ϕΫτϧΛ؆୯ʹࢼͤΔ 3. ֶशࡁΈͷϞσϧΛΤΫεϙʔτͰ͖ͳ͍
  84. Amazon Machine Learning Λ࢖ͬͯΈͨײ૝ 1. Α͘Ͱ͖ͯΔ 2. ͬ͘͞ͱϓϩτλΠϓ͍ͨ࣌͠ʹศརͦ͏ → ΞϧΰϦζϜΛදʹग़ͣ͞ʹ্ख͘؆ུԽͯ͠Δ

    → ࣮ӡ༻લʹ༷ʑͳಛ௃ϕΫτϧΛ؆୯ʹࢼͤΔ 3. ֶशࡁΈͷϞσϧΛΤΫεϙʔτͰ͖ͳ͍ → ࣮ӡ༻࣌͸ࣗ෼Ͱ࣮૷ͨ͠ϞσϧΛ࢖͏
 ɹ ϓϩτλΠϓͰ্ख͘ߦ͖ͦ͏ͳ͜ͱ͕
 ɹ ෼͔ͬͯΔͷͰ࣮૷ίετ΋ؾʹͳΒͳ͍!?