From f6ba34d2ea793634b0c84a2d3c12792aff6316ea Mon Sep 17 00:00:00 2001 From: Andrew Ghazi <6763470+andrewGhazi@users.noreply.github.com> Date: Sat, 27 Jul 2024 10:26:45 -0400 Subject: [PATCH] updates --- NAMESPACE | 2 +- R/run.R | 46 ++++++++++++++++++++++++++++++++++++++++----- README.Rmd | 2 +- man/run_gp.Rd | 7 +++++-- man/suggest_next.Rd | 3 ++- man/suggest_tune.Rd | 14 ++++++++++++++ 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 man/suggest_tune.Rd diff --git a/NAMESPACE b/NAMESPACE index a635285..00fe845 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,8 @@ # Generated by roxygen2: do not edit by hand export(create_ranges) -export(run_gp) export(suggest_next) +export(suggest_tune) import(collapse) importFrom(data.table,":=") importFrom(data.table,.BY) diff --git a/R/run.R b/R/run.R index 17b0911..d6161a7 100644 --- a/R/run.R +++ b/R/run.R @@ -104,12 +104,12 @@ center_dat = function(dat, param_ranges) { #' @param dat data frame input of brew parameters and rating #' @param ... arguments passed to cmdstanr's sample method #' @param max_grid_size maximum number of grid points to evaluate -#' @param param_ranges upper and lower limits of parameter ranges to evaluate (ignored if param_grid is specified directly) +#' @param param_ranges upper and lower limits of parameter ranges to evaluate (ignored if +#' param_grid is specified directly) #' @param param_grid user-specified grid of brew parameters to evaluate GP at -#' @details -#' The function \code{\link[dyingforacup:create_ranges]{dyingforacup::create_ranges()}} will create an example range df. -#' -#' @export +#' @details The function +#' \code{\link[dyingforacup:create_ranges]{dyingforacup::create_ranges()}} will create an +#' example range df. run_gp = function(dat, ..., max_grid_size = 2000, param_ranges = create_ranges(), param_grid = NULL) { @@ -214,3 +214,39 @@ suggest_next = function(dat, ..., max_grid_size = 2000, acq_df = acq_df, suggested = suggest ) } + +#' Suggest a coffee-related tune +#' +#' @details +#' Some are more rare than others, collect all 8! +#' +#' @export +suggest_tune = function() { + msgs = c("How 'bout this one? Donk:") + + song_info = data.table(u = c("https://www.youtube.com/watch?v=RJC9DXQAd7U", + "https://www.youtube.com/watch?v=zTbJBnkRkFo", + "https://www.youtube.com/watch?v=lpOktupkl0c", + "https://www.youtube.com/watch?v=PU_kd9uJQEI", + "https://www.youtube.com/watch?v=iP6IUqrFHjw", + "https://www.youtube.com/watch?v=cm3YM_9iW_s", + "https://www.youtube.com/watch?v=_rp4tGqRhWA", + "https://www.youtube.com/watch?v=nsFS8tt_3fs"), + info = c('Dethklok - "Duncan Hills Coffee Jingle"', + 'Frank Sinatra - "The Coffee Song"', + 'Black Flag - "Black Coffee"', + 'Humble Pie - "Black Coffee"', + 'The Ink Spots - "The Java Jive"', + 'Otis Redding - "Cigarettes and Coffee"', + "Marty Robbins - \"Smokin' Cigarettes And Drinkin\' Coffee Blues\"", + 'Anthrax - "Cupajoe"')) |> + mtt(p = rev(1:fnobs(u))) + + i = sample(nrow(song_info), 1, prob = song_info$p) + + cli::cli_inform("How 'bout this one? {.emph Donk}:") + cli::cli_inform("") + cli::cli_inform("{.strong {song_info$info[i]}}") + cli::cli_inform("{.url {song_info$u[i]}}") +} + diff --git a/README.Rmd b/README.Rmd index 73c02b5..59cf4bf 100644 --- a/README.Rmd +++ b/README.Rmd @@ -113,7 +113,7 @@ $suggested 1: 1.19 0.464 0.536 9 195 30 ``` -This returns a list of MCMC draws, the acquisition function values over a grid of brew parameters, and a suggestion on where to go next. `offset` and `lambda` can be tweaked to control exploration vs exploitation, but expect to be suggested some combinations that result in really bad coffee sometimes. See `?suggest_next` for more detail on these function arguments and more. +This returns a list of MCMC draws, the acquisition function values over a grid of brew parameters, and a suggestion on where to go next. `offset` and `lambda` can be tweaked to control exploration vs exploitation, but expect to be suggested some combinations that result in really bad coffee sometimes (especially early on before it has collapsed the uncertainty along the outer edges of the parameter space). See `?suggest_next` for more detail on these function arguments and more. ## TODO list diff --git a/man/run_gp.Rd b/man/run_gp.Rd index e59e271..112416a 100644 --- a/man/run_gp.Rd +++ b/man/run_gp.Rd @@ -19,7 +19,8 @@ run_gp( \item{max_grid_size}{maximum number of grid points to evaluate} -\item{param_ranges}{upper and lower limits of parameter ranges to evaluate (ignored if param_grid is specified directly)} +\item{param_ranges}{upper and lower limits of parameter ranges to evaluate (ignored if +param_grid is specified directly)} \item{param_grid}{user-specified grid of brew parameters to evaluate GP at} } @@ -27,5 +28,7 @@ run_gp( Run the GP } \details{ -The function \code{\link[dyingforacup:create_ranges]{dyingforacup::create_ranges()}} will create an example range df. +The function +\code{\link[dyingforacup:create_ranges]{dyingforacup::create_ranges()}} will create an +example range df. } diff --git a/man/suggest_next.Rd b/man/suggest_next.Rd index a678100..17444b5 100644 --- a/man/suggest_next.Rd +++ b/man/suggest_next.Rd @@ -21,7 +21,8 @@ suggest_next( \item{max_grid_size}{maximum number of grid points to evaluate} -\item{param_ranges}{upper and lower limits of parameter ranges to evaluate (ignored if param_grid is specified directly)} +\item{param_ranges}{upper and lower limits of parameter ranges to evaluate (ignored if +param_grid is specified directly)} \item{param_grid}{user-specified grid of brew parameters to evaluate GP at} diff --git a/man/suggest_tune.Rd b/man/suggest_tune.Rd new file mode 100644 index 0000000..0c4cf71 --- /dev/null +++ b/man/suggest_tune.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run.R +\name{suggest_tune} +\alias{suggest_tune} +\title{Suggest a coffee-related tune} +\usage{ +suggest_tune() +} +\description{ +Suggest a coffee-related tune +} +\details{ +Some are more rare than others, collect all 8! +}