Slide 1

Slide 1 text

@u_ribo TOKYO.R #95 Shinya Uryu

Slide 2

Slide 2 text

γʔγϡϙεͷؠ ࡞ۀͷ΍Γ௚͠ʹۤ͠Ήσʔλ෼ੳऀͨͪ

Slide 3

Slide 3 text

ϫʔΫϑϩʔͷґଘؔ܎ (BSSFUUBOE)BEMFZ ΑΓ࡞੒

Slide 4

Slide 4 text

ϫʔΫϑϩʔͷґଘؔ܎ ্ྲྀͰߦͬͨมߋ͕ԼྲྀʹӨڹ 🔥 🔥 🔥 🔥 🔥

Slide 5

Slide 5 text

࠶ݱੑͱ࣮ߦ࣌ؒͷδϨϯϚ 🔥 ϫʔΫϑϩʔʹมߋ͕ՃΘͬͨ࣌ Ͳ͏͢Δʁ ࠶ݱੑ ࣮ߦ࣌ؒ ϑΥϧμ؅ཧ ίʔυΛ࢒͢ ˓ º ख͕͔͔ؒΔ ݁ՌʢσʔλʣΛ ࢒͢ º ˓ ख͕͔͔ؒΔ

Slide 6

Slide 6 text

{targets} Dynamic Function-Oriented 'Make'-Like Declarative Workflows ؔ਺ࢦ޲ϓϩάϥϛϯάͱએݴܕͷϫʔΫϑϩʔ ͕ಛ௃ ౷ܭɾσʔλαΠΤϯεͷͨΊͷύΠϓϥΠϯπʔϧ ίʔυͱσʔλͷ؅ཧ͕༰қ \ESBLF^ύοέʔδͷޙܧ

Slide 7

Slide 7 text

{targets}ΛקΊΔཧ༝ ࡞ۀͷྲྀΕͷࢹ֮Խ σʔλɾίʔυͷϒϥοΫϘοΫεԽΛ๷͙ શମͷॲཧΛ؆ܿʹ ॲཧΛؔ਺Խ͢Δ͜ͱͰอकੑ΋޲্ ίʔυɺσʔλ؅ཧͷ൥Θ͔͠͞Βͷ୤٫ मਖ਼ɾ௥Ճ࡞ۀͷࡍͷෛ୲͕ݮগ ϫʔΫϑϩʔʹΑΔґଘؔ܎ͷ೺Ѳ

Slide 8

Slide 8 text

ࠓ೔࿩ʢͤc͞ʣͳ͍͜ͱ 5BSHFU.BSLEPXO σόοάͷํ๏ ͜ΕΒͷ಺༰͸ϚχϡΞϧΛࢀߟ @UBSHFUTΦϒδΣΫτͷ؅ཧ https://books.ropensci.org/targets/ 3.BSLEPXOจॻ಺෦ͰύΠϓϥΠϯΛఆٛ 5BSHFU.BSLEPXOݕূϝϞUFSBTIJNDPN https://terashim.com/posts/target-markdown/ ͳͲ

Slide 9

Slide 9 text

{targets}ͷύΠϓϥΠϯ ࣮ߦ݁ՌΛ಺෦ʹอଘɻ࠶࣮ߦ࣌ɺલճͷ࣮ߦ͔࣌Βɹ มߋͷͳ͍ॲཧʢλʔήοτʣΛεΩοϓ ࣮ߦ࣌ؒͷ୹ॖɺ ... ϫʔΫϑϩʔશମͷґଘؔ܎ ʢίʔυɺσʔλɺ্ྲྀͰͷॲཧ಺༰ʣΛ؂ࢹ ࠶ݱੑ͕อূ͞ΕΔɻ ϑΥϧμ؅ཧͷ൥Θ͔͠͞Βղ์͞ΕΔɻ 4UBOͳͲͷ࣮ߦʹ࣌ؒΛཁ͢Δॲཧ΍ػցֶशͷ࣮ݧʹద͢Δɻ

Slide 10

Slide 10 text

{targets}ͷجૅ αϯϓϧϦϙδτϦ IUUQTHJUIVCDPNVSJCPUBML@@UPLZPS

Slide 11

Slide 11 text

\UBSHFUT^Λ࢖ͬͨϓϩδΣΫτͷجຊ ├─_targets.R ├─ R/ ├── function.R ├─ data/ ├── raw_data.csv └─ hoge.Rproj \UBSHFUT^ʹΑΔύΠϓϥΠϯͷ ࣮ߦखॱΛهࡌɺ ࣮ߦʹඞཁͳύοέʔδɾؔ਺ಡΈࠐ Έ΍ͦͷଞͷΦϓγϣϯΛؚΊΔɻ 5BSHFUεΫϦϓτϑΝΠϧ @UBSHFUT3

Slide 12

Slide 12 text

ͭͷॲཧ ͔ΒͳΔϫʔΫϑϩʔ @UBSHFUT3ʹλʔήοτͱͳΔॲཧΛهड़ library(targets) list( tar_target( my_mtcars, subset(mtcars, cyl == 6)), tar_target( dist_histogram, hist(my_mtcars$disp)), tar_target( lm_res, lm(mpg ~ wt, mtcars)) ) MJTU Λ࢖ͬͯύΠϓϥΠϯΛఆٛ ⁞   ⁠ ݸผͷॲཧ͸UBS@UBSHFU Ͱࢦఆ UBS@UBSHFU ໊લ ॲཧ಺༰ my_mtcars <- subset(mtcars, cyl == 6) UBS@NBLF ͰύΠϓϥΠϯͷ࣮ߦ ࣮ߦ؀ڥͱ͸ҟͳΔ3ηογϣϯͰ ͕ߦΘΕΔΠϝʔδ ⁞   ⁠ _targets.R

Slide 13

Slide 13 text

tar_make()ύΠϓϥΠϯͷ࣮ߦ TUBSU CVJME 5BSHFUʹมߋ͕͋Ε͹ ʢΩϟογϡ͕ར༻͞ΕΔʣ 5BSHFUͷॲཧ͕࣮ߦ σʔλετϨʔδʢޙड़ʣʹ ͳ͚Ε͹TLJQ ࠷ॳͷUBS@NBLF ೋ౓໨ͷUBS@NBLF

Slide 14

Slide 14 text

tar_visnetwork()ϫʔΫϑϩʔͷՄࢹԽ library(targets) list( tar_target( my_mtcars, subset(mtcars, cyl == 6)), tar_target( dist_histogram, hist(my_mtcars$disp)), tar_target( lm_res, lm(mpg ~ wt, mtcars)) ) ॲཧ಺༰ͷґଘؔ܎͕໌֬ʹ ⁞   ⁠ Ͳͷॲཧ͕มߋ͞Εͨʁ ΤϥʔՕॴͷಛఆ͕༰қʹ _targets.R

Slide 15

Slide 15 text

tar_read()tar_load()݁Ռͷ෮ݩ ॲཧ݁Ռ͸@UBSHFUTʹ஝ੵ͞Ε͍ͯΔ tar_read(lm_res) #> Call: #> lm(formula = mpg ~ wt, data = mtcars) #> #> Coefficients: #> (Intercept) wt #> 37.285 -5.344 UBS@MPBE Ͱ࡞ۀۭؒʹ ΦϒδΣΫτͱͯ͠อଘ UBS@SFBE ͰಡΈࠐΈ ʢग़ྗʣ ࠶ݱੑͷ޲্ɾ࣌ؒͷ୹ॖ

Slide 16

Slide 16 text

ଟ༷ͳσʔλετϨʔδ ├─ _targets/ ├── meta/meta ├── objects/ ├──── my_mtcars ├──── dist_histogram ├──── lm_res ͲͷΑ͏ͳσʔλ͕͋Δ͔ʜ UBS@NFUB ύΠϓϥΠϯͰੜ੒͞Εͨ݁ՌΛ@UBSHFUT಺Ͱ؅ཧ σϑΥϧτͰ͸SET UBS@UBSHFU ʜ GPSNBU ͰࢦఆՄೳ GTU GFBUIFS QBSRVFU BXT

Slide 17

Slide 17 text

{targets}ͷਪ͠ػೳ

Slide 18

Slide 18 text

ਪ͠ϒϥϯν ϞσϧͷύϥϝʔλΛมߋͯ݁͠ՌΛൺֱ͍ͨ͠ ࣮ݧͱͯ͠ద౰ͳ஋ΛೖΕͯࢼ͍ͨ͠ ࡞ਤͷݟͨ໨Λม͑ΔͷʹҰ෦ͷ৭͚ͩมߋͯ͠Έ͍ͨ ίʔυʹ࢒͢ʁ ݁ՌΛ؅ཧ͢Δͷ͸໘౗ʜ UBS@SFBE ʜ CSBODIFT list(… tar_target(activations, c("relu", "sigmoid")), tar_target( run, test_model(act1 = activations, churn_data, churn_recipe), pattern = map(activations) ),…) 5BSHFUT͕Α͠ͳʹ؅ཧʂ QBUUFSOҾ਺ JUFSBUJPOҾ਺ ׆ੑԽؔ਺ͷࢦఆΛύλʔϯ༻ҙ _targets.R

Slide 19

Slide 19 text

ਪ͠ߴੑೳܭࢉ UBS@UBSHFU ಺Ͱͷ੾Γସ͑͸EFQMPZNFOUҾ਺ͰࢦఆɻlNBJOz·ͨ͸lXPSLFSz UBS@NBLF@DMVTUFSNR ෛ୲ͷେ͖ͳॲཧ΋ߴ଎ʹ {clustermq} {future} UBS@NBLF@GVUVSF options( clustermq.scheduler = "multiprocess") library(future) library(future.callr) plan(callr) list( tar_target(data, get_data()), tar_target(fast_fit, fit_small_model(data)), tar_target(plot_1, make_plot(fast_fit))) _targets.R

Slide 20

Slide 20 text

R targetopia tarchetypes::tar_render() 3NEϑΝΠϧͷग़ྗΛ࣮ߦ stantargets::tar_stan_compile() TUBOϑΝΠϧͷίϯύΠϧ ॲཧ಺༰ΛύοέʔδԽ ൚༻తͳ ༻్ʹಛԽͨؔ͠਺Λఏڙ