Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewGhazi committed Jul 27, 2024
1 parent 5e82393 commit f6ba34d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
46 changes: 41 additions & 5 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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]}}")
}

2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ $suggested
<num> <num> <num> <num> <num> <num>
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

Expand Down
7 changes: 5 additions & 2 deletions man/run_gp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/suggest_next.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/suggest_tune.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f6ba34d

Please sign in to comment.