diff --git a/NAMESPACE b/NAMESPACE index eb065677..9d2fee38 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,7 +2,7 @@ S3method(as.data.table,orsf_summary_uni) S3method(predict,ObliqueForest) -S3method(print,orsf_fit) +S3method(print,ObliqueForest) S3method(print,orsf_summary_uni) export(orsf) export(orsf_control_cph) diff --git a/R/orsf_print.R b/R/orsf_print.R index 5aa13764..77c2eb69 100644 --- a/R/orsf_print.R +++ b/R/orsf_print.R @@ -32,81 +32,9 @@ #' #' print(object) #' -print.orsf_fit <- function(x, ...){ - - control <- get_control(x) - info_tree_type <- get_tree_type(x) - info_n_obs <- get_n_obs(x) - info_n_events <- get_n_events(x) %||% "TBD" - info_n_tree <- get_n_tree(x) - info_n_leaves_mean <- round_magnitude(get_n_leaves_mean(x)) %O% "TBD" - info_max_time <- get_max_time(x) - info_mtry <- get_mtry(x) %||% "TBD" - info_names_x <- get_names_x(x) - info_leaf_min_obs <- get_leaf_min_obs(x) - info_vi <- get_importance(x) - info_leaf_min_events <- get_leaf_min_events(x) - - info_model_type <- switch(info_tree_type, - 'survival' = "Cox regression", - 'regression' = "Linear regression", - 'classification' = "Logistic regression") - - info_lincomb_type <- switch(control$lincomb_type, - 'glm' = NULL, - 'net' = "Penalized ", - 'custom' = "Custom user function") - - - if(control$lincomb_type != 'custom'){ - - if(control$lincomb_iter_max == 1){ - info_lincomb_type <- "Accelerated " - } - - info_lincomb_type <- paste0(info_lincomb_type, info_model_type) - - } - - info_oobag_type <- info_oobag_stat <- 'none' - - if(contains_oobag(x)){ - - info_oobag_type <- x$eval_oobag$stat_type - - info_oobag_stat <- "Not estimated" - - if(is_trained(x)){ - info_oobag_stat <- round_magnitude(last_value(x$eval_oobag$stat_values)) - } - - } - - - forest_text <- paste("Oblique random", info_tree_type, "forest") - - header <- paste0('---------- ', forest_text, '\n') - - if(!is_trained(x)){ - header <- paste0('Untrained ', tolower(forest_text), '\n') - } - - cat(header, - paste0(' Linear combinations: ', info_lincomb_type ), - paste0(' N observations: ', info_n_obs ), - paste0(' N events: ', info_n_events ), - paste0(' N trees: ', info_n_tree ), - paste0(' N predictors total: ', length(info_names_x) ), - paste0(' N predictors per node: ', info_mtry ), - paste0(' Average leaves per tree: ', info_n_leaves_mean ), - paste0('Min observations in leaf: ', info_leaf_min_obs ), - paste0(' Min events in leaf: ', info_leaf_min_events ), - paste0(' OOB stat value: ', info_oobag_stat ), - paste0(' OOB stat type: ', info_oobag_type ), - paste0(' Variable importance: ', info_vi ), - '\n-----------------------------------------', - sep = '\n') +print.ObliqueForest <- function(x, ...){ + x$print() invisible(x) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 8788136a..91f613b7 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -23,8 +23,8 @@ reference: desc: Fit, inspect, summarize, and apply ORSF models - contents: - matches("^orsf$") - - matches("^print\\.orsf_fit$") - - matches("^predict\\.orsf_fit$") + - matches("^print\\.ObliqueForest$") + - matches("^predict\\.ObliqueForest$") - matches("^orsf_summarize") - matches("^print\\.orsf_summary") - title: Control how your ORSF model works @@ -45,6 +45,7 @@ reference: desc: Datasets used in examples and vignettes. - contents: - matches("^pbc_orsf$") + - matches("^penguins_orsf$") - title: Miscellaneous desc: Functions that don't fit neatly into a category above, but are still helpful. - contents: diff --git a/man/print.orsf_fit.Rd b/man/print.ObliqueForest.Rd similarity index 93% rename from man/print.orsf_fit.Rd rename to man/print.ObliqueForest.Rd index db20fb9f..b8397493 100644 --- a/man/print.orsf_fit.Rd +++ b/man/print.ObliqueForest.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/orsf_print.R -\name{print.orsf_fit} -\alias{print.orsf_fit} +\name{print.ObliqueForest} +\alias{print.ObliqueForest} \title{Inspect your ORSF model} \usage{ -\method{print}{orsf_fit}(x, ...) +\method{print}{ObliqueForest}(x, ...) } \arguments{ \item{x}{(\emph{orsf_fit}) an oblique random survival forest (ORSF; see \link{orsf}).}