Per-variable lasso-beta importance from an unsupervised varPro fit
Source:R/gg_beta_uvarpro.R
gg_beta_uvarpro.RdTidy wrapper around varPro::get.beta.entropy() for a uvarpro object.
Where gg_beta_varpro() refines the supervised release-rule contrast,
gg_beta_uvarpro() does the unsupervised analogue: uvarpro() builds
entropy regions with no response, and get.beta.entropy() fits a
cross-validated lasso within each region to ask how strongly every other
variable explains the released variable. Averaging the absolute lasso
coefficients per variable gives one number per variable: an unsupervised,
lasso-flavoured importance.
Arguments
- object
A
uvarproobject fromvarPro::uvarpro().- ...
Forwarded to
varPro::get.beta.entropy()whenbeta_fit = NULL(e.g.pre.filter,second.stage,use.cv). Ignored, with a warning, whenbeta_fitis supplied.- cutoff
Selection threshold on
beta_mean.NULL(default) usesmean(beta_mean); a scalar sets it explicitly. Variables at or above the cutoff are flaggedselected.- beta_fit
Optional pre-computed
varPro::get.beta.entropy()matrix forobject. When supplied, must be a numeric matrix with column names (the variables);...is then ignored.
Value
A gg_beta_uvarpro object (a data.frame), one row per variable,
most-important first, with columns:
variablefactor; levels reversed so the most-important variable lands at the top after
coord_flip()(thegg_vimpconvention).beta_meanmean(|lasso beta|)over the released regions (colMeans(beta, na.rm = TRUE)).n_releasednumber of regions contributing a non-
NAcoefficient for the variable.selectedlogical;
beta_mean >= cutoff.
The provenance attribute records source, family ("unsupv"),
cutoff, n_var, n_released_regions, and precomputed.
Details
get.beta.entropy(o) returns a (released-variable x variable) numeric
matrix of absolute lasso coefficients. The column mean (na.rm = TRUE) is
the per-variable importance reported here, matching the canonical
sort(colMeans(beta, na.rm = TRUE), decreasing = TRUE) idiom in the
varPro::uvarpro() help ("iowa housing - illustrates lasso importance").
Because get.beta.entropy() is expensive (a cross-validated glmnet per
region), the beta_fit argument accepts a pre-computed matrix so you can
iterate on the cutoff without re-fitting. The pairing mirrors the
beta_fit argument of gg_beta_varpro().
See also
gg_beta_varpro() (supervised analogue), gg_udependent(),
varPro::get.beta.entropy(), varPro::uvarpro().
Examples
# \donttest{
if (requireNamespace("varPro", quietly = TRUE)) {
set.seed(1)
o <- varPro::uvarpro(mtcars, ntree = 50)
gg <- gg_beta_uvarpro(o)
plot(gg)
}
# }