| Title: | Multi-Way Component Analysis |
|---|---|
| Description: | For single tensor data, any matrix factorization method can be specified the matricised tensor in each dimension by Multi-way Component Analysis (MWCA). An originally extended MWCA is also implemented to specify and decompose multiple matrices and tensors simultaneously (CoupledMWCA). See the reference section of GitHub README.md <https://github.com/rikenbit/mwTensor>, for details of the methods. |
| Authors: | Koki Tsuyuzaki [aut, cre] |
| Maintainer: | Koki Tsuyuzaki <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.2 |
| Built: | 2026-05-11 11:00:10 UTC |
| Source: | https://github.com/rikenbit/mwtensor |
For single tensor data, any matrix factorization method can be specified the matricised tensor in each dimension by Multi-way Component Analysis (MWCA). An originally extended MWCA is also implemented to specify and decompose multiple matrices and tensors simultaneously (CoupledMWCA). See the reference section of GitHub README.md <https://github.com/rikenbit/mwTensor>, for details of the methods.
The DESCRIPTION file:
| Package: | mwTensor |
| Type: | Package |
| Title: | Multi-Way Component Analysis |
| Version: | 1.2.2 |
| Authors@R: | c(person("Koki", "Tsuyuzaki", role = c("aut", "cre"), email = "[email protected]")) |
| Suggests: | testthat, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Depends: | R (>= 4.1.0) |
| Imports: | methods, MASS, rTensor, nnTensor, ccTensor, iTensor, igraph |
| Description: | For single tensor data, any matrix factorization method can be specified the matricised tensor in each dimension by Multi-way Component Analysis (MWCA). An originally extended MWCA is also implemented to specify and decompose multiple matrices and tensors simultaneously (CoupledMWCA). See the reference section of GitHub README.md <https://github.com/rikenbit/mwTensor>, for details of the methods. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/rikenbit/mwTensor |
| Config/pak/sysreqs: | cmake libfreetype6-dev libglpk-dev libglu1-mesa-dev make texlive libicu-dev libpng-dev libuv1-dev libxml2-dev libgl1-mesa-dev zlib1g-dev |
| Repository: | https://rikenbit.r-universe.dev |
| Date/Publication: | 2026-05-07 05:37:38 UTC |
| RemoteUrl: | https://github.com/rikenbit/mwtensor |
| RemoteRef: | HEAD |
| RemoteSha: | 4ea233ec598ee64560880aa58ab09de383205729 |
| Author: | Koki Tsuyuzaki [aut, cre] |
| Maintainer: | Koki Tsuyuzaki <[email protected]> |
Index of help topics:
checkCoupledMWCA Static Validation of CoupledMWCA Parameters
compileMWCAProgram Compile an MWCAProgram to Solver Parameters
CoupledMWCA Coupled Multi-way Component Analysis
(CoupledMWCA)
CoupledMWCAInit-class Class '"CoupledMWCAInit"'
CoupledMWCAParams-class
Class "CoupledMWCAParams"
CoupledMWCAResult-class
Class "CoupledMWCAResult"
defaultCoupledMWCAParams
Default parameters for CoupledMWCA
defaultMWCAParams Default parameters for MWCA
executeMWCAProgram Execute an MWCAProgram (Experimental)
initCoupledMWCA Initialize CoupledMWCA Factors and Cores
MWCA Multi-way Component Analysis (MWCA)
MWCAParams-class Class "MWCAParams"
MWCAProgram Factorization Program Representation
MWCAResult-class Class "MWCAResult"
mwTensor-package Multi-Way Component Analysis
myALS_SVD Alternating Least Square Singular Value
Decomposition (ALS-SVD) as an example of
user-defined matrix decomposition.
myCX CX Decomposition as an example of user-defined
matrix decomposition.
myICA Independent Component Analysis (ICA) as an
example of user-defined matrix decomposition.
myNMF Independent Component Analysis (ICA) as an
example of user-defined matrix decomposition.
mySVD Singular Value Decomposition (SVD) as an
example of user-defined matrix decomposition.
plotTensor3Ds Plot function for visualization of tensor data
structure
RefinedFactor-class Class '"RefinedFactor"'
refineFactor One-Step Factor Refinement (Experimental)
toyModel Toy model of coupled tensor data
validateMWCAProgram Validate an MWCAProgram
Koki Tsuyuzaki [aut, cre]
Maintainer: Koki Tsuyuzaki <[email protected]>
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
Gene H. Golub et al., (2012). Matrix Computation (Johns Hopkins Studies in the Mathematical Sciences), Johns Hopkins University Press
Madeleine Udell et al., (2016). Generalized Low Rank Models, Foundations and Trends in Machine Learning, 9(1).
Andrzej CICHOCK, et. al., (2009). Nonnegative Matrix and Tensor Factorizations.
A. Hyvarinen. (1999). Fast and Robust Fixed-Point Algorithms for Independent Component Analysis. IEEE Transactions on Neural Networks, 10(3), 626-634.
Petros Drineas et al., (2008). Relative-Error CUR Matrix Decompositions, SIAM Journal on Matrix Analysis and Applications, 30(2), 844-881.
mySVD, myALS_SVD, myNMF, myICA, myCX, MWCA, CoupledMWCA, checkCoupledMWCA, initCoupledMWCA, refineFactor, MWCAProgram, plotTensor3Ds
ls("package:mwTensor")ls("package:mwTensor")
Validates a CoupledMWCAParams object without running optimization.
Collects all errors and warnings instead of stopping on the first failure.
This is useful for pre-validating candidate decomposition problems
before committing to a potentially expensive CoupledMWCA run.
checkCoupledMWCA(params)checkCoupledMWCA(params)
params |
A |
A list with the following components:
Logical. TRUE if no errors were found.
Character vector of error messages (empty if ok is TRUE).
Character vector of warning messages.
The input params if valid, or NULL if errors exist.
A single human-readable summary string.
Koki Tsuyuzaki
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
CoupledMWCA, defaultCoupledMWCAParams, CoupledMWCAParams-class.
if(interactive()){ # Test data Xs <- toyModel("coupled_CP_Easy") common_model <- list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) params <- defaultCoupledMWCAParams(Xs, common_model) # Validate without running optimization result <- checkCoupledMWCA(params) result$ok # TRUE result$errors # character(0) result$summary # "Validation passed" }if(interactive()){ # Test data Xs <- toyModel("coupled_CP_Easy") common_model <- list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) params <- defaultCoupledMWCAParams(Xs, common_model) # Validate without running optimization result <- checkCoupledMWCA(params) result$ok # TRUE result$errors # character(0) result$summary # "Validation passed" }
Converts a validated, non-recursive MWCAProgram into
MWCAParams (single block) or CoupledMWCAParams
(multiple blocks). Programs with refinements cannot currently be
compiled.
compileMWCAProgram(program, Xs, ...)compileMWCAProgram(program, Xs, ...)
program |
An |
Xs |
Named list of input arrays, with names matching the program's block names. |
... |
Additional parameters: |
An MWCAParams or CoupledMWCAParams object.
Koki Tsuyuzaki
MWCAProgram, validateMWCAProgram,
MWCA, CoupledMWCA.
The input is assumed to be a CoupledMWCAParams or CoupledMWCAInit object.
When a CoupledMWCAInit object (produced by
initCoupledMWCA) is passed, its pre-computed factor
matrices are used as the starting point for optimization.
CoupledMWCA(params)CoupledMWCA(params)
params |
A |
CoupledMWCAResult object.
Koki Tsuyuzaki
CoupledMWCAParams-class and CoupledMWCAResult-class.
if(interactive()){ # Test data (multiple arrays) Xs=list( X1=array(runif(7*4), dim=c(7,4)), X2=array(runif(4*5*6), dim=c(4,5,6)), X3=array(runif(6*8), dim=c(6,8))) # Setting of factor matrices common_model=list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) # Default Parameters params <- defaultCoupledMWCAParams(Xs=Xs, common_model=common_model) # Perform Coupled MWCA out <- CoupledMWCA(params) }if(interactive()){ # Test data (multiple arrays) Xs=list( X1=array(runif(7*4), dim=c(7,4)), X2=array(runif(4*5*6), dim=c(4,5,6)), X3=array(runif(6*8), dim=c(6,8))) # Setting of factor matrices common_model=list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) # Default Parameters params <- defaultCoupledMWCAParams(Xs=Xs, common_model=common_model) # Perform Coupled MWCA out <- CoupledMWCA(params) }
"CoupledMWCAInit"
Container for CoupledMWCA initialization results produced by
initCoupledMWCA.
The CoupledMWCAParams object used for initialization.
Named list of common factor matrices.
List of common core tensors.
Named list of specific factor matrices.
List of specific core tensors.
Character string indicating the initialization policy used.
The random seed used, or NULL.
initCoupledMWCA, CoupledMWCAParams-class.
The parameter object to be specified against CoupledMWCA function.
Objects can be created by calls of the form new("CoupledMWCAParams", ...).
MWCAParams has four settings as follows. For each setting, the list must have the same structure.
1. Data-wise setting Each item must be a list object that is as long as the number of data and is named after the data.
A list containing multiple high-dimensional arrays.
A list containing multiple high-dimensional arrays, in which 0 or 1 values are filled to specify the missing elements.
The pseudo count to avoid zero division, when the element is zero (Default: Machine Epsilon).
A list containing multiple high-dimensional arrays, in which some numeric values are specified to weigth each data.
2. Common Model setting Each item must be a nested list object that is as long as the number of data and is named after the data.
Each element of the list must be a list corresponding the dimention name of data and common factor matrices name.
3. Common Factor matrix-wise setting Each item must be a list object that is as long as the number of common factor matrices and is named after the factor matrices.
The initial values of common factor matrices. If nothing is specified, random matrices are used.
Algorithms used to decompose the matricised tensor in each mode.
The number of iterations.
If FALSE is specified, unit matrix is used as the common factor matrix.
If TRUE is specified, the common factor matrix is not updated in the iteration.
The lower dimension of each common factor matrix.
Whether the common factor matrix is transposed to calculate core tensor.
If "CP" is specified, all the core tensors become diagonal core tensors. If "Tucker" is specified, all the core tensors become dense core tensors.
4. Specific Model setting Each item must be a nested list object that is as long as the number of data and is named after the data.
Each element of the list must be a list corresponding the dimention name of data and data specific factor matrices name.
5. Specific Factor matrix-wise setting Each item must be a list object that is as long as the number of data specific factor matrices and is named after the factor matrices.
The initial values of data specific factor matrices. If nothing is specified, random matrices are used.
Algorithms used to decompose the matricised tensor in each mode.
The number of iterations.
If FALSE is specified, unit matrix is used as the data specific factor matrix.
If TRUE is specified, the data specific factor matrix is not updated in the iteration.
The lower dimension of each data specific factor matrix.
Whether the data specific factor matrix is transposed to calculate core tensor.
If "CP" is specified, all the core tensors become diagonal core tensors. If "Tucker" is specified, all the core tensors become dense core tensors.
6. Other option Each item must to be a vector of length 1.
Whether data specific factor matrices are also calculated.
The threshold to stop the iteration. The higher the value, the faster the iteration will stop.
Whether the output is visualized.
When viz=TRUE, whether the plot is output in the directory.
Whether the process is monitored by verbose messages.
Function to peform CoupledMWCA.
CoupledMWCAResult-class, CoupledMWCA
The result object genarated by CoupledMWCA function.
weights of CoupledMWCAParams.
common_model of CoupledMWCAParams.
common_initial of CoupledMWCAParams.
common_algorithms of CoupledMWCAParams.
common_iteration of CoupledMWCAParams.
common_decomp of CoupledMWCAParams.
common_fix of CoupledMWCAParams.
common_dims of CoupledMWCAParams.
common_transpose of CoupledMWCAParams.
common_coretype of CoupledMWCAParams.
Common factor matrices of CoupledMWCA.
Common core tensors of CoupledMWCA.
specific_model of CoupledMWCAParams.
specific_initial of CoupledMWCAParams.
specific_algorithms of CoupledMWCAParams.
specific_iteration of CoupledMWCAParams.
specific_decomp of CoupledMWCAParams.
specific_fix of CoupledMWCAParams.
specific_dims of CoupledMWCAParams.
specific_transpose of CoupledMWCAParams.
specific_coretype of CoupledMWCAParams.
Data specific factor matrices of CoupledMWCA.
Data specific core tensors of CoupledMWCA.
specific of CoupledMWCAParams.
thr of CoupledMWCAParams.
viz of CoupledMWCAParams.
figdir of CoupledMWCAParams.
verbose of CoupledMWCAParams.
The reconstructed error.
Training Error. train_error + test_error = rec_error.
Test Error. train_error + test_error = rec_error.
The relative change of each iteration step.
CoupledMWCAParams-class, CoupledMWCA
The input list is assumed to contain multiple arrays.
defaultCoupledMWCAParams(Xs, common_model)defaultCoupledMWCAParams(Xs, common_model)
Xs |
A list object containing multiple arrays |
common_model |
A list object to describe the relationship between dimensions of each tensor and factor matrices extracted from the tensor |
CoupledMWCAParams object.
Koki Tsuyuzaki
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
CoupledMWCAParams-class, CoupledMWCA, checkCoupledMWCA, initCoupledMWCA.
if(interactive()){ # Test data (multiple arrays) Xs=list( X1=array(runif(7*4), dim=c(7,4)), X2=array(runif(4*5*6), dim=c(4,5,6)), X3=array(runif(6*8), dim=c(6,8))) # Setting of factor matrices common_model=list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) # Default Parameters params <- defaultCoupledMWCAParams(Xs=Xs, common_model=common_model) # Perform Coupled MWCA out <- CoupledMWCA(params) }if(interactive()){ # Test data (multiple arrays) Xs=list( X1=array(runif(7*4), dim=c(7,4)), X2=array(runif(4*5*6), dim=c(4,5,6)), X3=array(runif(6*8), dim=c(6,8))) # Setting of factor matrices common_model=list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) # Default Parameters params <- defaultCoupledMWCAParams(Xs=Xs, common_model=common_model) # Perform Coupled MWCA out <- CoupledMWCA(params) }
The input is assumed to be an array object.
defaultMWCAParams(X)defaultMWCAParams(X)
X |
An array object |
MWCAParams object.
Koki Tsuyuzaki
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
MWCAParams-class and MWCAResult-class.
if(interactive()){ # Test data (single array) X <- nnTensor::toyModel("Tucker")@data # Default Parameters params <- defaultMWCAParams(X) # Perform MWCA out <- MWCA(params) }if(interactive()){ # Test data (single array) X <- nnTensor::toyModel("Tucker")@data # Default Parameters params <- defaultMWCAParams(X) # Perform MWCA out <- MWCA(params) }
Compiles and runs an MWCAProgram, including optional
one-step factor refinements. For programs without refinements, this is
equivalent to compileMWCAProgram followed by
CoupledMWCA (or MWCA).
Refinements are applied after the main decomposition completes,
using refineFactor.
executeMWCAProgram(program, Xs, ...)executeMWCAProgram(program, Xs, ...)
program |
An |
Xs |
Named list of input arrays. |
... |
Additional parameters passed to |
A list with components:
The MWCAResult or CoupledMWCAResult.
Named list of RefinedFactor objects
(empty list if no refinements).
Koki Tsuyuzaki
MWCAProgram, compileMWCAProgram,
refineFactor.
Generates normalized, reproducible initial values for a CoupledMWCA
problem without running iterative optimization. This is a companion to
checkCoupledMWCA and can be used to inspect or store
initial states before calling CoupledMWCA.
initCoupledMWCA(params, seed = NULL, init_policy = "random")initCoupledMWCA(params, seed = NULL, init_policy = "random")
params |
A |
seed |
An optional integer seed for reproducibility. When |
init_policy |
Character string specifying the initialization strategy.
One of |
A CoupledMWCAInit object with the following slots:
The input CoupledMWCAParams.
Named list of initialized common factor matrices.
List of initialized common core tensors.
Named list of initialized specific factor matrices
(or list(NULL) when specific=FALSE).
List of initialized specific core tensors
(or list(NULL) when specific=FALSE).
The policy used.
The seed used (or NULL).
Koki Tsuyuzaki
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
checkCoupledMWCA, CoupledMWCA,
defaultCoupledMWCAParams.
if(interactive()){ # Test data Xs <- toyModel("coupled_CP_Easy") common_model <- list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) params <- defaultCoupledMWCAParams(Xs, common_model) # Initialize with seed for reproducibility init <- initCoupledMWCA(params, seed=42L) # Inspect shapes lapply(init@common_factors, dim) # SVD-based initialization init_svd <- initCoupledMWCA(params, seed=42L, init_policy="svd") }if(interactive()){ # Test data Xs <- toyModel("coupled_CP_Easy") common_model <- list( X1=list(I1="A1", I2="A2"), X2=list(I2="A2", I3="A3", I4="A4"), X3=list(I4="A4", I5="A5")) params <- defaultCoupledMWCAParams(Xs, common_model) # Initialize with seed for reproducibility init <- initCoupledMWCA(params, seed=42L) # Inspect shapes lapply(init@common_factors, dim) # SVD-based initialization init_svd <- initCoupledMWCA(params, seed=42L, init_policy="svd") }
The input is assumed to be a MWCAParams object.
MWCA(params)MWCA(params)
params |
MWCAParams object |
MWCAResult object.
Koki Tsuyuzaki
Andrzej Cichocki et al., (2016). Tensor Networks for Dimensionality Reduction and Large-scale Optimization: Part 1 Low-Rank Tensor Decompositions
Andrzej Cichocki et al., (2015). Tensor Decompositions for Signal Processing Applications, IEEE SIGNAL PROCESSING MAGAZINE
MWCAParams-class and MWCAResult-class.
if(interactive()){ # Test data (single array) X <- nnTensor::toyModel("Tucker")@data # Default Parameters params <- defaultMWCAParams(X) # Perform MWCA out <- MWCA(params) }if(interactive()){ # Test data (single array) X <- nnTensor::toyModel("Tucker")@data # Default Parameters params <- defaultMWCAParams(X) # Perform MWCA out <- MWCA(params) }
The parameter object to be specified against MWCA function.
Objects can be created by calls of the form new("MWCAParams", ...).
A high-dimensional array.
A mask array having the same dimension of X.
The pseudo count to avoid zero division, when the element is zero (Default: Machine Epsilon).
Algorithms used to decompose the matricised tensor in each mode.
The lower dimension of each factor matrix.
Whether the factor matrix is transposed to calculate core tensor.
Whether the output is visualized.
When viz=TRUE, whether the plot is output in the directory.
Function to peform MWCA.
A lightweight S3-based internal representation for factorization programs.
This is a structural description layer between problem specification and
the existing solver parameters (MWCAParams,
CoupledMWCAParams).
Designed as a foundation for future recursive decomposition support (decomposing factors obtained from an initial decomposition). Currently only depth-0 (no refinement) and depth-1 (one-step factor refinement) programs are representable. Full recursive optimization is not implemented.
MWCAProgram(blocks, factors, refinements = list()) MWCAProgramBlock(modes, factor_map, type = "common", weight = 1) MWCAProgramFactor(mode, dim, status = "decomposed", algorithm = "mySVD", type = "common") MWCAProgramRefinement(source_factor, algorithm = "mySVD", dim = 2L)MWCAProgram(blocks, factors, refinements = list()) MWCAProgramBlock(modes, factor_map, type = "common", weight = 1) MWCAProgramFactor(mode, dim, status = "decomposed", algorithm = "mySVD", type = "common") MWCAProgramRefinement(source_factor, algorithm = "mySVD", dim = 2L)
blocks |
Named list of block descriptors (created by |
factors |
Named list of factor descriptors (created by |
refinements |
Named list of refinement descriptors (created by
|
modes |
Character vector of mode names for the block. |
factor_map |
Named character vector mapping mode names to factor names. |
type |
One of |
weight |
Numeric weight for the block (default 1). |
mode |
Character. The mode name associated with a factor. |
dim |
Integer. Target lower dimension. |
status |
One of |
algorithm |
Character or NULL. Decomposition algorithm name. |
source_factor |
Character. Name of the factor to refine. |
MWCAProgram returns an S3 object of class "MWCAProgram".
MWCAProgramBlock, MWCAProgramFactor, and
MWCAProgramRefinement return S3 objects of their respective classes.
Koki Tsuyuzaki
validateMWCAProgram, compileMWCAProgram,
CoupledMWCA, MWCA.
if(interactive()){ # A simple 3-block coupled program prog <- MWCAProgram( blocks=list( X1=MWCAProgramBlock(modes=c("I1","I2"), factor_map=c(I1="A1", I2="A2")), X2=MWCAProgramBlock(modes=c("I2","I3","I4"), factor_map=c(I2="A2", I3="A3", I4="A4")), X3=MWCAProgramBlock(modes=c("I4","I5"), factor_map=c(I4="A4", I5="A5"))), factors=list( A1=MWCAProgramFactor(mode="I1", dim=3), A2=MWCAProgramFactor(mode="I2", dim=3), A3=MWCAProgramFactor(mode="I3", dim=5), A4=MWCAProgramFactor(mode="I4", dim=4), A5=MWCAProgramFactor(mode="I5", dim=4))) print(prog) validateMWCAProgram(prog) # One-step refinement (structural only; compilation not yet supported) prog_ref <- MWCAProgram( blocks=prog$blocks, factors=prog$factors, refinements=list( R1=MWCAProgramRefinement(source_factor="A2", algorithm="myNMF", dim=2))) validateMWCAProgram(prog_ref) }if(interactive()){ # A simple 3-block coupled program prog <- MWCAProgram( blocks=list( X1=MWCAProgramBlock(modes=c("I1","I2"), factor_map=c(I1="A1", I2="A2")), X2=MWCAProgramBlock(modes=c("I2","I3","I4"), factor_map=c(I2="A2", I3="A3", I4="A4")), X3=MWCAProgramBlock(modes=c("I4","I5"), factor_map=c(I4="A4", I5="A5"))), factors=list( A1=MWCAProgramFactor(mode="I1", dim=3), A2=MWCAProgramFactor(mode="I2", dim=3), A3=MWCAProgramFactor(mode="I3", dim=5), A4=MWCAProgramFactor(mode="I4", dim=4), A5=MWCAProgramFactor(mode="I5", dim=4))) print(prog) validateMWCAProgram(prog) # One-step refinement (structural only; compilation not yet supported) prog_ref <- MWCAProgram( blocks=prog$blocks, factors=prog$factors, refinements=list( R1=MWCAProgramRefinement(source_factor="A2", algorithm="myNMF", dim=2))) validateMWCAProgram(prog_ref) }
The result object genarated by MWCA function.
algorithm of MWCAParams.
dims of MWCAParams.
transpose of MWCAParams.
viz of MWCAParams.
figdir of MWCAParams.
The factor matrices of MWCA.
The core tensor of MWCA.
The reconstructed error.
Training Error. train_error + test_error = rec_error.
Test Error. train_error + test_error = rec_error.
The input data is assumed to be a matrix. When algorithms of MWCAParams and CoupledMWCAParams are specified as "myALS_SVD", This function is called in MWCA and CoupledMWCA.
myALS_SVD(Xn, k, L2=1e-10, iter=30)myALS_SVD(Xn, k, L2=1e-10, iter=30)
Xn |
The input matrix which has N-rows and M-columns. |
k |
The rank parameter (k <= min(N,M)) |
L2 |
The regularization parameter (Default: 1e-10) |
iter |
The number of iteration (Default: 30) |
The output matrix which has N-rows and k-columns.
Koki Tsuyuzaki
Madeleine Udell et al., (2016). Generalized Low Rank Models, Foundations and Trends in Machine Learning, 9(1).
if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform ALS-SVD myALS_SVD(matdata, k=3, L2=0.1, iter=10) }if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform ALS-SVD myALS_SVD(matdata, k=3, L2=0.1, iter=10) }
The input data is assumed to be a matrix. When algorithms of MWCAParams and CoupledMWCAParams are specified as "myCX", This function is called in MWCA and CoupledMWCA.
myCX(Xn, k)myCX(Xn, k)
Xn |
The input matrix which has N-rows and M-columns. |
k |
The rank parameter (k <= min(N,M)) |
The output matrix which has N-rows and k-columns.
Koki Tsuyuzaki
Petros Drineas et al., (2008). Relative-Error CUR Matrix Decompositions, SIAM Journal on Matrix Analysis and Applications, 30(2), 844-881.
if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform CX myCX(matdata, k=3) }if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform CX myCX(matdata, k=3) }
The input data is assumed to be a matrix. When algorithms of MWCAParams and CoupledMWCAParams are specified as "myICA", This function is called in MWCA and CoupledMWCA.
myICA(Xn, k)myICA(Xn, k)
Xn |
The input matrix which has N-rows and M-columns. |
k |
The rank parameter (k <= min(N,M)) |
The output matrix which has N-rows and k-columns.
Koki Tsuyuzaki
A. Hyvarinen. (1999). Fast and Robust Fixed-Point Algorithms for Independent Component Analysis. IEEE Transactions on Neural Networks, 10(3), 626-634.
if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform ICA myICA(matdata, k=3) }if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform ICA myICA(matdata, k=3) }
The input data is assumed to be a matrix. When algorithms of MWCAParams and CoupledMWCAParams are specified as "myNMF", This function is called in MWCA and CoupledMWCA.
myNMF(Xn, k, L1=1e-10, L2=1e-10)myNMF(Xn, k, L1=1e-10, L2=1e-10)
Xn |
The input matrix which has N-rows and M-columns. |
k |
The rank parameter (k <= min(N,M)) |
L1 |
The regularization parameter to control the sparseness (Default: 1e-10) |
L2 |
The regularization parameter to control the overfit (Default: 1e-10) |
The output matrix which has N-rows and k-columns.
Koki Tsuyuzaki
Andrzej CICHOCK, et. al., (2009). Nonnegative Matrix and Tensor Factorizations.
if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform NMF myNMF(matdata, k=3, L1=1e-1, L2=1e-2) }if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform NMF myNMF(matdata, k=3, L1=1e-1, L2=1e-2) }
The input data is assumed to be a matrix. When algorithms of MWCAParams and CoupledMWCAParams are specified as "mySVD", This function is called in MWCA and CoupledMWCA.
mySVD(Xn, k)mySVD(Xn, k)
Xn |
The input matrix which has N-rows and M-columns. |
k |
The rank parameter (k <= min(N,M)) |
The output matrix which has N-rows and k-columns.
Koki Tsuyuzaki
if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform SVD mySVD(matdata, k=3) }if(interactive()){ # Test data matdata <- matrix(runif(10*20), nrow=10, ncol=20) # Perform SVD mySVD(matdata, k=3) }
Multiple multi-dimensional arrays and matrices are visualized simultaneously.
plotTensor3Ds(Xs)plotTensor3Ds(Xs)
Xs |
A List object containing multi-dimensional array (or matrix) in each element. |
Koki Tsuyuzaki
plotTensor3D and plotTensor2D.
Xs <- toyModel(model = "coupled_CP_Easy") tmp <- tempdir() png(filename=paste0(tmp, "/couled_CP.png")) plotTensor3Ds(Xs) dev.off()Xs <- toyModel(model = "coupled_CP_Easy") tmp <- tempdir() png(filename=paste0(tmp, "/couled_CP.png")) plotTensor3Ds(Xs) dev.off()
"RefinedFactor"
Container for one-step factor refinement results produced by
refineFactor.
Given a factor matrix A (k x n), the refinement decomposes
t(A) (n x k) into U * V where U is n x dim
and V is dim x k. The slots store:
sub_factors = t(U): the refined sub-basis (dim x n)
coef = t(V): coefficients (k x dim) such that
A is approximately coef %*% sub_factors
The original MWCAResult or CoupledMWCAResult.
Character. Name or index of the source factor.
Matrix. The original factor (k x n).
Character. Algorithm used for refinement.
Integer. Target dimension.
Matrix. Refined sub-basis (dim x n).
Matrix. Coefficient matrix (k x dim).
Takes a factor matrix from a completed MWCA or
CoupledMWCA fit and applies a single additional matrix
factorization to decompose it further.
This is not a full recursive decomposition engine. Only one level of refinement is supported.
refineFactor(fit, factor_name, algorithm = "mySVD", dim = 2L)refineFactor(fit, factor_name, algorithm = "mySVD", dim = 2L)
fit |
An |
factor_name |
For |
algorithm |
Character. Decomposition algorithm name. |
dim |
Integer. Target lower dimension for the refinement. |
Mathematical interpretation:
In MWCA/CoupledMWCA, each factor matrix A has shape k x n
where k is the lower dimension and n is the original observation
dimension. Each row of A is a basis vector in the
n-dimensional observation space.
refineFactor treats t(A) (n x k) as a new observed
matrix and decomposes it: t(A) = U * V where U is
n x dim and V is dim x k.
Equivalently, A = t(V) * t(U), so the original k basis
vectors are approximated by dim sub-basis vectors.
The returned sub_factors slot holds t(U) (dim x n):
the new lower-rank basis vectors. The coef slot holds
t(V) (k x dim): the coefficients expressing the original
factor rows in terms of the sub-basis.
If the original decomposition was X = S x_m A_m x ...,
then after refinement of A_m:
X ~ (S x_m coef) x_m sub_factors x ....
Computing this updated core is left to the caller.
A RefinedFactor object with slots:
The original fit object.
Character label identifying the source factor.
The original factor matrix A (k x n).
Algorithm used.
Target dimension used.
t(U): the refined sub-basis (dim x n).
t(V): coefficient matrix (k x dim) such that
A is approximately coef %*% sub_factors.
Koki Tsuyuzaki
MWCA, CoupledMWCA,
RefinedFactor-class.
if(interactive()){ X <- matrix(runif(20*30), nrow=20, ncol=30) params <- defaultMWCAParams(X) params@dims <- c(5L, 5L) fit <- MWCA(params) ref <- refineFactor(fit, 1L, algorithm="mySVD", dim=2L) dim(ref@sub_factors) # 2 x 20 dim(ref@coef) # 5 x 2 }if(interactive()){ X <- matrix(runif(20*30), nrow=20, ncol=30) params <- defaultMWCAParams(X) params@dims <- c(5L, 5L) fit <- MWCA(params) ref <- refineFactor(fit, 1L, algorithm="mySVD", dim=2L) dim(ref@sub_factors) # 2 x 20 dim(ref@coef) # 5 x 2 }
A list object containing multiple arrays are generated.
toyModel(model = "coupled_CP_Easy", seeds=123)toyModel(model = "coupled_CP_Easy", seeds=123)
model |
"coupled_CP_Easy", "coupled_CP_Hard", "coupled_Tucker_Easy", "coupled_Tucker_Hard", "coupled_Complex_Easy", or "coupled_Complex_Hard" can be specified (Default: "coupled_CP_Easy"). |
seeds |
The seed of random number (Default: 123). |
Koki Tsuyuzaki
Xs1 <- toyModel(model = "coupled_CP_Easy", seeds=123) Xs2 <- toyModel(model = "coupled_CP_Hard", seeds=123) Xs3 <- toyModel(model = "coupled_Tucker_Easy", seeds=123) Xs4 <- toyModel(model = "coupled_Tucker_Hard", seeds=123) Xs5 <- toyModel(model = "coupled_Complex_Easy", seeds=123) Xs6 <- toyModel(model = "coupled_Complex_Hard", seeds=123)Xs1 <- toyModel(model = "coupled_CP_Easy", seeds=123) Xs2 <- toyModel(model = "coupled_CP_Hard", seeds=123) Xs3 <- toyModel(model = "coupled_Tucker_Easy", seeds=123) Xs4 <- toyModel(model = "coupled_Tucker_Hard", seeds=123) Xs5 <- toyModel(model = "coupled_Complex_Easy", seeds=123) Xs6 <- toyModel(model = "coupled_Complex_Hard", seeds=123)
Checks structural consistency of a factorization program without running any computation. Validates factor references, mode mappings, and refinement depth constraints.
validateMWCAProgram(program)validateMWCAProgram(program)
program |
An |
A list with components:
Logical. TRUE if no errors.
Character vector of error messages.
Character vector of warning messages.
Human-readable summary string.
Koki Tsuyuzaki
MWCAProgram, compileMWCAProgram.