Kaggle Rコンペ解法紹介

Kaggle Rコンペ解法紹介

Kaggle Tokyo Meetup 裏 #01

99e9e6d2de62c373990ac1bd7c4defc5?s=128

Shuhei Goda

July 13, 2019
Tweet

Transcript

  1. (PPHMF"OBMZUJDT$VTUPNFS3FWFOVF1SFEJDUJPO 1VCMJDTU4PMVUJPOCFGPSFUIFDPNQFUJUJPOSFMBVODI ,BHHMFཪ.FFUVQ IBLVCJTIJO 8FMDPNFUP(PPHMF"OBMZUJDT $VTUPNFS3FWFOVF1SFEJDUJPO 1

  2. ࣗݾ঺հ !2 ໊લIBLVCJTIJO डୗ෼ੳձࣾͷσʔλαΠΤϯςΟετ ,BHHMFྺ  ࠓ೔࿩͢ίϯϖ

  3. ίϯϖͷ֓ཁ !3 w ಺༰  (PPHMF.FSDIBOEJTF4UPSFͷސ٬͋ͨΓͷऩӹΛ༧ଌ͢Δ w ։࠵ظؒ  ʙ

    w ࢖༻σʔλʹ͍ͭͯ  (PPHMFBOBMZUJDTͰऔಘͰ͖Δσʔλ  ֎෦σʔλΛ࢖༻Մೳ w ͦͷଞ  ௨শ3ίϯϖʢओ࠵͕3TUVEJPʣ
  4. w 3.4&  Z@IBUJTUIFOBUVSBMMPHPGQSFEJDUFESFWFOVFGPSBDVTUPNFS  ZJTUIFOBUVSBMMPHPGUIFBDUVBMTVNNFESFWFOVFWBMVFQMVTPOF ධՁࢦඪ !4

  5. w (PPHMF"OBMZUJDT͔ΒऔಘͰ͖Δσʔλͷ͏ͪҰ෦͕ఏڙ͞ΕΔ  LFZ͸ GVMMWJTJUPS*E WJTJU*E σʔλͷ֓ཁ !5 ม਺໊ ಺༰

    ܕ GVMMWJTJUPS*E ϢʔβʔͷJE  WJTJU*E ηογϣϯͷJE  EBUF ηογϣϯͷ೔෇ %BUF USBOTBDUJPO3FWFOVF ηογϣϯதͷऩӹ /VNFSJD EFWJDF Ϣʔβʔͷ୺຤৘ใ $BUFHPSZ USB⒏D4PVSDF τϥϑΟοΫͷࢀরݩ৘ใ $BUFHPSZ HFP/FUXPSL ϢʔβʔͷҐஔ৘ใ $BUFHPSZ UPUBMT ηογϣϯதͷΞΫγϣϯʹؔ͢Δूܭ৘ใ /VNFSJD
  6. w USBJOͷظؒʙ w UFTUͷظؒʙ  ༧ଌ஋͸VTFS୯ҐͰࢉग़͢ΔͨΊɺQVCMJDͱQSJWBUFͷظؒ͸Ұக USBJOUFTUظؒ !6  

    5SBJOʢ೥ʣ 5FTUʢϲ݄ʣ 
  7. ίϯϖͷܦҢ

  8. MPHTVNPSTVNMPH໰୊ !8 w ධՁࢦඪ͸ʮMPHTVNʯͰ͋Δ͕ɺԿނ͔ʮTVNMPHʯͰग़ྗͨ݁͠Ռͷ ํ͕-#είΞ͕ྑ͘ͳΔɻ ˣܭࢉ͸ਖ਼࣮͘͠ߦ͞Ε͍ͯΔΒ͍͠

  9. -FBEFSCPBSE6QEBUF ճ໨ !9 w ӡӦଆͷϛεʹΑΓɺʮTVNMPHʯͰ-#͕ܭࢉ͞Ε͍ͯͨ͜ͱ͕൑໌

  10. 1VCMJD-#PWFSpUUJOH !10 w ͳΜ͔ͩΜͩͰ࢑ఆҐʹͳͬͯتͿ

  11. -FBLൃ֮ !11 w ωοτʹస͕͍ͬͯͨίϯϖσʔλ  (PPHMF"OBMZUJDTͷσϞΞΧ΢ϯτΛ࢖ͬͯऔಘՄೳ  UFTUͷظؒ͸ίϯϖ։࠵࣌ΑΓ΋લͰɺUFTUͷ৘ใ΋औಘͰ͖Δ

  12. -FBEFSCPBSE6QEBUF ճ໨ w σʔλظؒΛ৭ʑͱมߋͯ͠࠶ελʔτ   5SBJOʢ೥ϲ݄ʣ 1VCMJD ʢ̒ϲ݄ʣ 

    1SJWBUF ʢϲ݄ʣ     5SBJOʢ೥ʣ 5FTU ʢϲ݄ʣ  !12 ࠶ελʔτޙͷઃఆ ࠷ॳͷઃఆ
  13. ղ๏঺հ

  14. Ϟσϧͷશମ૾ !14 w ηογϣϯ୯ҐͷϞσϧͱϢʔβʔ୯ҐͷϞσϧͷΞϯαϯϒϧ ηογϣϯ୯ҐͷϞσϧ MJHIUHCN  ηογϣϯຖͷऩӹΛ༧ଌ Ϣʔβʔ୯ҐͷϞσϧ MJHIUHCN

     Ϣʔβʔຖͷ૯ऩӹΛ༧ଌ Ϣʔβʔ୯ҐͷϞσϧ MJHIUHCN  લஈͷ༧ଌ஋ͷجૅ౷ܭྔΛ
 ಛ௃ྔͱͯ͠࢖༻ ΞϯαϯϒϧʢFMBTUJDOFUTUBDLJOHʣ 1PTUQSPDFTTJOH
 UPUBMCPVODFT
  15. w ࣌ؒํ޲Ͱަࠩݕূ͢ΔͷͰ͸ͳ͘ɺϢʔβʔຖʹ۠੾࣮ͬͯࢪ  ηογϣϯ୯ҐͷϞσϧˠ(SPVQ,'PMEʢϢʔβʔͰ੾Δʣ  Ϣʔβʔ୯ҐͷϞσϧˠ,'PMEʢηογϣϯ୯ҐϞσϧʹ߹ΘͤΔʣ  ཧ༝ͱͯ͠͸ 㾎ΞϯαϯϒϧͷͨΊʹɺUSBJOσʔλͷશϢʔβʔͷPPG WBMVF

    USBJOظؒதͷ༧ଌऩӹͷ૯࿨ ͕ཉ͍͠ 㾎UJNFTQMJU΋࠷ॳͷஈ֊Ͱࢼ͍ͯ͠Δɻൺֱͨ݁͠ՌɺHSPVQLGPME Ͱ΋໰୊ͳͦ͞͏ͩͬͨ 㾎QVCMJDͱQSJWBUFͷظؒ͸ಉ͡ͳͷͰɺίϯαόʹWBMJEBUJPOΛઃఆ ͠ͳͯ͘΋໰୊ͳ͍ͩΖ͏ͱ൑அʢQVCMJDΛ౰ͯʹ͍͚͹ྑ͍ʣ $7ʹ͍ͭͯ !15
  16. w ͲͷΧςΰϦ৘ใ΋ׂͱϊΠδʔ  ެ։LFSOFMͷ໊دͤॲཧͷ࠾༻ʴखಈ໊دͤΛ࣮ࢪ  ޙͷಛ௃ྔ࡞੒Ͱޮ͍ͯ͘Δ෦෼ɺ͜͜ʹҰ൪࣌ؒΛ͔͚ͨ ΧςΰϦσʔλͷ໊دͤ !16 lEFWJDFPQFSBUJOH4ZTUFNzͷྫ

  17. w ΧςΰϦσʔλͷಛ௃ྔ  EFWJDFܥɺUSB⒏D4PVSDFܥ͸໊دͤͯ͠ΧςΰϦม਺Խ  ਺஋σʔλΛΧςΰϦຖʹू໿ͯ͠ΤϯίʔσΟϯά  ΧςΰϦม਺ͷຒΊࠐΈදݱʢ-%"ʣ  5BSHFUFODPEJOH

     'SFRVFODZFODPEJOH w ਺஋σʔλͷಛ௃ྔ  UPUBMܥCPVODFT IJUT QBHFWJFXT IJUT QBHFWJFXT  #BTJD'FBUVSFʢηογϣϯ୯Ґʣ !17
  18. w ಛ௃ྔੜ੒ର৅ϨίʔυͷηογϣϯΛى఺ͱͯ͠ɺ௚ۙ௚ޙͷ৘ใΛ ू໿ͯ͠ಛ௃ྔͱͯ͠࠾༻͢Δ  ݱ࣌఺ͷηογϣϯ͔Βকདྷ·ͨ͸աڈO೔ؒʹ͓͚Δ๚໰ճ਺  ݱ࣌఺ͷηογϣϯ͔Βকདྷ·ͨ͸աڈO೔ؒʹ͓͚ΔIJUT  QBHFWJFXTͷ૯࿨ 

    ͭઌ·ͨ͸ͭޙͷηογϣϯ·Ͱͷܦա࣌ؒ 5JNF'FBUVSFʢηογϣϯ୯Ґʣ !18
  19. w ΧςΰϦσʔλͷಛ௃ྔ  FODPEJOH͔ͯ͠ΒϢʔβʔຖʹू໿ w ਺஋σʔλͷಛ௃ྔ  UPUBMܥCPVODFT IJUT QBHFWJFXT

    IJUT QBHFWJFXT  Λ
 Ϣʔβʔ୯Ґʹू໿ #BTJD'FBUVSFʢϢʔβʔ୯Ґʣ !19
  20. w ηογϣϯͷ࣌ؒ৘ใͷू໿  65$ɺ-PDBM5JNFͷEBUF৘ใ EBZPGXFFL IPVS EBZ ΛɺDPT TJOʹ ෼ղ͔ͯ͠Βू໿

    5JNF'FBUVSFʢϢʔβʔ୯Ґʣ !20
  21. w ηογϣϯͷ߹ܭώοτ਺ͱ߹ܭϖʔδϏϡʔ਺ͷൺ཰  $7͸্͕Δ͕-#͸Լ͕Δ  EJTDVTTJPOͷ౤ߘΛݟͯ΋ɺଞͷࢀՃऀ΋ಉ༷ͷݱ৅  ཧ༝͸݁ہෆ໌͕ͩɺQBHFWJFXTIJUTSBUJPʹؔ͢Δಛ௃ྔΛݢฒ Έআ֎͢Δ͜ͱͰ-#͕େ্͖͘ঢ QBHFWJFXTIJUTSBUJPಛ௃ྔͷআ֎

    !21 IUUQTXXXLBHHMFDPNDHBDVTUPNFSSFWFOVFQSFEJDUJPOEJTDVTTJPOMBUFTU
  22. w CPVODFTͷ৘ใΛ࢖༻ͨ͠ޙॲཧ  ίϯϖॳظ͔Βग़͍ͯͨ৘ใ  ηογϣϯͷ௚ؼ৘ใϑϥάʢUPUBMTCPVODFTʣཱ͕͍ͬͯΔ͔Ͳ͏ ͔Ͱऩӹ͕͋Δ͔ͳ͍͔͕൑அՄೳ  ϑϥάཱ͕͍ͬͯΔηογϣϯͷऩӹ༧ଌ஋Λʹஔ׵ 1PTUQSPDFTTJOH

    !22 IUUQTXXXLBHHMFDPNDHBDVTUPNFSSFWFOVFQSFEJDUJPOEJTDVTTJPOMBUFTU