Skip to content

BenchmarkScore implementation#36

Open
bblodfon wants to merge 14 commits into
mlr-org:mainfrom
bblodfon:main
Open

BenchmarkScore implementation#36
bblodfon wants to merge 14 commits into
mlr-org:mainfrom
bblodfon:main

Conversation

@bblodfon

Copy link
Copy Markdown

No description provided.

@bblodfon

Copy link
Copy Markdown
Author

@sebffischer still needs some discussion about documentation, etc. before reviewing

* remove independent parameter
* better doc
* no check for ntasks as this class is the container only
@bblodfon

Copy link
Copy Markdown
Author

@berndbischl @sebffischer please review - it's just the new container Class. I will do a new PR with the refactoring of BenchmarkAggr and the separate tests.

@bblodfon

Copy link
Copy Markdown
Author

So I removed the independent parameter, since this will be decided based on the test you use, not the container/class of the benchmarking results

@sebffischer sebffischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot already, looking good! :) Just let me know when you disagree on something

Comment thread R/BenchmarkAggr.R
#' for example the result of [mlr3::BenchmarkResult]`$aggregate` or via [as_benchmark_aggr],
#' or by passing in a custom dataset of results. Custom datasets must include at the very least,
#' a character column for learner ids, a character column for task ids, and numeric columns for
#' a factor column for learner ids, a factor column for task ids, and numeric columns for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this incorrectly documented or why was this changed?

Comment thread R/BenchmarkAggr.R
#' @param task_id (`factor(1)`) \cr
#' String specifying name of task id column.
#' @param learner_id (`character(1)`)\cr
#' @param learner_id (`factor(1)`)\cr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why must this be a factor? I don't want to wrote learner_id = factor("regr.lm") I want to write learner_id = "regr.lm"

Comment thread R/BenchmarkAggr.R

#' @description Subsets the data by given tasks or learners.
#' Returns data as [data.table::data.table].
#' @param task (`character()`) \cr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might even tend to remove this subset method as it is rather a class method than an instance method (from which you would expect it to modify the instance in-place I guess, at least that would be in line with the rest of mlr3). What do you think?

Comment thread R/BenchmarkScore.R
#' # equivalently
#' as_benchmark_score(df, task_id = "tasks", learner_id = "learners", iteration = "iters")
#'
#' if (requireNamespaces(c("mlr3", "rpart"))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is require_namespaces() in mlr3misc, I think I would use it and remove the requireNamespaces helper function from mlr3benchmark as they do the same thing, no need to keep it twice.

Comment thread R/BenchmarkScore.R
#'
#' @details This class is used as a container of benchmarking results where
#' multiple learners (models) have been tested against multiple tasks (datasets)
#' using a resampling scheme. The results stored are the per-resampling

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it seems like the resampling scheme is the same for all task-learner combinations. Is this the case? Otherwise rephrase.

Comment thread R/BenchmarkScore.R
#' @field iterations `(numeric())` \cr Unique resampling iterations.
iterations = function() unique(private$.dt[[self$col_roles$iteration]]),
#' @field measures `(character())` \cr Unique measure names.
measures = function() setdiff(colnames(private$.dt), unlist(self$col_roles)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't really support adding measures, right? so we can also compute this once and return it here

Comment thread R/BenchmarkScore.R

private = list(
.col_roles = character(0),
.dt = data.table()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually we initialize everything to NULL

Comment thread R/BenchmarkScore.R
)
)

#' @title Coercions to BenchmarkScore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @title Coercions to BenchmarkScore
#' @title Conversion to BenchmarkScore

Comment thread R/BenchmarkScore.R

#' @title Coercions to BenchmarkScore
#'
#' @description Coercion methods to [BenchmarkScore].

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#' @description Coercion methods to [BenchmarkScore].
#' @description Conversion methods to [BenchmarkScore].

loss$lower = loss[, meas] - se * stats::qnorm(1 - (1 - level) / 2)
loss$upper = loss[, meas] + se * stats::qnorm(1 - (1 - level) / 2)
ggplot(data = loss, aes_string(x = object$col_roles$learner_id, y = meas)) +
ggplot(data = loss, aes(x = .data[[object$col_roles$learner_id]], y = .data[[meas]])) +

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to set .data to NULL otherwise some tools will complain that it does not exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants