-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize score generation and optimization #54
Comments
Hi @banfai , from what I understand there are two problems:
I think the solution to this is to a) make function creation agnostic of a batch container my personal opinion: In our case I see more confusion than actual benefit. I think the approach should be: bc |> optimize(<bc>, scoring_fun = mk_scoring(batch_var), group_by=c(x, y)) |
also note on if we want to go this way, we should create an separate optimization object. which is by the way possible as a wrapper around optimize design. |
Hi @idavydov . Just to explain how we thought yesterday in the discussion, addressing your 2 points above...
So the idea would be to put all the sophistication into the add_scoring and add_shuffling functions and keep the actual generators of those scorings/shufflings as lean as possible. The pipe syntax seemed attryctive to the 3 of us present yesterday and it could work out like this... |
Some unstructured notes: scoring_f <- osat_score_generator("plates", c("SampleType", "Race", "AgeGrp"))
optimize_design(bc, scoring = scoring_f, max_iter = params$iterations)
scoring_f <- cached_score_generator(osat_score, feature_vars="plates", batch_vars=c("SampleType", "Race", "AgeGrp"))
optimize_design(bc, scoring = scoring_f, max_iter = params$iterations)
score_factory <- function() {function(f, ...) {
force(f)
args <- list(...)
function() {
cache <- NULL
function(dt) {
res <- do.call(f, c(args, cache = cache))
cache <<- res$cache
return(res$score_values)
}
}
}
bc |>
optimize_design(score = osat_score, group_by = plate)
fast_osat_score <- cached_score_generator(osat_score, batch = "...", feature = "...")
bc |>
optimize_design(score = , group_by = plate)
bc |>
optimize_design(score = osat_score_generator(batch_var = y, features = x ))
scoring_f <- list(
my_simple_score,
\(dt) osat_score(dt, feature_vars="a", batch_vars="b"),
score_generator(osat_score, feature_vars="a", batch_vars="b")
...
)
optimize_design(bc, scoring = scoring_f, max_iter = params$iterations) |
this should not need the whole batch container, it should work on subset:
designit/R/score_plates.R
Line 80 in fb873c1
list of lists, should work with group_by:
designit/R/score_plates.R
Line 253 in fb873c1
TODO:
bc |> group_by() |> optimize(<bc>, scoring_fun = mk_scoring(batch_var))
bc |> group_by() |> mk_scoring("osat") |> optimize()
grid_2d_score_generator()
scoring function might collide with the shufflingshuffling needs to act on the subset as welldesignit/R/osat.R
Line 142 in fb873c1
<1.>
bc |> optimize(scoring = "osat") |> group_by("plate") |> optimize(scoring = "2d")
<2.>
bc |> add_scoring_fun("osat", "plate") |> optimize() |> group_by("plate") |> add_scoring_fun("2d") |> optimize()
this should be generalizable to any grouping by batch, etc.
even more general:
bc |> add_scoring_fun("osat", "plate") |> add_shuffling_fun("row_swap") |> optimize()
The text was updated successfully, but these errors were encountered: