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.1.0 |
Built: | 2025-01-28 04:09:57 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.1.0 |
Authors@R: | c(person("Koki", "Tsuyuzaki", role = c("aut", "cre"), email = "[email protected]")) |
Suggests: | testthat |
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: | libfreetype6-dev libglpk-dev libglu1-mesa-dev make libicu-dev libpng-dev libxml2-dev libgl1-mesa-dev zlib1g-dev |
Repository: | https://rikenbit.r-universe.dev |
RemoteUrl: | https://github.com/rikenbit/mwtensor |
RemoteRef: | HEAD |
RemoteSha: | 36a9f19bab5952b33dd9a323d0def15cc917a310 |
Author: | Koki Tsuyuzaki [aut, cre] |
Maintainer: | Koki Tsuyuzaki <[email protected]> |
Index of help topics:
CoupledMWCA Coupled Multi-way Component Analysis (CoupledMWCA) CoupledMWCAParams-class Class "CoupledMWCAParams" CoupledMWCAResult-class Class "CoupledMWCAResult" MWCA Multi-way Component Analysis (MWCA) MWCAParams-class Class "MWCAParams" MWCAResult-class Class "MWCAResult" defaultCoupledMWCAParams Default parameters for CoupledMWCA defaultMWCAParams Default parameters for MWCA 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 toyModel Toy model of coupled tensor data
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
, plotTensor3Ds
ls("package:mwTensor")
ls("package:mwTensor")
The input is assumed to be a CoupledMWCAParams object.
CoupledMWCA(params)
CoupledMWCA(params)
params |
CoupledMWCAParams object |
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) }
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
and MWCAResult-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) }
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) }
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.
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()
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)