-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests and make a proposal for changes
- Loading branch information
Showing
5 changed files
with
98 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# https://test.openml.org/api/v1/evaluation/setup/list/flow/2117/task/403/limit/100 works, while https://test.openml.org/api/v1/evaluation/setup/list/flow/6794 returns nothing. | ||
|
||
# Result size limits are okay, as long as I can somehow reliably iterate with the offset, i.e. | ||
# https://test.openml.org/api/v1/evaluation/setup/list/flow/2117/task/403/function/predictive_accuracy/limit/1/offset/2 | ||
|
||
|
||
|
||
#' @title Extract Parameters from an OpenML run into a flat structure | ||
#' | ||
#' @param run.evals [\code{data.frame}]\cr | ||
#' Result of caling listOMLRunEvaluations(..., setup = TRUE). | ||
#' @param drop.constant [\code{logical(1)]\cr | ||
#' Should constant columns be dropped before returning the result? | ||
#' | ||
#' @return [\code{\link{data.table}}]. | ||
#' @family run-related functions | ||
#' @export | ||
convertOMLRunEvalsToDT = function(run.evals, drop.constant = TRUE) { | ||
assert_data_frame(run.evals) | ||
assert_true(!is.null(run.evals$setup_parameters)) | ||
assert_flag(drop.constant) | ||
setup_params = run.evals$setup_parameters | ||
out = lapply(setup_params, function(params) { | ||
params[!(parameter_name == "verbose" & data_type == "boolean"), ] | ||
params[, convertValueByType(parameter_name, value, data_type)] | ||
}) | ||
dt = rbindlist(out, fill = TRUE) | ||
if (drop.constant) dt = dt[, vlapply(dt, function(x) length(unique(x)) > 1), with =FALSE] | ||
run.evals$setup_parameters = NULL | ||
return(cbind(run.evals, dt)) | ||
} | ||
|
||
|
||
# Convert values according to a parameter's type. | ||
# Note that this is very unreliably. | ||
convertValueByType = function(parameter_name, value, type) { | ||
value = Map(function(v, t) { | ||
v[v == "None" | v == "none" | v == "Null" | v == "null"] = NA | ||
v = gsub(""", "", v) | ||
if (t %in% c("boolean", "bool")) v = as.logical(v) | ||
else if (t %in% c("float", "number")) v = as.numeric(v) | ||
else if (t %in% c("int", "integer", "int or None", "integer or None")) v = suppressWarnings(as.integer(v)) | ||
return(v) | ||
}, value, type) | ||
names(value) = gsub(""", "", parameter_name) | ||
return(as.data.table(value)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 957dca1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R/convertOMLSetupParamsToDT.R:28:85: style: Put spaces around all infix operators (except exponentiation).
if (drop.constant) dt = dt[, vlapply(dt, function(x) length(unique(x)) > 1), with =FALSE]
^~
R/listOMLRunEvaluations.R:23:76: style: Commas should always have a space after.
parameters = as.data.table(cleanupSetupParameters(x$parameters))[-25,]
^
what is the[-25, ] for :D? Does this make sense in every API call?