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

{targets}でワークフローを管理せよ / Workflow management wit...

Uryu Shinya
October 30, 2021

{targets}でワークフローを管理せよ / Workflow management with targets

Uryu Shinya

October 30, 2021
Tweet

More Decks by Uryu Shinya

Other Decks in Programming

Transcript

  1. \UBSHFUT^Λ࢖ͬͨϓϩδΣΫτͷجຊ ├─_targets.R ├─ R/ ├── function.R ├─ data/ ├── raw_data.csv

    └─ hoge.Rproj \UBSHFUT^ʹΑΔύΠϓϥΠϯͷ ࣮ߦखॱΛهࡌɺ ࣮ߦʹඞཁͳύοέʔδɾؔ਺ಡΈࠐ Έ΍ͦͷଞͷΦϓγϣϯΛؚΊΔɻ 5BSHFUεΫϦϓτϑΝΠϧ @UBSHFUT3
  2. ͭͷॲཧ ͔ΒͳΔϫʔΫϑϩʔ @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
  3. 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
  4. 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 ͰಡΈࠐΈ ʢग़ྗʣ ࠶ݱੑͷ޲্ɾ࣌ؒͷ୹ॖ
  5. ଟ༷ͳσʔλετϨʔδ ├─ _targets/ ├── meta/meta ├── objects/ ├──── my_mtcars ├────

    dist_histogram ├──── lm_res ͲͷΑ͏ͳσʔλ͕͋Δ͔ʜ UBS@NFUB ύΠϓϥΠϯͰੜ੒͞Εͨ݁ՌΛ@UBSHFUT಺Ͱ؅ཧ σϑΥϧτͰ͸SET UBS@UBSHFU ʜ GPSNBU ͰࢦఆՄೳ GTU GFBUIFS QBSRVFU BXT
  6. ਪ͠ϒϥϯν ϞσϧͷύϥϝʔλΛมߋͯ݁͠ՌΛൺֱ͍ͨ͠ ࣮ݧͱͯ͠ద౰ͳ஋ΛೖΕͯࢼ͍ͨ͠ ࡞ਤͷݟͨ໨Λม͑ΔͷʹҰ෦ͷ৭͚ͩมߋͯ͠Έ͍ͨ ίʔυʹ࢒͢ʁ ݁ՌΛ؅ཧ͢Δͷ͸໘౗ʜ 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
  7. ਪ͠ߴੑೳܭࢉ 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