Skip to content

Commit

Permalink
drop global verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Oct 8, 2023
1 parent 9551eba commit f755ea9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/ForestSurvival.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ForestSurvival::load(
this->pd_x_cols = pd_x_cols;
this->pd_probs = pd_probs;

if(VERBOSITY > 0){
if(verbosity > 2){
Rcout << "---- loading forest from input list ----";
Rcout << std::endl << std::endl;
}
Expand Down
42 changes: 17 additions & 25 deletions src/Tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,12 @@

}

if(VERBOSITY > 1){
if(verbosity > 4){

mat x_print = x_inbag.rows(rows_node);
Rcout << "Column " << j << " was sampled but ";
Rcout << "unique values of column " << j << " are ";
Rcout << unique(x_print.col(j)) << std::endl;
Rcout << " -- Column " << j << " was sampled but ";
Rcout << "its unique values are " << unique(x_print.col(j));
Rcout << std::endl;

}

Expand Down Expand Up @@ -371,10 +371,6 @@

double n_obs = 0;

if(VERBOSITY > 1){
Rcout << "----- finding lower bound for cut-points -----" << std::endl;
}

// stop at end-1 b/c we access it+1 in lincomb_sort
for(it = lincomb_sort.begin(); it < lincomb_sort.end()-1; ++it){

Expand All @@ -388,10 +384,10 @@

if(n_obs >= leaf_min_obs) {

if(VERBOSITY > 0){
if(verbosity > 3){
Rcout << std::endl;
Rcout << "lower cutpoint: " << lincomb(*it) << std::endl;
Rcout << " - n_obs, left node: " << n_obs << std::endl;
Rcout << " -- lower cutpoint: " << lincomb(*it) << std::endl;
Rcout << " - n_obs, left node: " << n_obs << std::endl;
Rcout << std::endl;
}

Expand All @@ -407,8 +403,8 @@

if(it == lincomb_sort.end()-1) {

if(VERBOSITY > 1){
Rcout << "Could not find a valid cut-point" << std::endl;
if(verbosity > 3){
Rcout << " -- Could not find a valid cut-point" << std::endl;
}

return;
Expand All @@ -421,10 +417,6 @@
// reset before finding the upper limit
n_obs=0;

if(VERBOSITY > 1){
Rcout << "----- finding upper bound for cut-points -----" << std::endl;
}

// stop at beginning+1 b/c we access it-1 in lincomb_sort
for(it = lincomb_sort.end()-1; it >= lincomb_sort.begin()+1; --it){

Expand All @@ -444,10 +436,10 @@

--it;

if(VERBOSITY > 0){
if(verbosity > 3){
Rcout << std::endl;
Rcout << "upper cutpoint: " << lincomb(*it) << std::endl;
Rcout << " - n_obs, right node: " << n_obs << std::endl;
Rcout << " -- upper cutpoint: " << lincomb(*it) << std::endl;
Rcout << " - n_obs, right node: " << n_obs << std::endl;
Rcout << std::endl;
}

Expand All @@ -466,8 +458,8 @@

if(j > k){

if(VERBOSITY > 0) {
Rcout << "Could not find valid cut-points" << std::endl;
if(verbosity > 2) {
Rcout << " -- Could not find valid cut-points" << std::endl;
}

return;
Expand Down Expand Up @@ -698,10 +690,10 @@

double accuracy_permuted = compute_prediction_accuracy(pred_values);

if(VERBOSITY>1){
Rcout << "prediction accuracy after noising " << pred_col << ": ";
if(verbosity > 3){
Rcout << " -- prediction accuracy after noising " << pred_col << ": ";
Rcout << accuracy_permuted << std::endl;
Rcout << " - mean leaf pred: ";
Rcout << " - mean leaf pred: ";
Rcout << mean(conv_to<vec>::from(pred_leaf));
Rcout << std::endl << std::endl;
}
Expand Down
2 changes: 0 additions & 2 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@

const PredType DEFAULT_PRED_TYPE = PRED_RISK;

const int VERBOSITY = 0;

// Interval to print progress in seconds
const double STATUS_INTERVAL = 1.0;

Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test-oobag.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ fit_custom_oobag <- orsf(pbc_orsf,
formula = Surv(time, status) ~ . - id,
n_tree = 100,
oobag_fun = oobag_c_survival,
tree_seeds = 1:100,
verbose_progress = 0)
tree_seeds = 1:100)

fit_standard_oobag <- orsf(pbc_orsf,
formula = Surv(time, status) ~ . - id,
n_tree = 100,
tree_seeds = 1:100,
verbose_progress = 0)
tree_seeds = 1:100)

testthat::expect_equal(
fit_custom_oobag$forest$rows_oobag,
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-orsf_pd.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,21 @@ test_that(
# }
# )

# bili_seq <- seq(1, 5, length.out=20)
#
# microbenchmark::microbenchmark(
# pd_reference = partial(fit,
# pred.var = "bili",
# pred.grid = data.frame(bili = bili_seq),
# pred.fun = pred_aorsf,
# plot = FALSE,
# ice = TRUE,
# train = pbc_orsf),
# pd_aorsf = orsf_ice_new(fit,
# new_data = pbc_orsf,
# pred_spec = list(bili=bili_seq),
# pred_horizon = 1000,
# expand_grid = TRUE)
# )


0 comments on commit f755ea9

Please sign in to comment.