Skip to content

Commit b2dbed8

Browse files
corybrunsonhfrick
andauthored
dials for 'ordinal_reg' models (#435)
* add polr method (ordinal link function) as tuning parameter * increment version number + update ordinal_link documentation * draft new dials for rpartScore params * typo * move engine-specific dials to ordered * oops - complete last commit * introduce odds_link param * note need to harmonize ordinal_link options * add caution re engines and link functions * add tests for ordinal_reg model params * rename cumulative_logits to cumulative_link * add news entry for ordinal_reg dials * touch-ups --------- Co-authored-by: Hannah Frick <hannah@posit.co>
1 parent a8a8e92 commit b2dbed8

7 files changed

Lines changed: 121 additions & 1 deletion

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dials
22
Title: Tools for Creating Tuning Parameter Values
3-
Version: 1.4.2.9000
3+
Version: 1.4.2.9001
44
Authors@R: c(
55
person("Max", "Kuhn", , "max@posit.co", role = "aut"),
66
person("Hannah", "Frick", , "hannah@posit.co", role = c("aut", "cre")),

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export(num_random_splits)
129129
export(num_runs)
130130
export(num_terms)
131131
export(num_tokens)
132+
export(odds_link)
133+
export(ordinal_link)
132134
export(over_ratio)
133135
export(parameters)
134136
export(parameters_constr)
@@ -206,6 +208,8 @@ export(values_activation)
206208
export(values_cal_cls)
207209
export(values_cal_reg)
208210
export(values_initial_umap)
211+
export(values_odds_link)
212+
export(values_ordinal_link)
209213
export(values_prune_method)
210214
export(values_regularization_method)
211215
export(values_scheduler)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# dials (development version)
22

3+
* `ordinal_link()` and `odds_link()` are two new parameters for the new `ordinal_reg()` models in parsnip (@corybrunson, #435).
4+
35
* A bug was fixed where some space-filling designs did not respect the `original` argument (#409).
46

57
* Parameters were added for the `tab_pfn` model: `num_estimators()`, `softmax_temperature()`, `balance_probabilities()`, `average_before_softmax()`, and `training_set_limit()`.

R/param_ordinal_link.R

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#' Ordinal Regression Link Functions (character)
2+
#'
3+
#' The ordinal and odds link functions of an ordinal regression model.
4+
#'
5+
#' @param values For `*_link()`, a character string from among the possible
6+
#' values encoded in `values_*_link`. See the examples below.
7+
#'
8+
#' @details These parameters are used by ordinal regression models specified by
9+
#' `parsnip::ordinal_reg()`, for example `parsnip::set_engine('polr')`. The
10+
#' nomenclature is taken from Wurm et al (2021), who characterize the pair of
11+
#' functions as a composite link function. Note that different engines support
12+
#' different subsets of link functions.
13+
#'
14+
#' @references Wurm, Michael J., Rathouz, Paul J., & Hanlon, Bret M. (2021).
15+
#' Regularized Ordinal Regression and the ordinalNet R Package. _Journal of
16+
#' Statistical Software_, 99(6), 1–42. 10.18637/jss.v099.i06
17+
#' @examples
18+
#' values_ordinal_link
19+
#' ordinal_link()
20+
#' values_odds_link
21+
#' odds_link()
22+
#' @export
23+
ordinal_link <- function(values = values_ordinal_link) {
24+
new_qual_param(
25+
type = "character",
26+
values = values,
27+
label = c(ordinal_link = "Ordinal Link"),
28+
finalize = NULL
29+
)
30+
}
31+
32+
#' @rdname ordinal_link
33+
#' @export
34+
values_ordinal_link <- c(
35+
"logistic",
36+
"probit",
37+
"loglog",
38+
"cloglog",
39+
"cauchit"
40+
)
41+
42+
#' @rdname ordinal_link
43+
#' @export
44+
odds_link <- function(values = values_odds_link) {
45+
new_qual_param(
46+
type = "character",
47+
values = values,
48+
label = c(odds_link = "Odds Link"),
49+
finalize = NULL
50+
)
51+
}
52+
53+
#' @rdname ordinal_link
54+
#' @export
55+
values_odds_link <- c(
56+
"cumulative_link",
57+
"adjacent_categories",
58+
"continuation_ratio",
59+
"stopping_ratio"
60+
)

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ reference:
8484
- num_comp
8585
- num_estimators
8686
- num_knots
87+
- ordinal_link
8788
- penalty
8889
- predictor_prop
8990
- prune_method

man/ordinal_link.Rd

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-params.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,8 @@ test_that("param values", {
199199
expect_equal(cal_method_reg()$values, values_cal_reg)
200200
expect_equal(balance_probabilities(TRUE)$values, TRUE)
201201
expect_equal(average_before_softmax(TRUE)$values, TRUE)
202+
expect_equal(ordinal_link(letters[1:3])$values, letters[1:3])
203+
expect_equal(ordinal_link()$values, values_ordinal_link)
204+
expect_equal(odds_link(letters[4:6])$values, letters[4:6])
205+
expect_equal(odds_link()$values, values_odds_link)
202206
})

0 commit comments

Comments
 (0)