Skip to content

Commit 68d22a2

Browse files
committed
removed S3 classes to create models for issue #2
1 parent 0704312 commit 68d22a2

File tree

9 files changed

+53
-77
lines changed

9 files changed

+53
-77
lines changed

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
S3method(finalize,logistic_reg)
44
S3method(finalize,rand_forest)
55
S3method(fit,model_spec)
6-
S3method(logistic_reg,default)
76
S3method(print,logistic_reg)
87
S3method(print,rand_forest)
9-
S3method(rand_forest,default)
108
S3method(update,logistic_reg)
119
S3method(update,rand_forest)
1210
export(finalize)

R/logistic_reg.R

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727
#' \item \pkg{Stan}: `"rstanarm"`
2828
#' \item \pkg{Spark}: `"spark"`
2929
#' }
30-
#' @export
31-
#' @rdname logistic_reg
32-
#' @importFrom rlang expr enquo missing_arg
33-
#' @importFrom purrr map_lgl
34-
#' @seealso [varying()], [fit()]
35-
#' @examples
36-
#' logistic_reg()
37-
#'
38-
#' # Parameters can be represented by a placeholder:
39-
#' logistic_reg(regularization = varying())
40-
41-
logistic_reg <- function (mode, ...)
42-
UseMethod("logistic_reg")
43-
44-
#' @rdname logistic_reg
45-
#' @export
4630
#' @param mode A single character string for the type of model.
4731
#' The only possible value for this model is "classification".
4832
#' @param engine_args A named list of arguments to be used by the
@@ -58,9 +42,17 @@ logistic_reg <- function (mode, ...)
5842
#' (the lasso).
5943
#' @param ... Used for S3 method consistency. Any arguments passed to
6044
#' the ellipses will result in an error. Use `engine_args` instead.
45+
#' @seealso [varying()], [fit()]
46+
#' @examples
47+
#' logistic_reg()
48+
#'
49+
#' # Parameters can be represented by a placeholder:
50+
#' logistic_reg(regularization = varying())
51+
#' @export
6152

62-
63-
logistic_reg.default <-
53+
#' @importFrom rlang expr enquo missing_arg
54+
#' @importFrom purrr map_lgl
55+
logistic_reg <-
6456
function(mode = "classification",
6557
regularization = NULL,
6658
mixture = NULL,

R/rand_forest.R

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,12 @@
2626
#' to determine the _mode_ of the model. For `rand_forest`, the
2727
#' possible modes are "regression" and "classification".
2828
#'
29-
#' The model can be created using the [fit()] function using the
29+
#' The model can be created using the [fit()] function using the
3030
#' following _engines_:
3131
#' \itemize{
3232
#' \item \pkg{R}: `"ranger"` or `"randomForests"`
3333
#' \item \pkg{Spark}: `"spark"`
3434
#' }
35-
#' @export
36-
#' @rdname rand_forest
37-
#' @importFrom rlang expr enquo missing_arg
38-
#' @importFrom purrr map_lgl
39-
#' @seealso [varying()], [fit()]
40-
#' @examples
41-
#' rand_forest(mode = "classification", trees = 2000)
42-
#'
43-
#' # Parameters can be represented by a placeholder:
44-
#' rand_forest(mode = "regression", mtry = varying())
45-
46-
rand_forest <- function (mode, ...)
47-
UseMethod("rand_forest")
48-
49-
#' @rdname rand_forest
50-
#' @export
5135
#' @param mode A single character string for the type of model.
5236
#' Possible values for this model are "unknown", "regression", or
5337
#' "classification".
@@ -64,8 +48,17 @@ rand_forest <- function (mode, ...)
6448
#' in a node that are required for the node to be split further.
6549
#' @param ... Used for method consistency. Any arguments passed to
6650
#' the ellipses will result in an error. Use `engine_args` instead.
51+
#' @importFrom rlang expr enquo missing_arg
52+
#' @importFrom purrr map_lgl
53+
#' @seealso [varying()], [fit()]
54+
#' @examples
55+
#' rand_forest(mode = "classification", trees = 2000)
56+
#'
57+
#' # Parameters can be represented by a placeholder:
58+
#' rand_forest(mode = "regression", mtry = varying())
59+
#' @export
6760

68-
rand_forest.default <-
61+
rand_forest <-
6962
function(mode = "unknown",
7063
mtry = NULL, trees = NULL, min_n = NULL,
7164
engine_args = list(),

docs/articles/parsnip_Intro.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/logistic_reg.html

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

docs/reference/rand_forest.html

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

man/logistic_reg.Rd

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

man/rand_forest.Rd

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

vignettes/parsnip_Intro.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Commonly used arguments to the modeling functions have their parameters exposed
7474
The arguments to the default function are:
7575

7676
```{r rf-def}
77-
args(parsnip:::rand_forest.default)
77+
args(rand_forest)
7878
```
7979

8080
However, there might be other arguments that you would like to change or allow to vary. These are accessible using the `engine_args` option. This is a named list of arguments in the form of the underlying function being called. For example, `ranger` has an option to set the internal random number seed. To set this to a specific value:

0 commit comments

Comments
 (0)