Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
輪講 The hundred ML3.3-3.5
Search
ganyariya
June 23, 2020
Programming
0
84
輪講 The hundred ML 3.3-3.5
https://github.com/tsukuba-mas/The_Hundred_ML
ganyariya
June 23, 2020
Tweet
Share
More Decks by ganyariya
See All by ganyariya
FastAPI+VercelでZennのバッジをお手軽に作る
ganariya
0
820
The Hundred Machine Learning 7.4-7.7
ganariya
0
51
ありがとう競技プログラミングこんにちはDocker
ganariya
0
1.5k
Other Decks in Programming
See All in Programming
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
690
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
cmp.Or に感動した
otakakot
3
190
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Remix on Hono on Cloudflare Workers
yusukebe
1
290
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
330
Featured
See All Featured
Being A Developer After 40
akosma
87
590k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
How STYLIGHT went responsive
nonsquared
95
5.2k
Documentation Writing (for coders)
carmenintech
65
4.4k
Scaling GitHub
holman
458
140k
YesSQL, Process and Tooling at Scale
rocio
169
14k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
It's Worth the Effort
3n
183
27k
Transcript
ྠߨ 5IFIVOESFE.- HBOBSJZB ganariya ganariya2525 ganariya2525 ganariya’s blog ganariya
ganariya
%FDJTJPO5SFF-FBSOJOH
3 / N ֓ཁ • ܾఆͦͷ໊ͷ௨ΓܾఆΛߦ͏ͨΊͷ%"( • άϥϑͷ֤ϊʔυͰಛྔͷ൪ͷ ! (#)Λج४ʹͯ͠
σʔλΛࠨӈʹྨ͢Δ • ࠨϊʔυج४ະຬ • ӈϊʔυج४Ҏ্ • ʮ*%ʯͱ͍͏ΞϧΰϦζϜͱೋ͕ѻΘΕ͍ͯΔ͕ ͞ΒʹΑΓྑ͍ΞϧΰϦζϜଞΫϥεྨ͕͋Δ
4 / N 1SPCMFN4UBUFNFOU • ߦ͍͍ͨ͜ͱ{0, 1}ͷྨ • ͦͷͨΊʹɺܾఆͱ͍͏ϞσϧΛ࡞͢Δ
5 / N *%ର • *%ͱ͍͏ΞϧΰϦζϜΛ༻͍Δ • ࠷దԽج४ҎԼͷରΛ༻͍Δ • %&'
ܾఆͦͷͷͰ͋Γɺݸͷσʔλͷྨ͕Β ͘͠ྨ͢Δ͜ͱΛࢦ͢ • ϩδεςΟοΫճؼͱҟͳΓύϥϝʔλΛ୳ࡧͤͣ %&' = Pr( = 1|)͕Β͘͠ͳΔϞσϧΛߏங͢Δ
6 / N ΞϧΰϦζϜ खॱ̍ • = { ! ,
! ) !() * Λϥϕϧ͚͞Εͨαϯϓϧͱ͢Δ • ࠜϊʔυͷఆϞσϧ%&' + %&' + = 1 || 2 , ,. ∈+ !"# $ は根における = 1の割合・確率 定数である この時点であればどんな⼊⼒xを⼊れても 分類は「これまでのサンプルにおけるy=1の 割合」で⾏うしか無い
7 / N ΞϧΰϦζϜ खॱ • ಛྔ = 1, …
, ͱᮢΛఆΊͯࠓͷϊʔυ+ ͷσʔλΛ ̎ͭͷू߹(ࢠϊʔυ)0 , 1 ʹྨ͢Δ • % = {(x, )| x, ∈ , x & < } • ' = {(x, )| x, ∈ , x & ≥ } • ະσʔλx͕༩͑ΒΕͨ࣌ ࢠϊʔυʹҠಈͯ͠ ͞Βʹਖ਼֬ʹྨͰ͖Δ • खॱ̎Λ͋ͱ܁Γฦ͢
8 / N ύϥϝʔλ • ͜͜Ͱൃੜ͢Δͱͯ͠ ʮ্खʹ, Λઃఆ͢Δʯඞཁ͕͋Δ ্खʹϥϕϧͰׂ͞Εͯ΄͍͠ •
ʮΤϯτϩϐʔʯΛ༻͍ͯ͏·ׂ͘͢Δ͜ͱʹ͢Δ
9 / N Τϯτϩϐʔ • Τϯτϩϐʔෳࡶ͞Ͱ͋ΓʮใͷՁʯ ௨৴ཧ ͱ ଊ͑Δͱ͔Γ͍͢ •
͋ͳͨࠓʮ4Ωϟϥ͕ग़ΔʯώϯτΛಘͨ • ͱͱ֬ఆ4Ωϟϥ͔͠Ͱͳ͍Ψνϟ Τϯτϩϐʔখ͍͞ • ͯ͢ͷϥϯΫ͕ಉ֬ͷΨνϟ Τϯτϩϐʔେ͖͍ • ࣄ͕ى͜Δͱͬͨͱ͖ͷΤϯτϩϐʔ = −log()
10 / N ฏۉΤϯτϩϐʔ • ฏۉΤϯτϩϐʔʮෳͷࣄʯ͕ى͜Δͱ͖ͷ ͋ΔࣄΛͬͨͱ͖ͷʮخ͠͞ʯͷฏۉ ฏۉΤϯτϩϐʔ͕େ͖͍΄ͲෳࡶͰᐆດ • =
− ∑( × log) • ΨνϟͰܭࢉͯ͠ΈΔ • ʮ4 "ʯ • ʮ4 "ʯ • ʮ4 "ʯ
11 / N ฏۉΤϯτϩϐʔ • ฏۉΤϯτϩϐʔʮෳͷࣄʯ͕ى͜Δͱ͖ͷ ͋ΔࣄΛͬͨͱ͖ͷʮخ͠͞ʯͷฏۉ ฏۉΤϯτϩϐʔ͕େ͖͍΄ͲෳࡶͰᐆດ • =
− ∑( × log) • ΨνϟͰܭࢉͯ͠ΈΔ • ʮ4 "ʯ • ʮ4 "ʯ • ʮ4 "ʯ
12 / N *%ͷΤϯτϩϐʔ • αϯϓϧू߹ͷΤϯτϩϐʔ • , Ͱׂͨ࣌͠ͷΤϯτϩϐʔ 0
, 1 • % , ' ͕খ͘͞ͳΔΑ͏ʹ, ΛఆΊΔ
13 / N ఀࢭ݅ • ͯ͢ͷ༿ϊʔυͷαϯϓϧσʔλ͕ྨ͞Εͨ࣌ • ∀ ͰׂͰ͖ͳ͍ •
Τϯτϩϐʔ͕͋ΔΑΓݮΒͳ͍ • ਂ͕͞࠷େਂ͞ʹ౸ୡͨ͠ • , ࣮ݧతʹઃఆ͢Δ
14 / N • ࠷దղอূ͞Εͳ͍ • աֶश͢ΔՄೳੑߴ͍ • όοΫτϥοΫͰվળ͢Δ͔͠Εͳ͍
• վྑͷྫʹ$͕͋Δ • ࿈ଓɾࢄͰ͑Δ • QSVOJOHΛ͢Δ ྨʹد༩͠ͳ͍ࢬΛআ͢Δ
4VQQPSU7FDUPS.BDIJOF
16 / N • جຊͰ͍͑ͯΔ ͦ͜Ͱɺ47.ͷͭͷݒ೦ࣄ߲Λߟ͑Δ ϊΠζσʔλ͕͋ͬͯฏ໘ͰશʹྨͰ͖ͳ͍ͱ͖ Ͳ͏͢Δʁ
ฏ໘ʢઢܗʣͰׂͰ͖ͳ͍ͱ͖Ͳ͏͢Δʁ
17 / N 47.SFWJFX • 47.͕ຬ͖ͨ݅͢ • 47.ͷతؔ ϋʔυϚʔδϯ •
w ) Λ࠷খʹ͢Εਖ਼ͱෛͷ෯͕͕ͬͯ͏Ε͍͠ • ೋ࣍ܭը࠷దԽͰղ͘͜ͱ͕Ͱ͖Δ • * ) ɺޯ߱Լ๏ͳͲͰඍͨ͠ͱ͖ʹָͳͷͰ͚ͭΔ
18 / N ϊΠζରࡦ • ઢܗͰ͖ͳ͍σʔλͷͨΊʹώϯδଛࣦ ؔ Λಋೖ • =
max(0, 1 − ) • max(0, 1 − + (+ − )) • ώϯδଛࣦ খ͍ͨ͘͞͠ʂ 0 1 2 5
19 / N ϊΠζରࡦ • ώϯδଛࣦΛಋೖͨ͠ͱ͖ͷ࠷খԽ͢Δతؔ ॏΈ͚ ʢιϑτϚʔδϯʣ • ͕େ͖͍ͱʮʯ
• ͕খ͍͞ͱʮʯ 0 2
20 / N ϊΠζରࡦ • ώϯδଛࣦΛಋೖͨ͠ͱ͖ͷ࠷খԽ͢Δతؔ ॏ Έ͚ ʢιϑτϚʔδϯʣ •
͕େ͖͍ͱʮਅΜதΛऔΔʯ • ͕খ͍͞ͱʮਅΜதແࢹ ͩ͢͠ʯ 0 2
21 / N ݻ༗ඇઢܗੑ త 47.ͰઢܗͰ͖ͳ͍σʔλʹରॲ͍ͨ͠ ରࡦ๏ • ʮΦϦδφϧͷۭؒʯΛʮߴ࣍ݩۭؒʯʹมͯ͠ ͦͷۭؒͰઢܗ͢Δ
తؔͷ࠷దԽʹ͓͍ͯ͜ͷมΛ༻͍Δ͜ͱΛ ʮΧʔωϧτϦοΫʯͱ͍͏
22 / N ΧʔωϧτϦοΫྫ • ϕΫτϧΛߴ࣍ݩʹม͢ΔؔΛఆٛ͢Δ : x → x
• x = [, ]ͷͱ͖ , = (2, 2, 2)ͱ͍͏ؔͱ͢Δ
23 / N • ͕ݟ͔ͭΕઢܗͰ͖Δ͕ ࣮ࡍʹ୳ࡧ͢Δͷܭࢉྔ͕ݫ͍͠ • ઌۦऀ͕ʮΧʔωϧؔʯͳΔͷΛݟ͚͍ͭͯΔͨΊ ͜ͷؔΛͬͯߴ࣍ݩʹҠ͍͍ͤ
• ͨͩ͜͠ͷΧʔωϧͷಈ࡞Λཧղ͢Δʹɺ47.͕ , Λݟ͚ͭΔ࠷దԽΞϧΰϦζϜΛཧղ͠ͳ͍ͱ͍͚ͳ͍
24 / N • ݩͷతؔ࠷దԽͱͯ͠ϥάϥϯδϡ๏Ͱ ղ͘͜ͱ͕Ͱ͖Δʢϥάϥϯδϡ͍֮͑ͯ·ͤΜʣ • + ϥάϥϯδϡ
• Լଆͷࣜʹ͢Δ͜ͱͰɺತੑͷೋ࣍࠷దԽʹͳΓ ΑΓޮతʹೋ࣍ܭըͱͯ͠ղ͚Δ • ͜ΕͰྑͦ͞͏ŋŋŋʁʁʁʁ
25 / N • צͷӶ͍ಡऀͳΒ͓ؾ͖ͮͩͱࢥ͏͕! 3 ্͕ͷࣜʹ͋Δ • ͠Ͱߴ࣍ݩʹ͢Δͱ
! # ܭࢉྔ͕ ॏ͘ͳͬͯ͠·͏͕͋Δ • ͜͜Ͱʮ! 3 ͷ݁Ռ͔͑͞Εྑ͍ʯ ͦ͜ͰɺΧοτੵΧοτ͔ͯ͠ΘΓʹ ΧʔωϧτϦοΫΛ༻͍ΕΑ͍
26 / N τϦοΫͷྫ ! , " = ! "
# カーネル関数
27 / N • ༗໊ͳΧʔωϧؔʹ3#'Χʔωϧ͕͋Δ • x − x4
2 ͭͷϕΫτϧͷϢʔΫϦουڑͷ • = ) 25, 1ͭͷ܇࿅σʔλ͕༩͑ΔӨڹͷൣғ • ͕খ͍͞΄Ͳԕ͘·ͰӨڹͯ͠ ޓ͍ͷڥքͰࣝผۂઢ͕Ҿ͔ΕΔ ୯७ • ͕େ͖͍ͱ͚ۙͩ͘Өڹͯ͠ ͍ͼͭͳܗͷࣝผۂઢ͕Ҿ͔ΕΔ ෳࡶ • ͪΐ͏Ͳ͍͍ؤுͬͯ୳͢
L/FBSFTU/FJHICPST
29 / N L// • L//ύϥϝʔλΛ࣋ͨͳֶ͍शΞϧΰϦζϜ • ֶशσʔλΛͯ͢ϝϞϦʹهԱ͓͖ͯ͠ ֶशσʔλΛͱʹ৽͍͠σʔλΛྨ͢Δ •
৽͍͠σʔλx͕དྷͨΒͬͱ͍ۙݸͷϥϕϧΛΈͯ ྨճؼͷॲཧΛߦ͏ https://medium.com/@kristian.roopnarine/building-a-k-nearest- neighbor-algorithm-with-the-iris-dataset-b7e76867f5d9
30 / N L// • ϢʔΫϦουڑίαΠϯྨࣅͰ ࠷͍ۙݸΛબͿ • ଞʹ৭ʑछྨ͕͋Δ •
ϋΠύʔύϥϝʔλͳͷͰ࣮ݧతʹ୳ͦ͏ σʔλ͔Βֶश͢Δํ๏͋Δ͕ষͰड़Δ
31 / N L//