Julia で 機械学習 2020 === <!-- .slide: data-background-color="rgba(102,130,223,0.3)" --> 2020/06/29 機械学習 名古屋 第24回勉強会 antimon2(後藤 俊介) Note: スポンサー枠(?)LTスライドですっ ---- <!-- .slide: data-background-color="rgba(102,130,223,0.3)" --> ## お品書き + お前誰よ? + 来栖川電算の紹介 + Juliaの紹介 + Julia で 機械学習 --- <!-- .slide: data-background-color="rgba(102,130,223,0.3)" --> # お前誰よ? ---- <!-- .slide: data-background-color="rgba(102,130,223,0.3)" --> ## 自己紹介 + 名前:後藤 俊介 + 所属:**[有限会社 来栖川電算](https://www.kurusugawa.jp)** + コミュニティ:**:star2:[機械学習名古屋](https://machine-learning.connpass.com/)**, :star2:[JuliaTokai](https://juliatokai.connpass.com/), :star:[Python東海](https://connpass.com/series/292/), Ruby東海, … + 言語:**[Julia](https://julialang.org)**, Python, Scala(勉強中), Ruby, … + ![Twitter](https://i.imgur.com/HqouMIg.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [@antimon2](https://twitter.com/antimon2) / ![Facebook](https://i.imgur.com/01nPd37.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [antimon2](https://www.facebook.com/antimon2) + ![Github](https://i.imgur.com/yBKtii5.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [antimon2](https://github.com/antimon2/) / ![Qiita](https://i.imgur.com/FxHMi64.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [@antimon2](http://qiita.com/antimon2) / [<i class="fa fa-file-text"><!-- .element style="font-size:120%" --></i> @antimon2](https://hackmd.io/@antimon2) Note: 今日も Julia の話っ --- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> # 来栖川電算 Note: スポンサー枠っ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> [![有限会社来栖川電算](https://i.imgur.com/8Kuhfel.png) https://www.kurusugawa.jp](https://www.kurusugawa.jp) Note: 見に来てねっ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> [![来栖川電算 ホーム Facebook](https://i.imgur.com/1X3A2vk.png) https://www.facebook.com/kurusugawa.jp](https://www.facebook.com/kurusugawa.jp) Note: 『いいね!』してねっ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> <iframe src="//www.slideshare.net/slideshow/embed_code/key/ssifdsEG0d8IbW" width="595" height="485" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="//www.slideshare.net/youheiyamaguchi/miso20200530" title="MISO20200530" target="_blank">MISO20200530</a> </strong> from <strong><a href="https://www.slideshare.net/youheiyamaguchi" target="_blank">陽平 山口</a></strong> </div> Note: 5/30にオンラインで行われた「みそかつ社 エンジニア・デザイナー 転職会議」での弊社山口の発表資料っ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## 概要 + 設立 2003年(名古屋工業大学発ベンチャー) + 従業員 81人(急成長中!) + ここ最近また人が増えた Note: 従業員にはバイトや家政夫さんも含まれています。 ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## SF 世界の技術を実用化、<br>課題を解決! <!-- .element: style="font-size:2em" --> + AI・ML 技術の研究開発 + 文字認識,物体認識,動作認識,行動認識 + 自社サービス Note: マルチっ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## 技術者集団 + 最先端の AI 技術 + 文字認識、物体認識、モーション認識 + 限界性能を引き出す実装技術 + 高精度化、高速化、省資源化、並列化、分散化 + 高品質なソフトウェアを実現する技術 + 言語・アーキテクチャ・プロセスに対する深い造詣 ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## ビジネス体制 + AI研究開発の手本となり、SI/AIインフラの導入を促進 + アノテータ / デザイナ + 研究者 / 開発者 + AIアプリ / データ / モデル / インフラ Note: アノテーションツールも自社製っ 基本使用料無料で誰でも使えますっ! ---- <!-- .slide: data-background="https://i.imgur.com/bGYH4xl.png" data-background-color="rgba(44,214,221,0.3)" --> Note: ![体制](https://i.imgur.com/bGYH4xl.png) ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## 製品・サービス + 画像認識API(ライセンス販売) + 物体認識(研究開発→SI) + 走行画像リアルタイム認識、地図生成 + モーション認識 + [毎朝体操](http://maiasa.jp/) + 研究開発支援 + **[AnnoFab](https://annofab.com/)**(アノテーションツール) + AHAB(実験スケジューラ) Note: なお次回、[AnnoFab](https://annofab.com/) のハンズオンをこの機械学習名古屋でやりますっ ---- <!-- .slide: data-background="https://i.imgur.com/rwKd7GI.jpg" data-background-color="rgba(44,214,221,0.3)" --> Note: ![事例・製品・サービス](https://i.imgur.com/rwKd7GI.jpg) ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## コミュニティ活動支援 + 勉強会主催 + スポンサー + 会場提供 Note: 名古屋を中心に勉強会コミュニティの各種支援を行っていますっ ---- <!-- .slide: data-background="https://i.imgur.com/Q5Z2052.jpg" data-background-color="rgba(44,214,221,0.3)" --> Note: ![コミュニティ活動](https://i.imgur.com/Q5Z2052.jpg) 機械学習名古屋、JuliaTokai も支えてもらってますっ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## OSS への貢献 + スポンサー + パッチ提供 Note: 名古屋を中心に勉強会コミュニティの各種支援を行っていますっ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> [![OSS の vis.js に 400\$ を寄付しました](https://i.imgur.com/2Pff8A8.png) https://www.kurusugawa.jp/donated-to-vis-js/](https://www.kurusugawa.jp/donated-to-vis-js/) <!-- .element: style="font-size:80%" --> Note: 困窮していたOSS開発コミュニティの復活に貢献した例っ ---- <!-- .slide: data-background-color="rgba(44,214,221,0.3)" --> ## 求人等 + 研究(認識技術) + 開発(サーバサイド/フロントエンド) + 企画(アプリ/サービス) + デザイナ Note: 学生の皆さん、転職者の皆さん、力を貸してくださいっ ---- <!-- .slide: data-background="https://i.imgur.com/5CbxlN7.jpg" data-background-color="rgba(44,214,221,0.3)" --> Note: ![募集中!](https://i.imgur.com/5CbxlN7.jpg) --- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> # Julia の紹介 ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> [![Julia](https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-logo-color.svg?sanitize=true)<!-- .element: style="background:white;width:80%" -->](https://julialang.org) ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## Julia とは?(1) + [The Julia Language](https://julialang.org) + 最新 v1.4.2(2020/05/23) + LTS v1.0.5(2019/09/09) + pre v1.5.0-RC1(2020/06/26) + 科学技術計算に強い! + 動作が速い!(LLVM JIT コンパイル) Note: ググるときはなるべく [julialang](https://www.google.co.jp/search?q=julialang) で! ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## Julia とは?(2) > + Rのように中身がぐちゃぐちゃでなく、 > + Rubyのように遅くなく、 > + Lispのように原始的またはエレファントでなく、 > + Prologのように変態的なところはなく、 > + Javaのように硬すぎることはなく、 > + Haskellのように抽象的すぎない > > ほどよい言語である <!-- .element: style="font-size:66%" --> 引用元:http://www.slideshare.net/Nikoriks/julia-28059489/8 <!-- .element: style="font-size:71%" --> ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## Julia とは?(3) > + C のように高速だけど、 Ruby のような動的型付言語である > + Lisp のようにプログラムと同等に扱えるマクロがあって、しかも Matlab のような直感的な数式表現もできる > + Python のように総合的なプログラミングができて、 R のように統計処理も得意で、 Perl のように文字列処理もできて、 Matlab のように線形代数もできて、 shell のように複数のプログラムを組み合わせることもできる > + 超初心者にも習得は簡単で、 超上級者の満足にも応えられる > + インタラクティブにも動作して、コンパイルもできる <!-- .element: style="font-size:50%" --> ([Why We Created Julia](http://julialang.org/blog/2012/02/why-we-created-julia) から抜粋・私訳) <!-- .element: style="font-size:71%" --> Note: いろんな言語の「いいとこどり」言語!ってことでっ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## 要するに <!-- .element: style="font-size:300%" --> + 動的言語なのに速い! + 文法も覚えやすい! + 数値計算に強い! <!-- .element: style="font-size:180%" --> Note: 機械学習とかにも持って来いっ! ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## 主な機能 <!-- .element: style="font-size:280%" --> + [多重ディスパッチ](https://docs.julialang.org/en/v1/manual/methods/) + [動的型システム](https://docs.julialang.org/en/v1/manual/types/) + [並行・並列処理](https://docs.julialang.org/en/v1/manual/parallel-computing/)、コルーチン + [組込パッケージマネージャ](https://docs.julialang.org/en/v1/stdlib/Pkg/) <!-- .element: style="font-size:160%" --> Note: っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ## 文法・関数 Note: 以降、ほぼ過去スライドからのコピペ。すっ飛ばして先へ進んで戴いてもOKっ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 基本的な演算 ```julia julia> 1 + 2 - 3 * 4 # 四則演算(除算以外) -9 julia> 7 / 5 # `整数 / 整数` の結果は浮動小数 1.4 julia> 7 ÷ 5 # `整数 ÷ 整数` の結果は整数 1 julia> 2 ^ 10 # 冪乗は `^` 1024 julia> 123 & 234 | 345 # 論理積 / 論理和 376 julia> 123 ⊻ 234 # 排他的論理和(==`xor(123, 234)`) 145 ``` <!-- .element: style="font-size:46%" --> Note: 整数同士の除算は実数になりますっ 整数除算演算子 `÷` が別に存在します(Python の `//` 相当)っ また冪乗も(`**` ではなく)`^` ですっ `⊻` は `\xor`+<kbd>Tab</kbd> または `\veebar`+<kbd>Tab</kbd> で変換できますっ ちなみに先ほどの `÷` も `\div`+<kbd>Tab</kbd>で(基本的に ${\rm \TeX}$ の書式)っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 配列 ```julia julia> a = [1, 2, 3, 4, 5] 5-element Array{Int64,1}: 1 2 3 4 5 julia> a[1] # Julia は 1-origin 1 julia> println(a[2:3]) # 範囲指定は両端含む [2, 3] ``` <!-- .element: style="font-size:50%" --> Note: 1-origin であることに注意すればあとは普通の配列っ あと `a:b` は範囲(`Range`)の記法。両端を含む(Ruby の `a..b` と同じ)っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 配列の内包表記 (1) ```julia julia> a = [n^2 for n=1:5] 5-element Array{Int64,1}: 1 4 9 16 25 julia> A = [x+10y for y=1:3, x=1:3] 3×3 Array{Int64,2}: 11 12 13 21 22 23 31 32 33 ``` <!-- .element: style="font-size:50%" --> Note: 内包表記の記法は Python に類似っ かつ、`for` にカンマ区切りで複数のイテレータを渡すことで2次元以上の配列も作成可能っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 配列の内包表記 (2) ```julia julia> [(a,b,c) for c=1:15,b=1:15,a=1:15 if a^2+a*b+b^2==c^2] 6-element Array{Tuple{Int64,Int64,Int64},1}: (3, 5, 7) (5, 3, 7) (6, 10, 14) (7, 8, 13) (8, 7, 13) (10, 6, 14) ``` Note: Python と同様に `if` で条件を指定することも可能っ あと Python と同様、`[○ for ○=○]` を `(○ for ○=○)` と書くと配列ではなくて `Generator` が返りますっ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### ベクトル ```julia julia> x = [1., 2., 3.]; y = [3., 1., 2.]; julia> x + y # `x .+ y` と書いても同じ(elementwise operation) [4., 3., 5.] julia> x .* y # これは `x * y` と書くとNG [3., 2., 6.] julia> using LinearAlgebra julia> x ⋅ y # 内積(dot積、`dot(x, y)` と書いても同じ) 11.0 julia> x × y # 外積(cross積、`cross(x, y)` と書いても同じ) [1., 7., -5.] ``` <!-- .element: style="font-size:50%" --> Note: Julia では実は1次元配列がベクトルの扱いっ `⋅` は `\cdot`+<kbd>Tab</kbd>、`×` は `\times`+<kbd>Tab</kbd>(これらを利用するには `using LinearAlgebra` 必要)っ あとこれらや先ほどの `÷` や `⊻` などのように、ASCIIの範囲を超えたUnicode文字の演算子(そのほとんどが $\TeX$ 由来)が Julia にはたくさんあります(他には例えば比較演算子の `≤` `≥` や、集合の要素 `∈` や包含関係 `⊆` などなど) ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 行列 ```julia julia> A = [1 2; 3 4] # この記法は MATLAB/Octave 由来 2×2 Array{Int64,2}: 1 2 3 4 julia> A' # `○'` は転置行列の記法(これも MATLAB/Octave 由来) 2×2 LinearAlgebra.Adjoint{Int64,Array{Int64,2}}: 1 3 2 4 julia> transpose(A) # 正確には転置行列はこっち 2×2 LinearAlgebra.Transpose{Int64,Array{Int64,2}}: 1 3 2 4 ``` <!-- .element: style="font-size:50%" --> Note: Julia では2次元配列が行列の扱いっ あと `○.'` という書式は廃止されました(`transpose(A)` 使ってね)っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 行列の演算 ```julia julia> A = [1 2; 3 4]; B = [3 0; 0 6]; julia> A + B # A .+ B でも同様 2×2 Array{Int64,2}: 4 2 3 10 julia> A * B # matrix multiply 2×2 Array{Int64,2}: 3 12 9 24 julia> A .* B # elementwise multiply 2×2 Array{Int64,2}: 3 0 0 24 ``` <!-- .element: style="font-size:48%" --> Note: 行列は `*` で通常の行列積になりますっこれ便利っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### ブロードキャスト ```julia julia> sin(0.1) 0.09983341664682815 julia> sin.([0.1, 0.2, 0.3, 0.4]) 4-element Array{Float64,1}: 0.0998334 0.198669 0.29552 0.389418 julia> [0.1, 0.2, 0.3, 0.4] .^ 2 # => [0.01, 0.04, 0.09, 0.16] ``` <!-- .element: style="font-size:50%" --> Note: 関数名と `(` の間に `.` を置くと、普通の関数を配列に拡張してくれる(ブロードキャスト)っ `.^` のように演算子の前に `.` を書いても同様(先ほど出た `.+` `.*` もブロードキャスト)っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 関数定義 ```julia julia> f(x) = x^2 + 2x - 1 f (generic function with 1 method) julia> f(1) 2 julia> f.(1:5) # => [2, 7, 14, 23, 34] ``` Note: 数学のように直感的な記述で関数を定義可能っ `2x` は `2*x` の省略形、曖昧さがなければリテラルと他の識別子が続く場合などに勝手に乗算と解釈してくれるっ またユーザ定義関数も `.` をつけて自動的にブロードキャスト対応っ ---- <!-- .slide: data-background-color="rgba(213,99,92,0.3)" --> ### 有理数・複素数 ```julia julia> 1//2 == 0.5 true julia> 1//2 - 1//3 1//6 julia> 1im ^ 2 == -1 true julia> (1.0 + 0.5im) * (2.0 - 3.0im) 3.5 - 2.0im ``` Note: 有理数・複素数を標準サポート。 `//` は有理数除算(結果は有理数) `im` は虚数単位。 どちらも四則演算も普通に書けますっ --- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> # Julia で 機械学習 <!-- .element: style="font-size:3em" --> ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ## Julia の機械学習ソリューション + **MLJ.jl** + [Flux.jl](https://fluxml.ai) / [Knet.jl](https://github.com/denizyuret/Knet.jl) + 自分で書く(行列・テンソル計算簡単) Note: っ ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ### Flux.jl + [GitHub](https://github.com/FluxML/Flux.jl) / [Document](https://fluxml.github.io/Flux.jl) + Julia 定番の Deep Learning F/W + GPU / TPU 対応 + [model zoo](https://github.com/FluxML/model-zoo) 装備 Note: っ --- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> # MLJ.jl <!-- .element: style="font-size:3.6em" --> ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ## MLJ (Machine Learning in Julia) + [GitHub](https://github.com/alan-turing-institute/MLJ.jl) / [Document](https://alan-turing-institute.github.io/MLJ.jl/stable/) + Julia の機械学習ツールボックス + 機械学習モデルの利用・構築に一貫性 + Julia ML/Stats エコシステム Note: つまり Python における scikit-learn のような位置づけっ ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> [![MLJ Dependency Chart](https://i.imgur.com/Nj6pLS4.png)https://github.com/alan-turing-institute/MLJ.jl/blob/master/README.md#the-mlj-universe](https://github.com/alan-turing-institute/MLJ.jl/blob/master/README.md#the-mlj-universe) <!-- .element: style="font-size:60%" --> Note: っ ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ### 基本的な使い方 + 新しい **[環境](https://julialang.github.io/Pkg.jl/v1/environments/)** を作る + `Pkg.add("MLJ")` + 使用するデータ/モデルに合ったパッケージを追加 + データ整備 + 学習器を作る + 学習する(`fit!()`) + 推論する(`predict()` / `transform()`) Note: っ ---- #### 新しい環境を作る <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```bash $ julia -e 'using Pkg;Pkg.generate("MLJ_sample")' $ cd MLJ_sample $ julia --project ``` Note: ここでいう **環境** とは、Julia の(仮想)環境のことっ pipenv とか poetry とかを想定してもらえるとっ で環境を作ったディレクトリ内で `julia --project` するとその環境を Activate した状態で REPL が立ち上がりますっ ---- #### `Pkg.add("MLJ")` <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.4.2 (2020-05-23) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | julia> # type ']' (MLJ_sample) pkg> add MLJ Updating registry at `~/.julia/registries/General` Updating git-repo `git@github.com:JuliaRegistries/General.git` Resolving package versions... Installed MLJModels ────── v0.10.1 : 《略》 Updating `/path/to/MLJ_sample/Project.toml` [add582a8] + MLJ v0.11.5 Updating `/path/to/MLJ_sample/Manifest.toml` [7d9fca2a] + Arpack v0.4.0 : 《略》 ``` <!-- .element: style="font-size:30%" --> Note: っ ---- #### 使用するデータ/モデルに合ったパッケージを追加 <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia julia> # type ']' (MLJ_sample) pkg> add RDatasets DecisionTree Resolving package versions... Installed DataFrames ─ v0.21.3 Installed DecisionTree ─ v0.10.5 Updating `/mnt/polonium_data/MLN/MS/202006/MLJ_sample_1st/Project.toml` [7806a523] + DecisionTree v0.10.5 [ce6b1742] + RDatasets v0.6.9 Updating `/mnt/polonium_data/MLN/MS/202006/MLJ_sample_1st/Manifest.toml` [336ed68f] + CSV v0.6.2 [7806a523] + DecisionTree v0.10.5 :《略》 ``` <!-- .element: style="font-size:40%" --> Note: っ ---- #### データ整備 <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia julia> import RDatasets julia> iris = RDatasets.dataset("datasets", "iris"); # a DataFrame julia> using MLJ julia> y, X = unpack(iris, ==(:Species), colname -> true); julia> models(matching(X,y)) 42-element Array{NamedTuple{(:name, :package_name, :is_supervised, :docstring, :hyperparameter_ranges, :hyperparameter_types, :hyperparameters, :implemented_methods, :is_pure_julia, :is_wrapper, :load_path, :package_license, :package_url, :package_uuid, :prediction_type, :supports_online, :supports_weights, :input_scitype, :target_scitype, :output_scitype),T} where T<:Tuple,1}: (name = AdaBoostClassifier, package_name = ScikitLearn, ... ) (name = AdaBoostStumpClassifier, package_name = DecisionTree, ... ) :《略》 (name = DecisionTreeClassifier, package_name = DecisionTree, ... ) :《略》 (name = XGBoostClassifier, package_name = XGBoost, ... ) ``` <!-- .element: style="font-size:40%" --> Note: っ ---- #### 学習器を作る <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia julia> tree_model = @load DecisionTreeClassifier verbosity=1 import MLJModels ✔ import DecisionTree ✔ import MLJ.MLJModels.DecisionTree_.DecisionTreeClassifier ✔ DecisionTreeClassifier( max_depth = -1, min_samples_leaf = 1, min_samples_split = 2, min_purity_increase = 0.0, n_subfeatures = 0, post_prune = false, merge_purity_threshold = 1.0, pdf_smoothing = 0.0, display_depth = 5) @ 1…84 ``` Note: っ ---- #### 学習する(`fit!()`) <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia julia> tree = machine(tree_model, X, y) Machine{DecisionTreeClassifier} @ 1…14 julia> train, test = partition(eachindex(y), 0.7, shuffle=true); # 70:30 split julia> fit!(tree, rows=train); [ Info: Training Machine{DecisionTreeClassifier} @ 1…14. ``` Note: っ ---- #### 推論する(`predict()` / `transform()`) <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ```julia julia> yhat = predict(tree, X[test,:]); julia> yhat[3:5] 3-element MLJBase.UnivariateFiniteArray{Multiclass{3},String,UInt8,Float64,1}: UnivariateFinite{Multiclass{3}}(setosa=>0.0, versicolor=>0.0, virginica=>1.0) UnivariateFinite{Multiclass{3}}(setosa=>1.0, versicolor=>0.0, virginica=>0.0) UnivariateFinite{Multiclass{3}}(setosa=>1.0, versicolor=>0.0, virginica=>0.0) julia> predict_mode(tree, rows=test[3:5]) 3-element CategoricalArrays.CategoricalArray{String,1,UInt8}: "virginica" "setosa" "setosa" ``` Note: っ ---- <!-- .slide: data-background-color="rgba(96,173,81,0.3)" --> ### 補足 + `models(matching(X,y))` で使えるモデルが探せる(便利) + 教師なし学習の場合は `transform()` Note: っ --- <!-- .slide: data-background-color="rgba(170,121,193,0.3)" --> # まとめ ---- <!-- .slide: data-background-color="rgba(170,121,193,0.3)" --> + Julia で 機械学習! + Julia 良いよ楽しいよ! <!-- .element: style="font-size: 160%" --> Note: っ ---- <!-- .slide: data-background-color="rgba(170,121,193,0.3)" --> ## 参考リンク + [MLJ.jl: A Julia machine learning framework (GitHub)](https://github.com/alan-turing-institute/MLJ.jl) + [Introduction · MLJ (Document)](https://alan-turing-institute.github.io/MLJ.jl/stable/) --- <!-- .slide: data-background-color="rgba(170,121,193,0.3)" --> ご清聴ありがとうございます。 Note: ご清聴ありがとうございますっ!
{"metaMigratedAt":"2023-06-15T10:01:12.694Z","metaMigratedFrom":"YAML","title":"Julia で 機械学習 2020","breaks":true,"slideOptions":"{\"transition\":\"slide\",\"theme\":\"league\"}","contributors":"[{\"id\":\"80062a4b-8dad-49ac-95bf-848ce0686e9e\",\"add\":9263,\"del\":7324}]"}
    1781 views