Repository navigation
Conversation
# Conflicts: # NEWS.md # R/RcppExports.R # src/RcppExports.cpp
…d select search candidates from term labels
…ents = TRUE); test the fallback and a latent case with thinned draws
…ver the draws in get_p_clust()
|
I pushed a1d321c. In case 2 of the description, full validated LOO took 34.9 s before this commit and 29.4 s with it (Triton, R 4.5.3, one SLURM job, one run each). The |
|
I pushed c7c6166 and 10b714e. In each search step, In case 1 of the description (200 predictors), full validated LOO took 8.3 s before these commits and 6.7 s with them. A second job gave 9.3 s and 7.5 s. |
This PR speeds up
cv_varsel()withvalidate_search = TRUEfor Gaussian submodels with the identity link, also with the latent projection. It changes the evaluation and search code that #579 added.Evaluation
For each left-out observation,
perf_eval()callsget_p_clust().get_p_clust()builds observations x clusters matrices of means and predictive variances, butperf_eval_gauss()uses only weighted column sums of them. The evaluation usesndraws_preddraws of the reference model (default 400), and each of them is its own cluster. (The search uses thenclustersclusters, which are not related.) This PR uses that case:get_p_clust(as_moments = TRUE)returns the draw index, the weight and the predictive variance of each cluster, and no matrices.wcol_moments_c()computes the weighted means and sums of squares from the draws.crossprod(), not the observations x draws matrix.perf_eval_gauss()does not apply orget_p_clust(as_moments = TRUE)returnsNULL,perf_eval()computes the fullget_p_clust()result.NULLoccurs, for example, if a cluster has more than one draw. If a projected draw is not finite,perf_eval_gauss()gets the fullget_p_clust()result.Without the observations x clusters and observations x draws matrices, garbage collection takes less time (see "Timings").
Search
Each step got its candidates from
select_possible_terms_size()and their new labels fromsetdiff()on each candidate string. If each search term is"1"or has one term label, the newsingle_label_info()(once per search) andcands_single_label()(once per step) give the same candidates and labels with vector operations. Other search terms use the old code.labels_gauss()now uses the session cache of #599.Timings
The timings are for full validated LOO. "Before" is master with #601 merged. For each case, both versions ran in one SLURM job, one run each. Case 1 ran on CSC Roihu with R 4.6.1, case 2 on Triton with R 4.5.3.
The search clusters are
nclusters, the evaluation draws arendraws_pred. Garbage collection took 1.7 s before and 0.5 s after in case 1, and 10.2 s before and 4.7 s after in case 2. The predictor ranking is identical in both cases. In case 2, the other elements of thevselobject are identical or differ by at most 1.1e-15 (relative).Tests
test_wcol_moments.R:wcol_moments_c()with R code, includingNaNand infinite values and a weight of 0.get_p_clust(as_moments = TRUE)with the fullget_p_clust()for all draws, permuted draws and thinned draws, and for Gaussian and Student-t families.NULL: clusters with more than one draw, a weight of 0, and a user-definedpredvar. It checks thatwcol_moments_c()gives a non-finite sum of squares for a non-finite projected draw.test_search_gauss.R:trace()to check that validated LOO usesas_moments = TRUE. The ranking and the submodel summaries are equal to those from the fullget_p_clust()(tolerance 1e-12).x1:f, soperf_eval_gauss()does not apply andperf_eval()uses the full result.options(projpred.search_gauss_crossprod = TRUE)and withFALSE. This option of Gaussian forward search and validated LOO evaluation from cross-products of the model matrix #579 switches the Gaussian search and evaluation code on and off.cands_single_label()withselect_possible_terms_size(), and the search with and without the new candidate code (single_label_info()mocked toNULL). The search terms include sets without"1", with a duplicated term, and with one interaction in two orders.This PR was assisted by Claude.