ropensci / targets

Function-oriented Make-like declarative workflows for R
https://docs.ropensci.org/targets/
Other
916 stars 74 forks source link

cmdstan format #211

Closed wlandau closed 3 years ago

wlandau commented 3 years ago

Prework

Proposal

We could consider accommodating CmdStanFit objects with tar_target(format = "cmdstanr"). Related: https://github.com/stan-dev/cmdstanr/issues/340.

wlandau commented 3 years ago

On reflection, I do not think this is worth a special feature. Users can load the relevant output into memory and specify the existing rds or qs format.

self$draws() 
try(self$sampler_diagnostics(), silent = TRUE) 
try(self$init(), silent = TRUE) 
wlandau commented 3 years ago

Related: @mike-lawrence and others, do you think there would be value in a tarchetypes-like package for cmdstan models? Some possible target archetypes:

mike-lawrence commented 3 years ago

That sounds for sure useful!

wlandau commented 3 years ago

This weekend, I implemented something like https://github.com/wlandau/targets/issues/211#issuecomment-724070231 in a new package called stantargets. It's not public yet, but it is fully fleshed out and working. I will post a link as soon as I get permission to share.

wlandau commented 3 years ago

stantargets is now open source! It is an extension to targets for Stan-powered Bayesian data analysis. stantargets makes it super easy to set up useful pipelines without having to write many functions or think about branching. It supports all the features of cmdstanr (MCMC, variational Bayes, optimization), and it supports both single-fit workflows and multi-rep simulation studies (vignettes here).

wlandau commented 3 years ago

Update: I am trying to continue what I started with stantargets and cultivate a whole ecosystem of these packages: https://wlandau.github.io/targetopia.html. My background is in Bayesian statistics, so that's where I am starting. But I also want to branch out to machine learning. @mattwarkentin, do you think the stuff people do with torch has enough workflow patterns to materialize in a stantargets-like package?

mattwarkentin commented 3 years ago

Hey @wlandau. Upon seeing targetopia, I immediately thought about whether I have anything worthwhile to contribute. My mind went to torch, but my hesitation was based on the fact that I really have yet to use or inspect stantargets et al. so I don't really know well enough what those packages do to reduce the friction of using targets. I'll try to dig into stantargets this weekend and see if it inspires any thoughts about how something similar could be warranted for torch.

wlandau commented 3 years ago

I immediately thought about whether I have anything worthwhile to contribute.

I think you do. You know targets super well, and you are experienced with torch, which I have not used in a real-world project.

My mind went to torch, but my hesitation was based on the fact that I really have yet to use or inspect stantargets et al. so I don't really know well enough what those packages do to reduce the friction of using targets.

Targetopia packages aim to automatically build in options and techniques that would either be annoying to implement manually or too advanced for the majority of users. Examples:

At some point I plan to write general guidance for targetopia developers.

mattwarkentin commented 3 years ago

Thanks for the detailed response, Will. This is very helpful for understanding how these add-on packages contribute to the targetopia. I will mull it over a bit more and try to sketch out some torch workflow patterns that I think might lend themselves well to this ecosystem.

wlandau commented 3 years ago

I am glad you are interested. With some good torch workflow patterns, I think a new torch-powered targetopia package is possible. cc @skeydan and @dfalbel.

dfalbel commented 3 years ago

That looks really nice! I's be happy to help! Let me know if you need any development in the torch side too.

wlandau commented 3 years ago

Thanks, glad to hear it! The torch vignettes are super nice, and they are helping me begin to wrap my head around usage patterns. If anything else strikes you as a particularly ubiquitous archetype, please let us know.

wlandau commented 3 years ago

@mattwarkentin, FYI: the R Targetopia now has its own website with a more detailed contributing guide.