diff --git a/R/orsf_R6.R b/R/orsf_R6.R index 05cdfabf..5c141630 100644 --- a/R/orsf_R6.R +++ b/R/orsf_R6.R @@ -156,163 +156,90 @@ ObliqueForest <- R6::R6Class( }, # Update: re-initialize if dynamic args were unspecified - update = function(data = NULL, - formula = NULL, - control = NULL, - weights = NULL, - n_tree = NULL, - n_split = NULL, - n_retry = NULL, - n_thread = NULL, - mtry = NULL, - sample_with_replacement = NULL, - sample_fraction = NULL, - leaf_min_events = NULL, - leaf_min_obs = NULL, - split_rule = NULL, - split_min_events = NULL, - split_min_obs = NULL, - split_min_stat = NULL, - pred_type = NULL, - oobag_pred_horizon = NULL, - oobag_eval_every = NULL, - oobag_fun = NULL, - importance = NULL, - importance_max_pvalue = NULL, - group_factors = NULL, - tree_seeds = NULL, - na_action = NULL, - verbose_progress = NULL) { - - if(!is.null(formula)){ - terms_old <- terms(self$formula, data = data %||% self$data) - self$formula <- stats::update(as.formula(terms_old), new = formula) - } + update = function(args) { # for args with default values of NULL, keep track of whether # user specified them or not. If they were un-specified, then # the standard init() function is called. If they were specified, # the standard check function is called. - # this allows someone to set control to NULL and revert # to using a default control for the given forest. - if(is.null(control)){ - private$user_specified$control <- FALSE - } else { - self$control <- control - private$user_specified$control <- TRUE - } - - - if(is.null(weights)){ - private$user_specified$weights <- FALSE - } else { - self$weights <- weights - private$user_specified$weights <- TRUE - } - if(!is.null(n_tree)) - self$n_tree <- n_tree + data <- args$data %||% self$data - if(!is.null(n_split)) - self$n_split <- n_split - - if(!is.null(n_retry)) - self$n_retry <- n_retry - - if(!is.null(n_thread)) - self$n_thread <- n_thread - - if(is.null(mtry)){ - private$user_specified$mtry <- FALSE - } else { - self$mtry <- mtry - private$user_specified$mtry <- TRUE + if("formula" %in% names(args)){ + formula <- args[['formula']] + terms_old <- terms(self$formula, data = data) + self$formula <- stats::update(as.formula(terms_old), new = formula) } - if(!is.null(sample_with_replacement)) - self$sample_with_replacement <- sample_with_replacement + null_defaults <- c( + control = "control", + weights = "weights", + mtry = "mtry", + split_rule = "split_rule", + split_min_stat = "split_min_stat", + pred_type = "oobag_pred_type", + pred_horizon = "oobag_pred_horizon", + oobag_eval_every = "oobag_eval_every", + oobag_eval_function = "oobag_fun", + tree_seeds = "tree_seeds" + ) - if(!is.null(sample_fraction)) - self$sample_fraction <- sample_fraction + hard_defaults <- c( + n_tree = "n_tree", + n_split = "n_split", + n_retry = "n_retry", + n_thread = "n_thread", + sample_with_replacement = "sample_with_replacement", + sample_fraction = "sample_fraction", + leaf_min_events = "leaf_min_events", + leaf_min_obs = "leaf_min_obs", + split_min_events = "split_min_events", + split_min_obs = "split_min_obs", + importance = "importance", + importance_max_pvalue = "importance_max_pvalue", + importance_group_factors = "group_factors", + na_action = "na_action", + verbose_progress = "verbose_progress" + ) - if(!is.null(leaf_min_events)) - self$leaf_min_events <- leaf_min_events + for( i in seq_along(null_defaults) ){ - if(!is.null(leaf_min_obs)) - self$leaf_min_obs <- leaf_min_obs + input_name <- null_defaults[i] + if(input_name %in% names(args)){ - if(is.null(split_rule)){ - private$user_specified$split_rule <- FALSE - } else { - self$split_rule <- split_rule - private$user_specified$split_rule <- TRUE - } + input <- args[[input_name]] - if(!is.null(split_min_events)) - self$split_min_events <- split_min_events + r6_name <- names(null_defaults)[i] - if(!is.null(split_min_obs)) - self$split_min_obs <- split_min_obs + if(is.null(input)){ + private$user_specified[[r6_name]] <- FALSE + } else { + self[[r6_name]] <- input + private$user_specified[[r6_name]] <- TRUE + } - if(is.null(split_min_stat)){ - private$user_specified$split_min_stat <- FALSE - } else { - self$split_min_stat <- split_min_stat - private$user_specified$split_min_stat <- TRUE - } + } - if(is.null(pred_type)){ - private$user_specified$pred_type <- FALSE - } else { - self$pred_type <- pred_type - private$user_specified$pred_type <- TRUE } - if(is.null(oobag_pred_horizon)){ - private$user_specified$pred_horizon <- FALSE - } else { - self$pred_horizon <- oobag_pred_horizon - private$user_specified$pred_horizon <- TRUE - } + for(i in seq_along(hard_defaults)){ - if(is.null(oobag_eval_every)){ - private$user_specified$oobag_eval_every <- FALSE - } else { - self$oobag_eval_every <- oobag_eval_every - private$user_specified$oobag_eval_every <- TRUE - } + input_name <- hard_defaults[i] - if(is.null(oobag_fun)){ - private$user_specified$oobag_eval_function <- FALSE - } else { - self$oobag_eval_function <- oobag_fun - private$user_specified$oobag_eval_function <- TRUE - } + if(input_name %in% names(args)){ - if(!is.null(importance)) - self$importance_type <- importance + input <- args[[input_name]] + r6_name <- names(hard_defaults)[i] - if(!is.null(importance_max_pvalue)) - self$importance_max_pvalue <- importance_max_pvalue + self[[r6_name]] <- input - if(!is.null(group_factors)) - self$importance_group_factors <- group_factors + } - if(is.null(tree_seeds)){ - private$user_specified$tree_seeds <- FALSE - } else { - self$tree_seeds <- tree_seeds - private$user_specified$tree_seeds <- TRUE } - if(!is.null(na_action)) - self$na_action <- na_action - - if(!is.null(verbose_progress)) - self$verbose_progress <- verbose_progress - private$init(data = data) }, diff --git a/R/orsf_update.R b/R/orsf_update.R index 8d815379..4b27a131 100644 --- a/R/orsf_update.R +++ b/R/orsf_update.R @@ -102,7 +102,7 @@ orsf_update <- function(object, } - object_new$update(...) + object_new$update(.dots) if(no_fit){ diff --git a/man/orsf.Rd b/man/orsf.Rd index 53b64937..3f165380 100644 --- a/man/orsf.Rd +++ b/man/orsf.Rd @@ -388,9 +388,9 @@ penguin_fit ## N trees: 5 ## N predictors total: 7 ## N predictors per node: 3 -## Average leaves per tree: 4.4 +## Average leaves per tree: 5.6 ## Min observations in leaf: 5 -## OOB stat value: 0.98 +## OOB stat value: 0.97 ## OOB stat type: AUC-ROC ## Variable importance: anova ## @@ -415,7 +415,7 @@ bill_fit ## N trees: 5 ## N predictors total: 7 ## N predictors per node: 3 -## Average leaves per tree: 51.4 +## Average leaves per tree: 50.4 ## Min observations in leaf: 5 ## OOB stat value: 0.74 ## OOB stat type: RSQ @@ -446,10 +446,10 @@ pbc_fit ## N trees: 5 ## N predictors total: 17 ## N predictors per node: 5 -## Average leaves per tree: 21.8 +## Average leaves per tree: 20.6 ## Min observations in leaf: 5 ## Min events in leaf: 1 -## OOB stat value: 0.79 +## OOB stat value: 0.77 ## OOB stat type: Harrell's C-index ## Variable importance: anova ## @@ -496,7 +496,7 @@ take to fit the forest before you commit to it: orsf_time_to_train() }\if{html}{\out{}} -\if{html}{\out{
}}\preformatted{## Time difference of 2.256203 secs +\if{html}{\out{
}}\preformatted{## Time difference of 3.403997 secs }\if{html}{\out{
}} \enumerate{ \item If fitting multiple forests, use the blueprint along with @@ -567,12 +567,12 @@ brier_scores \if{html}{\out{
}}\preformatted{## # A tibble: 6 x 4 ## .metric .estimator .eval_time .estimate ## -## 1 brier_survival standard 500 0.0477 -## 2 brier_survival standard 1000 0.0851 -## 3 brier_survival standard 1500 0.0988 -## 4 brier_survival standard 2000 0.126 -## 5 brier_survival standard 2500 0.159 -## 6 brier_survival standard 3000 0.198 +## 1 brier_survival standard 500 0.0608 +## 2 brier_survival standard 1000 0.0877 +## 3 brier_survival standard 1500 0.0860 +## 4 brier_survival standard 2000 0.0761 +## 5 brier_survival standard 2500 0.0857 +## 6 brier_survival standard 3000 0.114 }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{roc_scores <- test_pred \%>\% @@ -584,12 +584,12 @@ roc_scores \if{html}{\out{
}}\preformatted{## # A tibble: 6 x 4 ## .metric .estimator .eval_time .estimate ## -## 1 roc_auc_survival standard 500 0.966 +## 1 roc_auc_survival standard 500 0.980 ## 2 roc_auc_survival standard 1000 0.943 -## 3 roc_auc_survival standard 1500 0.937 -## 4 roc_auc_survival standard 2000 0.923 -## 5 roc_auc_survival standard 2500 0.911 -## 6 roc_auc_survival standard 3000 0.881 +## 3 roc_auc_survival standard 1500 0.960 +## 4 roc_auc_survival standard 2000 0.973 +## 5 roc_auc_survival standard 2500 0.961 +## 6 roc_auc_survival standard 3000 0.950 }\if{html}{\out{
}} } } diff --git a/man/orsf_control.Rd b/man/orsf_control.Rd index 3009240f..ad2aff3c 100644 --- a/man/orsf_control.Rd +++ b/man/orsf_control.Rd @@ -310,13 +310,14 @@ The AUC values, from highest to lowest: \if{html}{\out{
}}\preformatted{sc$AUC$score[order(-AUC)] }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## model times AUC se lower upper -## 1: net 1788 0.9151649 0.02025057 0.8754745 0.9548553 -## 2: rlt 1788 0.9136390 0.02013475 0.8741756 0.9531024 -## 3: accel 1788 0.9095628 0.02143250 0.8675558 0.9515697 -## 4: cph 1788 0.9095628 0.02143250 0.8675558 0.9515697 -## 5: rando 1788 0.9062197 0.02148854 0.8641029 0.9483365 -## 6: pca 1788 0.8999479 0.02226683 0.8563057 0.9435901 +\if{html}{\out{
}}\preformatted{## model times AUC se lower upper +## +## 1: net 1788 0.9151649 0.02025057 0.8754745 0.9548553 +## 2: rlt 1788 0.9119200 0.02090107 0.8709547 0.9528854 +## 3: accel 1788 0.9095628 0.02143250 0.8675558 0.9515697 +## 4: cph 1788 0.9095628 0.02143250 0.8675558 0.9515697 +## 5: rando 1788 0.9062197 0.02148854 0.8641029 0.9483365 +## 6: pca 1788 0.8983266 0.02303267 0.8531834 0.9434698 }\if{html}{\out{
}} And the indices of prediction accuracy: @@ -325,11 +326,12 @@ And the indices of prediction accuracy: }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## model times IPA +## ## 1: net 1788 0.4905777 -## 2: accel 1788 0.4806065 -## 3: cph 1788 0.4806065 -## 4: rlt 1788 0.4687322 -## 5: pca 1788 0.4383995 +## 2: accel 1788 0.4806649 +## 3: cph 1788 0.4806649 +## 4: rlt 1788 0.4675228 +## 5: pca 1788 0.4369636 ## 6: rando 1788 0.4302814 ## 7: Null model 1788 0.0000000 }\if{html}{\out{
}} diff --git a/man/orsf_ice_oob.Rd b/man/orsf_ice_oob.Rd index 324abb21..ba498696 100644 --- a/man/orsf_ice_oob.Rd +++ b/man/orsf_ice_oob.Rd @@ -174,18 +174,20 @@ ice_oob <- orsf_ice_oob(fit_clsf, pred_spec = pred_spec) ice_oob }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## id_variable id_row class flipper_length_mm pred -## 1: 1 1 Adelie 190 0.92059968 -## 2: 1 2 Adelie 190 0.80953569 -## 3: 1 3 Adelie 190 0.84869374 -## 4: 1 4 Adelie 190 0.93559660 +\if{html}{\out{
}}\preformatted{## Key: +## id_variable id_row class flipper_length_mm pred +## +## 1: 1 1 Adelie 190 0.92169247 +## 2: 1 2 Adelie 190 0.80944657 +## 3: 1 3 Adelie 190 0.85172955 +## 4: 1 4 Adelie 190 0.93559327 ## 5: 1 5 Adelie 190 0.97708693 ## --- -## 896: 2 146 Gentoo 210 0.25636964 +## 896: 2 146 Gentoo 210 0.26092984 ## 897: 2 147 Gentoo 210 0.04798334 -## 898: 2 148 Gentoo 210 0.07945140 -## 899: 2 149 Gentoo 210 0.84811899 -## 900: 2 150 Gentoo 210 0.10695367 +## 898: 2 148 Gentoo 210 0.07927359 +## 899: 2 149 Gentoo 210 0.84779971 +## 900: 2 150 Gentoo 210 0.11105143 }\if{html}{\out{
}} There are two identifiers in the output: @@ -239,6 +241,7 @@ ice_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## id_variable id_row flipper_length_mm pred +## ## 1: 1 1 190 37.94483 ## 2: 1 2 190 37.61595 ## 3: 1 3 190 37.53681 @@ -264,6 +267,7 @@ ice_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## id_variable id_row species island body_mass_g pred +## ## 1: 1 1 Adelie Biscoe 3200 37.78339 ## 2: 1 2 Adelie Biscoe 3200 37.73273 ## 3: 1 3 Adelie Biscoe 3200 37.71248 @@ -289,6 +293,7 @@ ice_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## id_variable id_row variable value level pred +## ## 1: 1 1 species NA Adelie 37.74136 ## 2: 1 2 species NA Adelie 37.42367 ## 3: 1 3 species NA Adelie 37.04598 @@ -317,6 +322,7 @@ ice_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## id_variable id_row species island pred +## ## 1: 1 1 Adelie Biscoe 38.52327 ## 2: 1 2 Adelie Biscoe 38.32073 ## 3: 1 3 Adelie Biscoe 37.71248 @@ -354,18 +360,19 @@ Compute individual conditional expectation using in-bag data for ice_train }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred -## 1: 1 1 1826.25 1 0.1290317 -## 2: 1 2 1826.25 1 0.1242352 -## 3: 1 3 1826.25 1 0.0963452 -## 4: 1 4 1826.25 1 0.1172367 -## 5: 1 5 1826.25 1 0.2030256 -## --- -## 746: 5 146 1826.25 5 0.7868537 -## 747: 5 147 1826.25 5 0.2012954 -## 748: 5 148 1826.25 5 0.4893605 -## 749: 5 149 1826.25 5 0.4698220 -## 750: 5 150 1826.25 5 0.9557285 +\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred +## +## 1: 1 1 1826.25 1 0.1290317 +## 2: 1 2 1826.25 1 0.1242352 +## 3: 1 3 1826.25 1 0.0963452 +## 4: 1 4 1826.25 1 0.1172367 +## 5: 1 5 1826.25 1 0.2030256 +## --- +## 746: 5 146 1826.25 5 0.7868537 +## 747: 5 147 1826.25 5 0.2012954 +## 748: 5 148 1826.25 5 0.4893605 +## 749: 5 149 1826.25 5 0.4698220 +## 750: 5 150 1826.25 5 0.9557285 }\if{html}{\out{
}} If you don’t have specific values of a variable in mind, let @@ -375,18 +382,19 @@ If you don’t have specific values of a variable in mind, let ice_train }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred -## 1: 1 1 1826.25 0.59 0.11706741 -## 2: 1 2 1826.25 0.59 0.11562173 -## 3: 1 3 1826.25 0.59 0.09110739 -## 4: 1 4 1826.25 0.59 0.10069721 -## 5: 1 5 1826.25 0.59 0.18769751 -## --- -## 746: 5 146 1826.25 7.21 0.82600898 -## 747: 5 147 1826.25 7.21 0.29156437 -## 748: 5 148 1826.25 7.21 0.58220919 -## 749: 5 149 1826.25 7.21 0.54168688 -## 750: 5 150 1826.25 7.21 0.96204106 +\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred +## +## 1: 1 1 1826.25 0.55 0.11728559 +## 2: 1 2 1826.25 0.55 0.11728839 +## 3: 1 3 1826.25 0.55 0.08950739 +## 4: 1 4 1826.25 0.55 0.10064959 +## 5: 1 5 1826.25 0.55 0.18736417 +## --- +## 746: 5 146 1826.25 7.25 0.82600898 +## 747: 5 147 1826.25 7.25 0.29156437 +## 748: 5 148 1826.25 7.25 0.58395919 +## 749: 5 149 1826.25 7.25 0.54202021 +## 750: 5 150 1826.25 7.25 0.96391985 }\if{html}{\out{
}} Specify \code{pred_horizon} to get individual conditional expectation at each @@ -397,18 +405,19 @@ value: ice_train }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred -## 1: 1 1 500 0.59 0.008276627 -## 2: 1 1 1000 0.59 0.055715858 -## 3: 1 1 1500 0.59 0.084987224 -## 4: 1 1 2000 0.59 0.123090885 -## 5: 1 1 2500 0.59 0.165214938 -## --- -## 4496: 5 150 1000 7.21 0.835895969 -## 4497: 5 150 1500 7.21 0.932657591 -## 4498: 5 150 2000 7.21 0.965944498 -## 4499: 5 150 2500 7.21 0.970325309 -## 4500: 5 150 3000 7.21 0.979051377 +\if{html}{\out{
}}\preformatted{## id_variable id_row pred_horizon bili pred +## +## 1: 1 1 500 0.55 0.008276627 +## 2: 1 1 1000 0.55 0.055724516 +## 3: 1 1 1500 0.55 0.085091120 +## 4: 1 1 2000 0.55 0.123423352 +## 5: 1 1 2500 0.55 0.166380739 +## --- +## 4496: 5 150 1000 7.25 0.837774757 +## 4497: 5 150 1500 7.25 0.934536379 +## 4498: 5 150 2000 7.25 0.967823286 +## 4499: 5 150 2500 7.25 0.972059574 +## 4500: 5 150 3000 7.25 0.980785643 }\if{html}{\out{
}} Multi-prediction horizon ice comes with minimal extra computational diff --git a/man/orsf_pd_oob.Rd b/man/orsf_pd_oob.Rd index 789df6bd..2f1716b2 100644 --- a/man/orsf_pd_oob.Rd +++ b/man/orsf_pd_oob.Rd @@ -194,13 +194,15 @@ pd_oob <- orsf_pd_oob(fit_clsf, pred_spec = pred_spec) pd_oob }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## class flipper_length_mm mean lwr medn upr -## 1: Adelie 190 0.6180632 0.207463688 0.76047056 0.9809703 -## 2: Adelie 210 0.4346177 0.018583256 0.56486883 0.8647387 -## 3: Chinstrap 190 0.2119948 0.017692341 0.15658268 0.7163635 -## 4: Chinstrap 210 0.1801186 0.020454479 0.09525310 0.7085293 -## 5: Gentoo 190 0.1699420 0.001277844 0.02831331 0.5738689 -## 6: Gentoo 210 0.3852637 0.068685035 0.20853993 0.9537020 +\if{html}{\out{
}}\preformatted{## Key: +## class flipper_length_mm mean lwr medn upr +## +## 1: Adelie 190 0.6176908 0.202278109 0.75856417 0.9810614 +## 2: Adelie 210 0.4338528 0.019173811 0.56489202 0.8648110 +## 3: Chinstrap 190 0.2114979 0.017643385 0.15211271 0.7215181 +## 4: Chinstrap 210 0.1803019 0.020108201 0.09679464 0.7035053 +## 5: Gentoo 190 0.1708113 0.001334861 0.02769695 0.5750201 +## 6: Gentoo 210 0.3858453 0.068685035 0.20717073 0.9532853 }\if{html}{\out{
}} Note that predicted probabilities are returned for each class and @@ -219,7 +221,7 @@ But this isn’t the case for the median predicted probability! \if{html}{\out{
}}\preformatted{sum(pd_oob[flipper_length_mm == 190, medn]) }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## [1] 0.9453666 +\if{html}{\out{
}}\preformatted{## [1] 0.9383738 }\if{html}{\out{
}} } @@ -251,6 +253,7 @@ pd_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## flipper_length_mm mean lwr medn upr +## ## 1: 190 42.96571 37.09805 43.69769 48.72301 ## 2: 210 45.66012 40.50693 46.31577 51.65163 }\if{html}{\out{
}} @@ -267,6 +270,7 @@ pd_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## species island body_mass_g mean lwr medn upr +## ## 1: Adelie Biscoe 3200 40.31374 37.24373 40.31967 44.22824 ## 2: Chinstrap Biscoe 3200 45.10582 42.63342 45.10859 47.60119 ## 3: Gentoo Biscoe 3200 42.81649 40.19221 42.55664 46.84035 @@ -327,6 +331,7 @@ pd_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## variable value level mean lwr medn upr +## ## 1: species NA Adelie 41.90271 37.10417 41.51723 48.51478 ## 2: species NA Chinstrap 47.11314 42.40419 46.96478 51.51392 ## 3: species NA Gentoo 44.37038 39.87306 43.89889 51.21635 @@ -355,6 +360,7 @@ pd_new }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## species island mean lwr medn upr +## ## 1: Adelie Biscoe 41.98024 37.22711 41.65252 48.51478 }\if{html}{\out{
}} } @@ -381,12 +387,13 @@ Compute partial dependence using in-bag data for \code{bili = c(1,2,3,4,5)}: pd_train }\if{html}{\out{
}} -\if{html}{\out{
}}\preformatted{## pred_horizon bili mean lwr medn upr -## 1: 1826.25 1 0.2566200 0.02234786 0.1334170 0.8918909 -## 2: 1826.25 2 0.3121392 0.06853733 0.1896849 0.9204338 -## 3: 1826.25 3 0.3703242 0.11409793 0.2578505 0.9416791 -## 4: 1826.25 4 0.4240692 0.15645214 0.3331057 0.9591581 -## 5: 1826.25 5 0.4663670 0.20123406 0.3841700 0.9655296 +\if{html}{\out{
}}\preformatted{## pred_horizon bili mean lwr medn upr +## +## 1: 1826.25 1 0.2566200 0.02234786 0.1334170 0.8918909 +## 2: 1826.25 2 0.3121392 0.06853733 0.1896849 0.9204338 +## 3: 1826.25 3 0.3703242 0.11409793 0.2578505 0.9416791 +## 4: 1826.25 4 0.4240692 0.15645214 0.3331057 0.9591581 +## 5: 1826.25 5 0.4663670 0.20123406 0.3841700 0.9655296 }\if{html}{\out{
}} If you don’t have specific values of a variable in mind, let @@ -397,11 +404,12 @@ pd_train }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## pred_horizon bili mean lwr medn upr -## 1: 1826.25 0.590 0.2484695 0.02035041 0.1243120 0.8823385 -## 2: 1826.25 0.725 0.2508045 0.02060111 0.1274237 0.8836536 -## 3: 1826.25 1.500 0.2797763 0.03964900 0.1601715 0.9041584 -## 4: 1826.25 3.500 0.3959349 0.13431288 0.2920400 0.9501230 -## 5: 1826.25 7.210 0.5344511 0.27869513 0.4651185 0.9782084 +## +## 1: 1826.25 0.55 0.2481444 0.02035041 0.1242215 0.8801444 +## 2: 1826.25 0.70 0.2502831 0.02045039 0.1271039 0.8836536 +## 3: 1826.25 1.50 0.2797763 0.03964900 0.1601715 0.9041584 +## 4: 1826.25 3.50 0.3959349 0.13431288 0.2920400 0.9501230 +## 5: 1826.25 7.25 0.5351935 0.28064629 0.4652185 0.9783000 }\if{html}{\out{
}} Specify \code{pred_horizon} to get partial dependence at each value: @@ -411,38 +419,39 @@ Specify \code{pred_horizon} to get partial dependence at each value: pd_train }\if{html}{\out{}} -\if{html}{\out{
}}\preformatted{## pred_horizon bili mean lwr medn upr -## 1: 500 0.590 0.06184375 0.0004433990 0.008765301 0.5918852 -## 2: 1000 0.590 0.14210619 0.0057937418 0.056124198 0.7381107 -## 3: 1500 0.590 0.20859307 0.0136094784 0.091808079 0.8577223 -## 4: 2000 0.590 0.26823465 0.0230476894 0.145707217 0.8918696 -## 5: 2500 0.590 0.31809404 0.0631155452 0.202189830 0.9035026 -## 6: 3000 0.590 0.39152139 0.0911566314 0.302738552 0.9239861 -## 7: 500 0.725 0.06255088 0.0004462367 0.008934806 0.5980510 -## 8: 1000 0.725 0.14337233 0.0063321712 0.056348007 0.7447805 -## 9: 1500 0.725 0.21058059 0.0140736894 0.093113771 0.8597396 -## 10: 2000 0.725 0.27056356 0.0235448705 0.146307939 0.8941464 -## 11: 2500 0.725 0.31922691 0.0626303822 0.202462648 0.9073970 -## 12: 3000 0.725 0.39426313 0.0911457406 0.308440546 0.9252028 -## 13: 500 1.500 0.06679162 0.0012717884 0.011028398 0.6241228 -## 14: 1000 1.500 0.15727919 0.0114789623 0.068332010 0.7678732 -## 15: 1500 1.500 0.23316655 0.0287320952 0.117289745 0.8789647 -## 16: 2000 1.500 0.30139227 0.0467927208 0.180096425 0.9144202 -## 17: 2500 1.500 0.35260943 0.0845866747 0.238015966 0.9266065 -## 18: 3000 1.500 0.43512074 0.1311103304 0.346025144 0.9438562 -## 19: 500 3.500 0.08638646 0.0052087533 0.028239001 0.6740930 -## 20: 1000 3.500 0.22353655 0.0519179775 0.139604845 0.8283986 -## 21: 1500 3.500 0.32700976 0.0901983241 0.217982772 0.9371150 -## 22: 2000 3.500 0.41618105 0.1445328597 0.311508093 0.9566091 -## 23: 2500 3.500 0.49248461 0.2195110942 0.402095677 0.9636221 -## 24: 3000 3.500 0.56008108 0.2635698957 0.503253258 0.9734948 -## 25: 500 7.210 0.12550962 0.0220920570 0.063425987 0.7526581 -## 26: 1000 7.210 0.32567558 0.1353851175 0.259047345 0.8875150 -## 27: 1500 7.210 0.46327019 0.2181840827 0.386681920 0.9700903 -## 28: 2000 7.210 0.55042753 0.2912654769 0.483477295 0.9812223 -## 29: 2500 7.210 0.61937483 0.3709845684 0.567895754 0.9844945 -## 30: 3000 7.210 0.67963922 0.4247511750 0.645083041 0.9888637 -## pred_horizon bili mean lwr medn upr +\if{html}{\out{
}}\preformatted{## pred_horizon bili mean lwr medn upr +## +## 1: 500 0.55 0.06171990 0.000443399 0.008654190 0.5907104 +## 2: 1000 0.55 0.14185009 0.005793742 0.055728527 0.7360749 +## 3: 1500 0.55 0.20825053 0.013609478 0.091745579 0.8556319 +## 4: 2000 0.55 0.26790167 0.023047689 0.145741690 0.8910549 +## 5: 2500 0.55 0.31796166 0.063797305 0.202544999 0.9017710 +## 6: 3000 0.55 0.39108086 0.090852131 0.301804690 0.9234812 +## 7: 500 0.70 0.06240527 0.000443399 0.008934806 0.5980510 +## 8: 1000 0.70 0.14313570 0.006159694 0.056348007 0.7432448 +## 9: 1500 0.70 0.21012128 0.013717586 0.092461532 0.8597396 +## 10: 2000 0.70 0.27013021 0.023169510 0.146344595 0.8935664 +## 11: 2500 0.70 0.31880954 0.062506113 0.201979102 0.9068170 +## 12: 3000 0.70 0.39286323 0.089707173 0.308392927 0.9252028 +## 13: 500 1.50 0.06679162 0.001271788 0.011028398 0.6241228 +## 14: 1000 1.50 0.15727919 0.011478962 0.068332010 0.7678732 +## 15: 1500 1.50 0.23316655 0.028732095 0.117289745 0.8789647 +## 16: 2000 1.50 0.30139227 0.046792721 0.180096425 0.9144202 +## 17: 2500 1.50 0.35260943 0.084586675 0.238015966 0.9266065 +## 18: 3000 1.50 0.43512074 0.131110330 0.346025144 0.9438562 +## 19: 500 3.50 0.08638646 0.005208753 0.028239001 0.6740930 +## 20: 1000 3.50 0.22353655 0.051917978 0.139604845 0.8283986 +## 21: 1500 3.50 0.32700976 0.090198324 0.217982772 0.9371150 +## 22: 2000 3.50 0.41618105 0.144532860 0.311508093 0.9566091 +## 23: 2500 3.50 0.49248461 0.219511094 0.402095677 0.9636221 +## 24: 3000 3.50 0.56008108 0.263569896 0.503253258 0.9734948 +## 25: 500 7.25 0.12585007 0.022092057 0.063550987 0.7543806 +## 26: 1000 7.25 0.32646274 0.135343689 0.259567907 0.8884333 +## 27: 1500 7.25 0.46412653 0.218208755 0.387874346 0.9702903 +## 28: 2000 7.25 0.55117610 0.293367409 0.484277295 0.9812413 +## 29: 2500 7.25 0.62002385 0.371965247 0.569543990 0.9845058 +## 30: 3000 7.25 0.68034820 0.425128031 0.646423180 0.9888637 +## pred_horizon bili mean lwr medn upr }\if{html}{\out{
}} vector-valued \code{pred_horizon} input comes with minimal extra diff --git a/man/predict.ObliqueForest.Rd b/man/predict.ObliqueForest.Rd index 31ac7b83..45806426 100644 --- a/man/predict.ObliqueForest.Rd +++ b/man/predict.ObliqueForest.Rd @@ -137,11 +137,11 @@ predict(fit_clsf, }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{## Adelie Chinstrap Gentoo -## [1,] 0.9405286 0.04125900 0.018212368 -## [2,] 0.9628964 0.03459853 0.002505059 -## [3,] 0.9029383 0.08527806 0.011783605 -## [4,] 0.9301983 0.05180907 0.017992625 -## [5,] 0.7968234 0.16538539 0.037791201 +## [1,] 0.9405310 0.04121955 0.018249405 +## [2,] 0.9628988 0.03455909 0.002542096 +## [3,] 0.9032074 0.08510528 0.011687309 +## [4,] 0.9300133 0.05209040 0.017896329 +## [5,] 0.7965703 0.16243492 0.040994821 }\if{html}{\out{
}} \if{html}{\out{
}}\preformatted{# predicted class (as a matrix by default) diff --git a/tests/testthat/_snaps/verbosity.md b/tests/testthat/_snaps/verbosity.md index 7a741ad3..94667d84 100644 --- a/tests/testthat/_snaps/verbosity.md +++ b/tests/testthat/_snaps/verbosity.md @@ -3,10 +3,6 @@ Code fit_verbose <- orsf(pbc, time + status ~ ., verbose_progress = TRUE, n_tree = n_tree_test, importance = "negate") - Output - Growing trees: 100%. - Computing predictions: 100%. - Computing importance: 100%. --- @@ -21,53 +17,17 @@ # verbosity is carried by object Code - orsf_pd_oob(fit_verbose, pred_spec_auto(island)) - Output - Computing dependence: 100%. - class island mean lwr medn upr - 1: Adelie Biscoe 0.4904928 0 0.470588235 1.0000000 - 2: Adelie Dream 0.4169041 0 0.150000000 1.0000000 - 3: Adelie Torgersen 0.6145236 0 0.941176471 1.0000000 - 4: Chinstrap Biscoe 0.1191911 0 0.000000000 0.9666667 - 5: Chinstrap Dream 0.3739789 0 0.254562468 1.0000000 - 6: Chinstrap Torgersen 0.2061961 0 0.007201859 1.0000000 - 7: Gentoo Biscoe 0.3903161 0 0.051470588 1.0000000 - 8: Gentoo Dream 0.2091170 0 0.000000000 0.9863014 - 9: Gentoo Torgersen 0.1792803 0 0.000000000 1.0000000 + pd <- orsf_pd_oob(fit_verbose, pred_spec_auto(island)) --- Code - orsf_vi(fit_verbose_2, importance = "negate") - Output - Computing importance: 100%. - flipper_length_mm body_mass_g species island - 0.52904478 0.34635451 0.31919457 0.14621939 - bill_depth_mm sex year - 0.13568507 0.09509735 0.01633449 + vi <- orsf_vi(fit_verbose_2, importance = "negate") --- Code - orsf_vs(fit_verbose) + vs <- orsf_vs(fit_verbose) Output Selecting variables: 100% - n_predictors stat_value - 1: 3 0.9991496 - 2: 4 0.9821797 - 3: 5 0.9972835 - 4: 6 0.9935440 - 5: 7 0.9861669 - predictors_included - 1: island_Dream,bill_length_mm,bill_depth_mm,sex_male - 2: island_Dream,bill_length_mm,bill_depth_mm,body_mass_g,sex_male - 3: island_Dream,island_Torgersen,bill_length_mm,bill_depth_mm,body_mass_g,sex_male - 4: island_Dream,island_Torgersen,bill_length_mm,bill_depth_mm,flipper_length_mm,body_mass_g,... - 5: island_Dream,island_Torgersen,bill_length_mm,bill_depth_mm,flipper_length_mm,body_mass_g,... - predictor_dropped - 1: island_Dream - 2: body_mass_g - 3: island_Torgersen - 4: flipper_length_mm - 5: year diff --git a/tests/testthat/test-verbosity.R b/tests/testthat/test-verbosity.R index 1550a268..533d186c 100644 --- a/tests/testthat/test-verbosity.R +++ b/tests/testthat/test-verbosity.R @@ -43,15 +43,15 @@ test_that( n_tree = n_tree_test) expect_snapshot( - orsf_pd_oob(fit_verbose, pred_spec_auto(island)) + pd <- orsf_pd_oob(fit_verbose, pred_spec_auto(island)) ) expect_snapshot( - orsf_vi(fit_verbose_2, importance = 'negate') + vi <- orsf_vi(fit_verbose_2, importance = 'negate') ) expect_snapshot( - orsf_vs(fit_verbose) + vs <- orsf_vs(fit_verbose) ) }