8000 Draw forge() columns per variable by jemus42 · Pull Request #81 · bips-hb/arf · GitHub
[go: up one dir, main page]

Skip to content

Draw forge() columns per variable - #81

Open
jemus42 wants to merge 1 commit into
mainfrom
forge-dt
Open

jemus42 wants to merge 1 commit into
mainfrom
forge-dt

Conversation

@jemus42
@jemus42 jemus42 commented Dec 3, 2026
Copy link
Copy Markdown
Member

Speeds up unconditional `forge()` and cuts its memory use by drawing each variable's column directly, instead of building a long table of all draws and variables and reshaping it with `unique()` and `dcast()`.

  • Continuous columns: a keyed join gives each draw's leaf parameters, and conditions override them where evidence applies, then one sampler call per column.
  • Categorical columns: levels for all draws are sampled in one `findInterval()` call on within-leaf cumulative probabilities offset by group (built exactly by a small C helper), replacing a per-group `sample()` that took over 70% of the run time with factors.
  • `sample_NAs` applies per column on the wide result.

Unconditional `forge()`, 5e4 rows, 50 trees, single thread:

case main this PR
20 continuous 0.72 s, 458 MB 0.44 s, 164 MB
10 continuous + 5 factors 2.0 s, 389 MB 0.44 s, 117 MB

Conditional `forge()` is unchanged, since its time goes to `cforde()`, which a follow-up PR addresses.

Distributions match main in 13 scenarios (point, interval, categorical and within-row or evidence, both row modes, `family = "unif"`, `sample_NAs`), compared by KS and chi-squared tests on 2e4 draws each.
Draws for a given seed differ from earlier versions.

🤖 Generated with Claude Code

@codecov
codecov Bot commented Dec 3, 2026
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.84536% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.27%. Comparing base (2253e24) to head (cb34d8c).

Files with missing lines Patch % Lines
R/forge_workers.R 93.50% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
+ Coverage   95.02%   95.27%   +0.24%     
==========================================
  Files          19       20       +1     
  Lines        1748     1798      +50     
==========================================
+ Hits         1661     1713      +52     
+ Misses         87       85       -2     
Files with missing lines Coverage Δ
src/init.c 100.00% <ø> (ø)
src/sample.c 100.00% <100.00%> (ø)
R/forge_workers.R 94.00% <93.50%> (+3.16%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0