Skip to content

Commit

Permalink
fixes for pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Nov 9, 2023
1 parent 2aa2497 commit e0a79fb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 80 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
76 changes: 2 additions & 74 deletions R/orsf_print.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
Expand Down
5 changes: 3 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions man/print.orsf_fit.Rd → man/print.ObliqueForest.Rd

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

0 comments on commit e0a79fb

Please sign in to comment.