Using the Matrix package I can create a two-dimensional sparse matrix.
Can someone suggest a package that would allow me to create a multidimensional (specifically a 3-dimensional) sparse matrix (array, or technically a three-way tensor) in R?
The slam package has a simple_sparse_array class: http://finzi.psych.upenn.edu/R/library/slam/html/array.html , although it only has support for indexing and coercion (if you wanted to do tensor operations, or elementwise arithmetic, without converting back to a regular dense array, you'd have to implement them yourself ...)
I found this by doing
library("sos")
findFn("{sparse array}")
There's also the tensorr package, which looks promising in providing support for sparse tensors, and tensor decompositions like PARAFAC/CANDECOMP etc are also on the to-do list:
https://cran.r-project.org/web/packages/tensorr/README.html
Related
I have text classification problem with over 20k features, 3m objects, and over 3k classes. Data is very sparse.
I wrote the program on R.
Data matrix in sparseMatrix object.
How can I select features on this data?
I found package FSelector, but it is not working with sparseMatrix, only data.frame, and I can not convert data due to memory limitation.
Please take a look at:
FSelector:
https://cran.r-project.org/web/packages/FSelector/FSelector.pdf
varSelRF:
https://cran.r-project.org/web/packages/varSelRF/varSelRF.pdf
R, correlation matrix filters, PCA & backward selection:
http://www.r-bloggers.com/introduction-to-feature-selection-for-bioinformaticians-using-r-correlation-matrix-filters-pca-backward-selection/
Why aren't there any multidimensional sparse matrices/arrays in Julia? Why can we only have 2D sparse matrices and not for example 3D sparse matrices (or arrays)?
The problem as I understand it (I'm not sparse linear algebra expert, although Viral Shah, who is one of the other Julia co-founders is) is that all libraries (e.g. SuiteSparse) for doing sparse computations are matrix-only. They don't support sparse vectors and they don't support higher dimensional tensors either. So we could define types for higher-dimensional sparse tensors, but you wouldn't be able to do anything useful with them.
I want to compute the Generalized Singular Value Decomposition (GSVD) for sparse matrices A and B. Therefore I am looking for an implementation that is capable of using a special data structure for sparse matrices.
The only implementation I found (here) is part of the LAPACK package which is written in Fortran 77.
It works quite good, but unfortunately it can't handle sparse matrices.
MATLAB's gsvd accepts sparse matrices. I believe Octave (freely available) supports gsvd as well.
I asked the same question on Scicomp and got good answers. The post can be found here.
I have large data in my database. I have to create a matrix has size 600.000x20.000 or like that, but many of cells will be empty. How can I use this R programming language to create my matrix or by using singular value decomposition(SVD) methods? I do not know using in language R and I'll use the sparse matrix in Java programming? I am so confused...
It seems that your answer is here. You may check SparseM or spam packages as well.
There are at least two sparse matrix packages for R. I'm looking into these because I'm working with datasets that are too big and sparse to fit in memory with a dense representation. I want basic linear algebra routines, plus the ability to easily write C code to operate on them. Which library is the most mature and best to use?
So far I've found
Matrix which has many reverse dependencies, implying it's the most used one.
SparseM which doesn't have as many reverse deps.
Various graph libraries probably have their own (implicit) versions of this; e.g. igraph and network (the latter is part of statnet). These are too specialized for my needs.
Anyone have experience with this?
From searching around RSeek.org a little bit, the Matrix package seems the most commonly mentioned one. I often think of CRAN Task Views as fairly authoritative, and the Multivariate Task View mentions Matrix and SparseM.
Matrix is the most common and has also just been accepted R standard installation (as of 2.9.0), so should be broadly available.
Matrix in base:
https://stat.ethz.ch/pipermail/r-announce/2009/000499.html
In my experience, Matrix is the best supported and most mature of the packages you mention. Its C architecture should also be fairly well-exposed and relatively straightforward to work with.
log(x) on a sparse matrix is a bad idea since log(0) isn't defined and most elements of a sparse matrix are zero.
If you would just like to get the log of the non-zero elements, try converting to a triplet sparse representation and taking a log of those values.