From ed3ab7e7c4e342d3c382c3a9a663601d7c82b530 Mon Sep 17 00:00:00 2001 From: Marvin Wright Date: Wed, 6 Nov 2024 11:24:59 +0100 Subject: [PATCH] fix docs/exports --- NAMESPACE | 2 ++ R/hshrink.R | 3 +++ R/print.R | 2 ++ man/hshrink.Rd | 5 +++++ 4 files changed, 12 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 64d06c481..6dd599111 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,8 @@ S3method(print,deforest.ranger) S3method(print,ranger) S3method(print,ranger.forest) S3method(print,ranger.prediction) +S3method(str,ranger) +S3method(str,ranger.forest) S3method(timepoints,ranger) S3method(timepoints,ranger.prediction) export(csrf) diff --git a/R/hshrink.R b/R/hshrink.R index 001866f4f..45794e847 100644 --- a/R/hshrink.R +++ b/R/hshrink.R @@ -39,6 +39,9 @@ #' @return The ranger object is modified in-place. #' #' @examples +#' ## Hierarchical shrinkage for a probablity forest +#' rf <- ranger(Species ~ ., iris, node.stats = TRUE, probability = TRUE) +#' hshrink(rf, lambda = 5) ##' @references ##' \itemize{ ##' \item Agarwal, A., Tan, Y.S., Ronen, O., Singh, C. & Yu, B. (2022). Hierarchical Shrinkage: Improving the accuracy and interpretability of tree-based models. Proceedings of the 39th International Conference on Machine Learning, PMLR 162:111-135. diff --git a/R/print.R b/R/print.R index 90e78bc2b..8f02bf096 100644 --- a/R/print.R +++ b/R/print.R @@ -103,11 +103,13 @@ print.ranger.prediction <- function(x, ...) { } } +##' @export str.ranger.forest <- function(object, max.level = 2, ...) { class(object) <- "list" str(object, max.level = max.level, ...) } +##' @export str.ranger <- function(object, max.level = 2, ...) { class(object) <- "list" str(object, max.level = max.level, ...) diff --git a/man/hshrink.Rd b/man/hshrink.Rd index e48c9a2e9..fd813e59a 100644 --- a/man/hshrink.Rd +++ b/man/hshrink.Rd @@ -19,6 +19,11 @@ Apply hierarchical shrinkage to a ranger object. Hierarchical shrinkage is a regularization technique that recursively shrinks node predictions towards parent node predictions. For details see Agarwal et al. (2022). } +\examples{ +## Hierarchical shrinkage for a probablity forest +rf <- ranger(Species ~ ., iris, node.stats = TRUE, probability = TRUE) +hshrink(rf, lambda = 5) +} \references{ \itemize{ \item Agarwal, A., Tan, Y.S., Ronen, O., Singh, C. & Yu, B. (2022). Hierarchical Shrinkage: Improving the accuracy and interpretability of tree-based models. Proceedings of the 39th International Conference on Machine Learning, PMLR 162:111-135.