Skip to content

Remove some measures, update some others #60

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ Collate:
'regr_msle.R'
'regr_pbias.R'
'regr_pinball.R'
'regr_rae.R'
'regr_rmse.R'
'regr_rmsle.R'
'regr_rrse.R'
'regr_rse.R'
'regr_rsq.R'
'regr_sae.R'
'regr_se.R'
'regr_sle.R'
Expand Down
4 changes: 0 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,9 @@ export(pinball)
export(ppv)
export(prauc)
export(precision)
export(rae)
export(recall)
export(rmse)
export(rmsle)
export(rrse)
export(rse)
export(rsq)
export(sae)
export(se)
export(sensitivity)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# mlr3measures (development version)

* BREAKIG CHANGE: removed `rse`, `rsq`, `rrse`, and `rae`.

# mlr3measures 1.0.0

* Added new measure `linex` (Linear-Exponential Loss).
Expand Down
6 changes: 3 additions & 3 deletions R/classif_acc.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#' @details
#' The Classification Accuracy is defined as
#' \deqn{
#' \frac{1}{n} \sum_{i=1}^n w_i \mathbf{1} \left( t_i = r_i \right),
#' }{1 / n * sum(wi * 1(ti = ri))}
#' where \eqn{w_i} are normalized weights for all observations \eqn{x_i}.
#' \sum_{i=1}^n w_i \mathbf{1} \left( t_i = r_i \right),
#' }{sum(wi * 1(ti = ri))}
#' where \eqn{w_i} are weights normalized to sum to 1 for all observations \eqn{x_i}.
#'
#' @templateVar mid acc
#' @template classif_template
Expand Down
8 changes: 8 additions & 0 deletions R/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ wmean = function(x, w) { # a better stats::weighted.mean
sum(x * (w / sum(w)))
}

wsum = function(x, w) { # sum(w * x) that asserts w and accepts NULL
if (is.null(w)) {
return(sum(x))
}
assert_numeric(w, lower = 0, finite = TRUE, any.missing = FALSE, len = length(x))
sum(x * w)
}

# confusion matrix
cm = function(truth, response, positive = NULL) {
if (!is.null(positive)) {
Expand Down
27 changes: 0 additions & 27 deletions R/regr_rae.R

This file was deleted.

31 changes: 0 additions & 31 deletions R/regr_rrse.R

This file was deleted.

31 changes: 0 additions & 31 deletions R/regr_rse.R

This file was deleted.

33 changes: 0 additions & 33 deletions R/regr_rsq.R

This file was deleted.

15 changes: 11 additions & 4 deletions R/regr_sae.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@
#'
#' @details
#' The Sum of Absolute Errors is defined as \deqn{
#' \sum_{i=1}^n \left| t_i - r_i \right|.
#' \sum_{i=1}^n w_i \left| t_i - r_i \right|.
#' }{
#' sum(abs((t - r))).
#' sum(w * abs((t - r))).
#' }
#' where \eqn{w_i} are unnormalized weights for each observation \eqn{x_i}, defaulting to 1.
#'
#' @templateVar mid sae
#' @template regr_template
#'
#' @param sample_weights (`numeric()`)\cr
#' Vector of non-negative and finite sample weights.
#' Must have the same length as `truth`.
#' Weights for this function are not normalized.
#' Defaults to sample weights 1.
#'
#' @inheritParams regr_params
#' @template regr_example
#' @export
sae = function(truth, response, ...) {
sae = function(truth, response, sample_weights = NULL, ...) {
assert_regr(truth, response = response)
sum(.ae(truth, response))
sum(.ae(truth, response), sample_weights)
}

#' @include measures.R
Expand Down
15 changes: 11 additions & 4 deletions R/regr_sse.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@
#'
#' @details
#' The Sum of Squared Errors is defined as \deqn{
#' \sum_{i=1}^n \left( t_i - r_i \right)^2.
#' \sum_{i=1}^n w_i \left( t_i - r_i \right)^2.
#' }{
#' sum((t - r)^2).
#' sum(w * (t - r)^2).
#' }
#' where \eqn{w_i} are unnormalized weights for each observation \eqn{x_i}, defaulting to 1.
#'
#' @templateVar mid sse
#' @template regr_template
#'
#' @param sample_weights (`numeric()`)\cr
#' Vector of non-negative and finite sample weights.
#' Must have the same length as `truth`.
#' Weights for this function are not normalized.
#' Defaults to sample weights 1.
#'
#' @inheritParams regr_params
#' @template regr_example
#' @export
sse = function(truth, response, ...) {
sse = function(truth, response, sample_weights = NULL, ...) {
assert_regr(truth, response = response)
sum(.se(truth, response))
wsum(.se(truth, response), sample_weights)
}

#' @include measures.R
Expand Down
6 changes: 3 additions & 3 deletions man/acc.Rd

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

4 changes: 0 additions & 4 deletions man/ae.Rd

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

4 changes: 0 additions & 4 deletions man/ape.Rd

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

4 changes: 0 additions & 4 deletions man/bias.Rd

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

4 changes: 0 additions & 4 deletions man/ktau.Rd

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

4 changes: 0 additions & 4 deletions man/linex.Rd

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

4 changes: 0 additions & 4 deletions man/mae.Rd

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

4 changes: 0 additions & 4 deletions man/mape.Rd

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

4 changes: 0 additions & 4 deletions man/maxae.Rd

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

4 changes: 0 additions & 4 deletions man/maxse.Rd

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

2 changes: 1 addition & 1 deletion man/measures.Rd

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

Loading
Loading