Clean up existing entry points #34
Labels
BREAKING
Possibly breaking changes to current user-facing functionality
Code Cleanliness
Internal changes / clean-ups / refactoring
Parameter Selection
Issues / feature requests related to tuning parameter selection
User Interface
Currently we have three R wrappers. They differ in functionalities, the abstraction level of arguments they take in, and where they are used in testsuites. Eventually their functionalities will be subsets of SFPCA wrappers' and thus they should be removed.
1. sfpca
https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/R/sfpca.R#L1
It is simply an R interface for the C++ function
cpp_sfpca
, https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/src/moma_R_function.cpp#L6 which uses repeatedlyMoMA::solve
andMoMA::deflate
. We need to explicitly specify all parameters.What it does: Solve the penalized SVD for fixed alpha_u/v, lambda_u/v. It also finds rank-k SVD by repeatedly deflating the matrix and then rerunning the algorithm. Note we don't have tests for the latter functionality yet.
Where it is used in the testsuite: It is used to test the correctness of the PG algorithm. To do this we inspect special cases where closed-form solutions exist. Then we check the results obtained by our algorithm against closed-form solutions. See https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/tests/testthat/test_sfpca.R#L1.
2. moma_svd
https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/R/moma_svd.R#L61
What it does: It supports the following three use cases. Note that it cooperates with prox argument wrappers like
lasso(), scad()
and PG loop settings wrapper (not merged yet). Essentially what it does is a proper subset ofMoMA::select_nestedBIC
described in section 3.Find rank-k penalized SVD with fixed alpha_u/v and lambda_u/v by calling
cpp_sfpca
described above;Run nested-BIC search on 2-D grids, whose axises could be a combination of any two parameters, by calling
cpp_sfpca_nestedBIC
.cpp_sfpca_nestedBIC
does some sanity check and then callsMoMA::select_nestedBIC
;https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/src/moma_R_function.cpp#L179
Run grid search on 2-D grids by calling
cpp_sfpca_grid
, which usesMoMA::reset
andMoMA::solve
;https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/src/moma_R_function.cpp#L80
Where it is used in the testsuite: It tests that prox arguments are correctly passed to C++ side (see
test_argument.R
https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/tests/testthat/test_arguments.R#L1 ). We also test thatcpp_sfpca_grid
andcpp_sfpca
give identical result (seetest_grid.R
https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/tests/testthat/test_grid.R#L1).3 MoMA::grid_BIC_mix
This will become the core of SFPCA wrappers (in progress). It supports finding the first k pairs of singular vectors, and the combination of nested-BIC search and grid search.
Where it is used in the testsuite: We test that it gives correctly sized lists. See https://github.com/michaelweylandt/MoMA/blob/7c8fd20fbd18d9cbfe21837bacd8ad401853efa6/tests/testthat/test_BIC_gird_mixed.R#L1
The text was updated successfully, but these errors were encountered: