Skip to content

Commit

Permalink
Merge branch 'master' into skip_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed Aug 22, 2024
2 parents 764d980 + 974d9b6 commit d98a7a6
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected].1
uses: JamesIves/[email protected].3
with:
clean: false
branch: gh-pages
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ranger
Type: Package
Title: A Fast Implementation of Random Forests
Version: 0.16.2
Date: 2024-05-16
Version: 0.16.3
Date: 2024-08-20
Author: Marvin N. Wright [aut, cre], Stefan Wager [ctb], Philipp Probst [ctb]
Maintainer: Marvin N. Wright <[email protected]>
Description: A fast implementation of Random Forests, particularly suited for high
Expand All @@ -19,7 +19,7 @@ Suggests:
survival,
testthat
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
URL: https://imbs-hl.github.io/ranger/,
https://github.com/imbs-hl/ranger
BugReports: https://github.com/imbs-hl/ranger/issues
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

# ranger 0.16.3
* Fix a bug for always.split.variables (for some settings)

# ranger 0.16.2
* Add Poisson splitting rule for regression trees

Expand Down
2 changes: 1 addition & 1 deletion cpp_version/src/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ifndef RANGER_VERSION
#define RANGER_VERSION "0.16.2"
#define RANGER_VERSION "0.16.3"
#endif
4 changes: 2 additions & 2 deletions src/Forest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,8 +953,8 @@ void Forest::setAlwaysSplitVariables(const std::vector<std::string>& always_spli
}
}

// Sort in reverse order for removing with erase later
std::sort(deterministic_varIDs.rbegin(), deterministic_varIDs.rend());
// Sort for removing later
std::sort(deterministic_varIDs.begin(), deterministic_varIDs.end());
}

void Forest::showProgress(std::string operation, size_t max_progress) {
Expand Down
4 changes: 2 additions & 2 deletions src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ void drawWithoutReplacementFisherYates(std::vector<size_t>& result, std::mt19937
std::iota(result.begin(), result.end(), 0);

// Skip indices
for (size_t i = 0; i < skip.size(); ++i) {
result.erase(result.begin() + skip[i]);
for (auto it = skip.rbegin(); it != skip.rend(); it++) {
result.erase(result.begin() + *it);
}

// Draw without replacement using Fisher Yates algorithm
Expand Down
4 changes: 3 additions & 1 deletion src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ void drawWithoutReplacementSimple(std::vector<size_t>& result, std::mt19937_64&
size_t num_samples);

/**
* Simple algorithm for sampling without replacement (skip values), faster for smaller num_samples
* Simple algorithm for sampling without replacement (skip values), faster for smaller num_samples.
* skip values are expected to be sorted in ascending order.
* @param result Vector to add results to. Will not be cleaned before filling.
* @param random_number_generator Random number generator
* @param range_length Length of range. Interval to draw from: 0..max-1
Expand All @@ -203,6 +204,7 @@ void drawWithoutReplacementFisherYates(std::vector<size_t>& result, std::mt19937

/**
* Fisher Yates algorithm for sampling without replacement (skip values).
* skip values are expected to be sorted in ascending order.
* @param result Vector to add results to. Will not be cleaned before filling.
* @param random_number_generator Random number generator
* @param max Length of range. Interval to draw from: 0..max-1
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_poissonsplit.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ test_that("poisson splitting works on poisson distributed data", {
n_test = (max(n_train)+1):n
df_train = df[n_train, ]
df_test = df[n_test, ]
rf_poi <- ranger(y ~ ., df_train, splitrule = "poisson", num.trees = 50, min.node.size = 50, poisson.tau = 1, seed = 12)
rf_mse <- ranger(y ~ ., df_train, splitrule = "variance", num.trees = 50, min.node.size = 50, seed = 13)
rf_poi <- ranger(y ~ ., df_train, splitrule = "poisson", num.trees = 50, min.node.size = 50, poisson.tau = 1, seed = 123)
rf_mse <- ranger(y ~ ., df_train, splitrule = "variance", num.trees = 50, min.node.size = 50, seed = 123)

expect_is(rf_poi, "ranger")
# deviance on test set
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_regularization.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test_that("Fewer variables used with regularization, survival extratrees", {
rf_noreg <- ranger(Surv(time, status) ~ ., dat_surv, num.trees = 5, min.node.size = 10, mtry = 4, splitrule = "extratrees")
rf_reg <- ranger(Surv(time, status) ~ ., dat_surv, num.trees = 5, min.node.size = 10, mtry = 4, splitrule = "extratrees", num.threads = 1,
regularization.factor = .0001, regularization.usedepth = TRUE)
expect_lt(get_num_splitvars(rf_reg),
expect_lte(get_num_splitvars(rf_reg),
get_num_splitvars(rf_noreg))
})

Expand Down

0 comments on commit d98a7a6

Please sign in to comment.