Skip to content

feat(varpro): unsupervised lasso importance — gg_beta_uvarpro() + gg_sdependent()#120

Closed
ehrlinger wants to merge 3 commits into
devfrom
feature/gg-beta-uvarpro
Closed

feat(varpro): unsupervised lasso importance — gg_beta_uvarpro() + gg_sdependent()#120
ehrlinger wants to merge 3 commits into
devfrom
feature/gg-beta-uvarpro

Conversation

@ehrlinger

@ehrlinger ehrlinger commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Adds two uvarpro-side wrappers (the "new methods" Hemant/Lu pointed to in the varPro::uvarpro() help, iowa housing — illustrates lasso importance), each with plot/print/summary/autoplot companions.

gg_beta_uvarpro() — unsupervised lasso importance

Wraps varPro::get.beta.entropy(). Aggregates the (released-variable × variable) |β| matrix into beta_mean = colMeans(|β|, na.rm=TRUE) per variable (most-important first, reversed factor levels for top-at-top), with cutoff/selected and a beta_fit cache path. The unsupervised analogue of gg_beta_varpro().

gg_sdependent() — signal-variable detection

Wraps varPro::sdependent(). One row per candidate variable — imp_score, graph degree, signal flag (membership in sdependent()$signal.vars) — ranked by imp_score, plotted as a lollipop coloured by signal. Complements gg_udependent() (which already wraps sdependent() as the dependency graph on dev) with the "which variables are signal" ranking. Shares the beta_fit entropy matrix with gg_beta_uvarpro()/gg_udependent().

Tests

  • gg_beta_uvarpro: deterministic logic via mock matrix (CRAN-safe, no live grow) + skip_on_cran live integration.
  • gg_sdependent: matrix-driven tests run CRAN-safe (sdependent() does not grow a forest) + skip_on_cran live uvarpro() integration.
  • check_man() clean; new files only.

Follow-ups

  • CORR defaults for get.beta.entropy() (pre.filter, second.stage, lambda.sel) — left at varPro defaults pending the analytical goal.
  • Consider an sdependent-style overlay on gg_udependent (node colour = signal).

Targets the v4.0.0 (dev) line. Self-contained, so it can also ride a quick 3.1.2 off main if you want it on CRAN sooner.

🤖 Generated with Claude Code

Scaffold the unsupervised analogue of gg_beta_varpro(): a tidy wrapper +
plot method around varPro::get.beta.entropy() for uvarpro() fits. From the
(released-variable x variable) lasso-coefficient matrix it computes
beta_mean = colMeans(|beta|) per variable (most-important first, factor
levels reversed for the coord_flip top-at-top convention) and flags
variables above a selection cutoff (default mean(beta_mean)). Optional
beta_fit accepts a precomputed get.beta.entropy() matrix so the expensive
CV-lasso runs once.

Follows the get.beta.entropy + sdependent "lasso importance" workflow from
the varPro::uvarpro() help (iowa-housing example), per Lu/Ishwaran.

Tests: deterministic logic via the precomputed beta_fit path with a mock
matrix (CRAN-safe, no live grow) + one skip_on_cran() live integration
test. check_man() clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.94656% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.84%. Comparing base (60d97cf) to head (be6e150).

Files with missing lines Patch % Lines
R/gg_sdependent.R 95.12% 4 Missing ⚠️
R/gg_beta_uvarpro.R 97.05% 3 Missing ⚠️
R/plot.gg_beta_uvarpro.R 97.61% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #120      +/-   ##
==========================================
+ Coverage   87.26%   87.84%   +0.58%     
==========================================
  Files          48       52       +4     
  Lines        4090     4352     +262     
==========================================
+ Hits         3569     3823     +254     
- Misses        521      529       +8     
Files with missing lines Coverage Δ
R/plot.gg_sdependent.R 100.00% <100.00%> (ø)
R/plot.gg_beta_uvarpro.R 97.61% <97.61%> (ø)
R/gg_beta_uvarpro.R 97.05% <97.05%> (ø)
R/gg_sdependent.R 95.12% <95.12%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ehrlinger and others added 2 commits June 12, 2026 10:00
Add the standard gg_* S3 companions, matching gg_beta_varpro:
- print.gg_beta_uvarpro: one-line header + selected/region summary
- summary.gg_beta_uvarpro: summary.gg with top variables by mean |beta|
- autoplot.gg_beta_uvarpro: dispatches to plot.gg_beta_uvarpro

Methods live in gg_beta_uvarpro.R; @Rdname routes them onto the shared
print.gg / summary.gg pages. Tests + check_man clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Wrap varPro::sdependent() (signal-variable detection on the
get.beta.entropy() matrix) as a tidy gg_sdependent frame: one row per
candidate variable with imp_score, graph degree, and a signal flag
(membership in sdependent()$signal.vars), ranked by imp_score. Default
plot is a ranked lollipop coloured by the signal flag. print/summary/
autoplot companions follow the gg_* conventions; beta_fit accepts a
precomputed entropy matrix shared with gg_beta_uvarpro()/gg_udependent().

Complements gg_udependent() (the dependency graph) with the "which
variables are signal" ranking. Matrix-driven tests run CRAN-safe
(sdependent does not grow a forest); the live uvarpro() grow is
skip_on_cran(). check_man() clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ehrlinger ehrlinger changed the title feat(varpro): gg_beta_uvarpro() — unsupervised lasso importance (get.beta.entropy) feat(varpro): unsupervised lasso importance — gg_beta_uvarpro() + gg_sdependent() Jun 12, 2026
ehrlinger added a commit that referenced this pull request Jun 12, 2026
Fold the unsupervised varPro wrappers (originally PR #120 on dev) into the
3.1.2 release line alongside the #118 fix:

- gg_beta_uvarpro() / plot/print/summary/autoplot: tidy wrapper for
  varPro::get.beta.entropy() (unsupervised lasso importance), the analogue
  of gg_beta_varpro(); colMeans(|beta|) per variable + cutoff/selected, with
  a precomputed beta_fit cache path.
- gg_sdependent() / plot/print/summary/autoplot: tidy wrapper for
  varPro::sdependent() signal-variable detection (imp_score / degree /
  signal flag), complementing gg_udependent()'s graph. Frame-building split
  into .gg_sdependent_build() to keep cyclomatic complexity under the lint
  cap.

Tests are CRAN-safe (constructed matrices, no varPro grow) with skip_on_cran
live-integration cases. lint_package() = 0; NEWS entries under v3.1.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ehrlinger

Copy link
Copy Markdown
Owner Author

Folded into #121 (the 3.1.2 release) — gg_beta_uvarpro() and gg_sdependent() now ship in 3.1.2 alongside the #118 fix, rather than waiting for v4.0.0. Closing in favor of #121; the dev/v4.0.0 line picks these up when it next syncs main.

@ehrlinger ehrlinger closed this Jun 12, 2026
ehrlinger added a commit that referenced this pull request Jun 12, 2026
Fold the unsupervised varPro wrappers (originally PR #120 on dev) into the
3.1.2 release line alongside the #118 fix:

- gg_beta_uvarpro() / plot/print/summary/autoplot: tidy wrapper for
  varPro::get.beta.entropy() (unsupervised lasso importance), the analogue
  of gg_beta_varpro(); colMeans(|beta|) per variable + cutoff/selected, with
  a precomputed beta_fit cache path.
- gg_sdependent() / plot/print/summary/autoplot: tidy wrapper for
  varPro::sdependent() signal-variable detection (imp_score / degree /
  signal flag), complementing gg_udependent()'s graph. Frame-building split
  into .gg_sdependent_build() to keep cyclomatic complexity under the lint
  cap.

Tests are CRAN-safe (constructed matrices, no varPro grow) with skip_on_cran
live-integration cases. lint_package() = 0; NEWS entries under v3.1.2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ehrlinger ehrlinger deleted the feature/gg-beta-uvarpro branch June 12, 2026 16:57
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