Upgrade to Pro — share decks privately, control downloads, hide ads and more …

#JJUG - Java でカジュアルにはじめる機械学習

#JJUG - Java でカジュアルにはじめる機械学習

JJUG ナイト・セミナー「機械学習・自然言語処理特集!」12/17(水)での発表資料です。

セミナー概要はこちら:
http://jjug.doorkeeper.jp/events/18378

E77287648aff5484ac7659748e45c936?s=128

KOMIYA Atsushi

December 17, 2014
Tweet

Transcript

  1. Java ͰΧδϡΞϧʹ͸͡ΊΔ ػցֶश 2014-12-17 JJUG night seminar @komiya_atsushi

  2. ͓·ͩΕ

  3. ,0.*:""UTVTIJ !LPNJZB@BUTVTIJ

  4. None
  5. None
  6. "EUFDI +BWBFOHJOFFS

  7. ࠓ೔ͷτϐοΫ

  8. ػցֶशʂ ػցֶशʂ • ػցֶशͷಋೖతͳ࿩ͱɺJava ͰΧδϡΞϧʹػ ցֶश͢Δ࿩͕ϝΠϯͱͳΓ·͢ • Ψνͷํ͸৸͍ͯͯͩͬͯ͘͞ߏ͍·ͤΜ • େن໛σʔλʹର͢Δػցֶशͷ͓࿩͸


    Ԑా͞Μʹ͓೚ͤ͠·͢ʂ • ࣗવݴޠॲཧʹ͍ͭͯ͸͡ΐʔͨʹ͞Μʹ
 ͓೚ͤ͠·͢ʂ
  9. ػցֶशΛ͸͡ΊΔલʹ ஌͓͖͍ͬͯͨ͜ͱ

  10. ػցֶशͱ͸ͳΜͧ΍ʁ ػցֶशνϡʔτϦΞϧˏ+VCBUVT$BTVBM5BMLT http://www.slideshare.net/unnonouno/jubatus-­‐casual-­‐talksΑΓҾ༻͠·ͨ͠ɻ

  11. ػցֶशͰԿ͕Ͱ͖Δͷ͔ ෼ྨɾࣝผ ༧ଌɾճؼ ύλʔϯϚΠχϯά ΞιγΤʔγϣϯϧʔϧ ΫϥελϦϯά εύϜϝʔϧͷݕ஌ χϡʔεهࣄͷΧςΰϦ෼ྨ ঎඼Ϩίϝϯσʔγϣϯ धཁɾച্༧ଌ

    ʜͳͲͳͲ
  12. ػցֶशͰԿ͕Ͱ͖Δͷ͔ ύλʔϯϚΠχϯά ΞιγΤʔγϣϯϧʔϧ ΫϥελϦϯά εύϜϝʔϧͷݕ஌ χϡʔεهࣄͷΧςΰϦ෼ྨ ঎඼Ϩίϝϯσʔγϣϯ धཁɾച্༧ଌ ڭࢣ͋Γֶश ɾਖ਼ղ͕͋Δ

    ɾʮϞσϧʯΛ࡞Δ ෼ྨɾࣝผ ༧ଌɾճؼ
  13. ػցֶशͰԿ͕Ͱ͖Δͷ͔ ࣝผɾ෼ྨ ճؼɾ༧ଌ ύλʔϯϚΠχϯά ΞιγΤʔγϣϯϧʔϧ ΫϥελϦϯά εύϜϝʔϧͷݕ஌ χϡʔεهࣄͷΧςΰϦ෼ྨ ঎඼Ϩίϝϯσʔγϣϯ धཁɾച্༧ଌ

    ڭࢣͳֶ͠श
  14. • ͲΜͳܗࣜͷσʔλͰ΋ OK ͱ͍͏Θ͚Ͱ͸ͳ͍ • ݪଇͱͯ͠਺஋ྻʢϕΫτϧʣ͔͠ѻ͑ͳ͍ • ඇߏ଄σʔλʢը૾ɺԻ੠ɺςΩετɺΞΫηεϩάɺetc.ʣ͸ͦͷ· ·Ͱ͸ѻ͑ͳ͍ •

    ඇߏ଄σʔλ͔Β͞·͟·ͳʮಛ௃ྔʯΛநग़ͯ͠ʮಛ௃ϕΫτϧʯΛ ࡞Δ • ΧςΰϦΧϧม਺͸μϛʔม਺Ͱදݱ͢Δ • εέʔϦϯά • feature engineering • ڭࢣ͋Γֶशͷ܇࿅σʔλͷ৔߹͸ɺՃ͑ͯʮϥϕϧʯͳͲਖ਼ղ৘ใΛ ෇༩͢Δ ԿΛೖྗσʔλͱ͢Δͷ͔
  15. ಘΒΕͨ݁Ռ͸ਖ਼͍͠ͷ͔ • ਖ਼͠͞Λ͔֬ΊΔ • k-෼ׂަࠩݕূ (k-fold cross validation) • ਖ਼͠͞ΛଌΔ

    • ෼ྨɾࣝผ • Precision, Recall, AUC, F-measure • ༧ଌɾճؼ • ૬ؔ܎਺ɺܾఆ܎਺ɺMAE, RMSE
  16. ઢܗ෼཭ɾඇઢܗ • Ұຊͷઢʢ௒ฏ໘ʣͰ఺ʢಛ௃ϕΫτϧʣΛ෼཭Ͱ͖Δ͔ʁ ઢܗ෼཭Մೳ ઢܗ෼཭ෆՄೳ ඇઢܗ

  17. ΦϯϥΠϯֶशɾΦϑϥΠϯֶश • ΦϯϥΠϯֶश • ஞ࣍ಘΒΕΔσʔλΛ΋ͱʹɺϞσϧΛਵ࣌ߋ৽͢Δ • ετϦʔϜॲཧతͳΠϝʔδ • ར༻ͨ͠σʔλ͸஝ੵ͢Δ͜ͱͳ͘ഁغͰ͖Δ •

    ʢઍ੾ͬͯ͸౤͛ɺઍ੾ͬͯ͸౤͛…ʣ • ΦϑϥΠϯֶश • ஝ੵ͞ΕͨσʔλΛ΋ͱʹɺϞσϧΛҰؾʹߋ৽͢Δ • όονॲཧʹ૬౰͢Δ
  18. Java Ͱػցֶश͢Δ

  19. ࠷ॳʹ͜Ε͚ͩ͸ ݴ͓͖͍ͬͯͨ

  20. ंྠͷ࠶ൃ໌͸΍ΊΑ͏

  21. طଘͷϥΠϒϥϦ౳Λ ׆༻͠Α͏

  22. ػցֶशͷ࣮૷ɺਏΈ͔͠ͳ͍ • ػցֶशΞϧΰϦζϜͷςετɺͱʹ͔͘ਏ͍ • ʮςετॻ͔ͳ͍ͱ͔͓લ̋̋ͷલͰ΋ಉ͜͡ͱ ݴ͑Μͷʁʯ • ࣌ؒɾۭؒޮ཰ͷΑ͍࣮૷͸໘౗ɾ೉͍͠ • the

    state of the art ͳΞϧΰϦζϜΛ࣮૷͢Δͷ΋ɺ େ෯ͳਫ਼౓޲্͕ݟࠐΊΔ৔߹ʹཹΊ͍ͨ • طଘϥΠϒϥϦ౳Λ࢖͏͚ͩͰ͸Ͳ͏ͯ͠΋ղܾͰ ͖ͳ͍৔߹ʹͷΈɺࣗલ࣮૷͢ΔΑ͏ʹ͍ͨ͠
  23. Java ʹΑΔػցֶश ޲͖ෆ޲͖

  24. ྫ͑͹͜ΜͳϫʔΫϑϩʔ 1. ର৅ͱ͢Δ໰୊Λೝࣝ͢Δ • ͲͷΑ͏ͳλεΫ͕߹͏ͷ͔ʁ 2. อ༗͍ͯ͠Δσʔλʹ͍ͭͯཧղΛਂΊΔ • ͲͷΑ͏ͳಛ௃ྔ͕நग़Ͱ͖Δͷ͔ʁ 3.

    ϞσϧΛ࡞੒͢Δ • ͲͷΞϧΰϦζϜΛར༻͢΂͖͔ʁ • Ͳͷಛ௃ྔΛར༻͢΂͖͔ʁ 4. ࡞੒ͨ͠ϞσϧΛධՁ͢Δ • ਫ਼౓͸͍͔΄Ͳ͔ʁ 5. γεςϜʹ૊ΈࠐΉɾγεςϜԽ͢Δ
  25. ྫ͑͹͜ΜͳϫʔΫϑϩʔ 1. ର৅ͱ͢Δ໰୊Λೝࣝ͢Δ • ͲͷΑ͏ͳλεΫ͕߹͏ͷ͔ʁ 2. อ༗͍ͯ͠Δσʔλʹ͍ͭͯཧղΛਂΊΔ • ͲͷΑ͏ͳಛ௃ྔ͕நग़Ͱ͖Δͷ͔ʁ 3.

    ϞσϧΛ࡞੒͢Δ • ͲͷΞϧΰϦζϜΛར༻͢΂͖͔ʁ • Ͳͷಛ௃ྔΛར༻͢΂͖͔ʁ 4. ࡞੒ͨ͠ϞσϧΛධՁ͢Δ • ਫ਼౓͸͍͔΄Ͳ͔ʁ 5. γεςϜʹ૊ΈࠐΉɾγεςϜԽ͢Δ ͜ͷ͋ͨΓͰ ػցֶशΛ ׆༻͢Δ
  26. ྫ͑͹͜ΜͳϫʔΫϑϩʔ 1. ର৅ͱ͢Δ໰୊Λೝࣝ͢Δ • ͲͷΑ͏ͳλεΫ͕߹͏ͷ͔ʁ 2. อ༗͍ͯ͠Δσʔλʹ͍ͭͯཧղΛਂΊΔ • ͲͷΑ͏ͳಛ௃ྔ͕நग़Ͱ͖Δͷ͔ʁ 3.

    ϞσϧΛ࡞੒͢Δ • ͲͷΞϧΰϦζϜΛར༻͢΂͖͔ʁ • Ͳͷಛ௃ྔΛར༻͢΂͖͔ʁ 4. ࡞੒ͨ͠ϞσϧΛධՁ͢Δ • ਫ਼౓͸͍͔΄Ͳ͔ʁ 5. γεςϜʹ૊ΈࠐΉɾγεςϜԽ͢Δ ͜ͷ͋ͨΓ͸ ΞυϗοΫͳ ෼ੳ͕ඞཁ
  27. ྫ͑͹͜ΜͳϫʔΫϑϩʔ 1. ର৅ͱ͢Δ໰୊Λೝࣝ͢Δ • ͲͷΑ͏ͳλεΫ͕߹͏ͷ͔ʁ 2. อ༗͍ͯ͠Δσʔλʹ͍ͭͯཧղΛਂΊΔ • ͲͷΑ͏ͳಛ௃ྔ͕நग़Ͱ͖Δͷ͔ʁ 3.

    ϞσϧΛ࡞੒͢Δ • ͲͷΞϧΰϦζϜΛར༻͢΂͖͔ʁ • Ͳͷಛ௃ྔΛར༻͢΂͖͔ʁ 4. ࡞੒ͨ͠ϞσϧΛධՁ͢Δ • ਫ਼౓͸͍͔΄Ͳ͔ʁ 5. γεςϜʹ૊ΈࠐΉɾγεςϜԽ͢Δ +BWBʹ޲͍ͯ ͍Δͷ͸ ͜ͷ͋ͨΓ
  28. దࡐదॴͰ͍͜͏ • Java ͰػցֶशΛ༻͍ͨΞυϗοΫ෼ੳ͕Ͱ͖ͳ͍Θ͚Ͱ͸ͳ͍͕ɺR ͳͲΛ࢖͏ํ͕Ұൠతʢʁʣ • ෼ੳΛ͢ΔͨΊʹಛԽͨ͠؀ڥ͕޲͍͍ͯΔ • Java ͩͱ

    Weka ͱ͔ Spark ͷΠϯλϥΫςΟϒͳίϯιʔϧͱ͔ • Java Ͱૉ௚ʹίʔυΛॻ͍ͯϏϧυͯ͠ɺ࠷ॳ͔Β࣮ߦ… Έ͍ͨͳ ͷ͸खֻ͕͔ؒΓա͗Δ • ҰํͰ R ͸ R ͰɺγεςϜԽʹ͸޲͔ͳ͍ • HTTP ϦΫΤετΛड͚ͯɺαʔό಺ͰϦΞϧλΠϜͰػցֶशͨ͠ ͍… Έ͍ͨͳγεςϜΛ࡞Γ͍ͨ৔߹ͳͲ
  29. Java ͔Β࢖͑Δ ػցֶशϥΠϒϥϦͳͲ

  30. liblinear-java • gradle ‘de.bwaldvogel:liblinear:1.95' • https://github.com/bwaldvogel/liblinear-java • ˒ 121 •

    LibSVM Λઢܗ෼ྨɾճؼʹಛԽͨ͠΋ͷɺͷ Java ϙʔ ςΟϯά • ϥΠϒϥϦ • ΘΓͱؤுͬͯɺຊମ (C++ ൛) ͷ࠷৽όʔδϣϯʹ௥ै ͠Α͏ͱ͍ͯ͠Δ
  31. Weka • gradle ‘nz.ac.waikato.cms.weka:weka-stable: 3.6.11' • ଟछଟ༷ͳػցֶशΞϧΰϦζϜ͕ఏڙ͞Ε ͍ͯΔ෼ੳϓϥοτϑΥʔϜ • ϥΠϒϥϦͱͯ͠΋ར༻͢Δ͜ͱ͕Ͱ͖Δ

    • ͱΓ͋͑ͣػցֶशΛ͸͡ΊͯΈΔͳΒɺ
 ·ͣ͸͜Ε͔Β
  32. MLlib (Spark) • gradle ‘org.apache.spark:spark-mllib_2.10:1.1.1' • https://github.com/apache/spark • ˒ 2,336

    • ෼ࢄॲཧϑϨʔϜϫʔΫ Spark ্Ͱͷར༻Λલఏͱͨ͠ ϥΠϒϥϦ • ػೳ௥Ճɾվળ͕ࠓͩ੝Μ • ΞυϗοΫ෼ੳͷ؀ڥͱͯ͠΋ར༻Ͱ͖Δʢ͸ͣʣ • ৄ͍͠࿩͸͜ͷޙͷԐా͞ΜτʔΫʹظ଴ʂ
  33. Mahout • gradle ‘org.apache.mahout:mahout-core:0.9' • https://github.com/apache/mahout • ˒ 229 •

    ෼ࢄॲཧϑϨʔϜϫʔΫ Hadoop ্ͷػցֶशϥ ΠϒϥϦ • Spark / MLlib ͕ग़͖͔ͯͯΒ͍ͩͿΦϫίϯײ͕ ᕷΈग़͖ͯͨؾ͕…
  34. SAMOA • https://github.com/yahoo/samoa • ˒ 363 • Storm ͳͲͷ෼ࢄετϦʔϛϯάϑϨʔϜ ϫʔΫ্Ͱར༻Ͱ͖ΔػցֶशϥΠϒϥϦ

    • Yahoo! Labs ۘ੡ • ̎͜͜ʙ̏ϲ݄͸͋·Γ։ൃ׆ൃͰͳ͍ʁ
  35. Jubatus • https://github.com/jubatus/jubatus • ˒ 389 • ෼ࢄॲཧϑϨʔϜϫʔΫˍΦϯϥΠϯػցֶशϥΠϒ ϥϦ •

    ຊମ͸ C++ ࣮૷͕ͩɺJava ͷΫϥΠΞϯτϥΠϒϥ Ϧ͕ఏڙ͞Ε͍ͯΔ • ϦΞϧλΠϜॲཧͳػցֶश͕ཁٻ͞ΕΔ৔߹ʹద͠ ͍ͯΔʁ
  36. h2o • https://github.com/h2oai/h2o • ˒ 1,333 • ෼ࢄॲཧϑϨʔϜϫʔΫ Hadoop ্Ͱར༻Ͱ

    ͖ΔػցֶशϥΠϒϥϦ • Կ͔ͱ࿩୊ͷ Deep learning Λ Java Ͱ͍ͨ͠ ͳΒɺ͜Ε୒Ұʂʁ
  37. ͸͡ΊͯΈΑ͏ػցֶश

  38. σʔληοτ

  39. UCI Machine learning repository • https://archive.ics.uci.edu/ml/datasets.html • ͍͍ͩͨ CSV ϑΝΠϧͰఏڙ͞Ε͍ͯΔ

    • ୅දతͳσʔληοτ • Mushroom: Ωϊί • ৭ɾܗঢ়ɾେ͖͞ͱ৯༻ɾ༗ಟͷϥϕϧ / ೋ஋෼ྨ • Iris: ΞϠϝσʔλ • ͕͘΍Ֆหͷ෯ɾ௕͞ͱ඼छͷϥϕϧ / ଟ஋෼ྨ • Abalone: ΞϫϏ • େ͖͞΍ॏ͞ͳͲͱ೥ྸ / ೥ྸͷ༧ଌ
  40. Weka Ͱ෼ྨɾճؼͯ͠ΈΔ

  41. http://bit.ly/jjug-­‐ml

  42. Weka ͷೖྗܗࣜ @RELATION iris @ATTRIBUTE sepallength NUMERIC @ATTRIBUTE sepalwidth NUMERIC

    @ATTRIBUTE petallength NUMERIC @ATTRIBUTE petalwidth NUMERIC @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica} ! @DATA 5.1,3.5,1.4,0.2,Iris-setosa 4.9,3.0,1.4,0.2,Iris-setosa 4.7,3.2,1.3,0.2,Iris-setosa 4.6,3.1,1.5,0.2,Iris-setosa 5.4,3.9,1.7,0.4,Iris-setosa …… "3''ϑΝΠϧ
  43. Weka ͷೖྗܗࣜ @RELATION iris @ATTRIBUTE sepallength NUMERIC @ATTRIBUTE sepalwidth NUMERIC

    @ATTRIBUTE petallength NUMERIC @ATTRIBUTE petalwidth NUMERIC @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica} ! @DATA 5.1,3.5,1.4,0.2,Iris-setosa 4.9,3.0,1.4,0.2,Iris-setosa 4.7,3.2,1.3,0.2,Iris-setosa 4.6,3.1,1.5,0.2,Iris-setosa 5.4,3.9,1.7,0.4,Iris-setosa …… "3''ϑΝΠϧ $47ϑΝΠϧΛΘ͟Θ͟ม׵͢Δͷ΋໘౗ʜ
  44. ࠓճ͸ weka.core.converters.CSVLoader (Λͪΐͬͱ͍ͬͨ͡΋ͷ) Λ࢖͍·͢

  45. ར༻͍ͯ͠ΔΫϥεͷղઆ • weka.classifiers.Evaluation • k-෼ׂަࠩݕূΛ࣮ࢪ͢Δ • weka.classifiers.functions.Logistic • ϩδεςΟοΫճؼʹΑΔ෼ྨ •

    weka.classifiers.trees.RandomForest • RandomForest (ܾఆ໦ͷྨ) ʹΑΔ෼ྨ • weka.classifiers.functions.LinearRegression • ઢܗճؼ
  46. ࣮ࡍʹσϞͯ͠Έ·͢

  47. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ