Title: | Implementation of Frequent-Directions Algorithm for Efficient Matrix Sketching |
---|---|
Description: | Implement frequent-directions algorithm for efficient matrix sketching. (Edo Liberty (2013) <doi:10.1145/2487575.2487623>). |
Authors: | Shinichi Takayanagi [aut, cre], Nagi Teramo [aut] |
Maintainer: | Shinichi Takayanagi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-03-10 03:34:24 UTC |
Source: | https://github.com/shinichi-takayanagi/frequentdirections |
Plot data using the first and second singular vector
plot_svd(a, label = NULL, b = a)
plot_svd(a, label = NULL, b = a)
a |
Original matrix to be sketched (n x m) |
label |
Group index for each a's row. These values are used for group and color. |
b |
A sketched matrix (l x m) |
# Dummy data size_col <- 50 size_row <- 10^3 x <- matrix( c(rnorm(size_row * size_col), rnorm(size_row * size_col, mean=1)), ncol = size_col, byrow = TRUE ) x <- scale(x) y <- rep(1:2, each=size_row) # Show 2D plot using SVD frequentdirections::plot_svd(x, y) # Matrix Skethinc(l=6) b <- frequentdirections::sketching(x, 6, 10^(-8)) # Show 2D plot using sketched matrix and show similar result with the above # That means that 6 dim is enough to express the original data matrix (x) frequentdirections::plot_svd(x, y, b)
# Dummy data size_col <- 50 size_row <- 10^3 x <- matrix( c(rnorm(size_row * size_col), rnorm(size_row * size_col, mean=1)), ncol = size_col, byrow = TRUE ) x <- scale(x) y <- rep(1:2, each=size_row) # Show 2D plot using SVD frequentdirections::plot_svd(x, y) # Matrix Skethinc(l=6) b <- frequentdirections::sketching(x, 6, 10^(-8)) # Show 2D plot using sketched matrix and show similar result with the above # That means that 6 dim is enough to express the original data matrix (x) frequentdirections::plot_svd(x, y, b)
Compute a sketch matrix of input matrix
sketching(a, l, eps = 10^(-8))
sketching(a, l, eps = 10^(-8))
a |
Original matrix to be sketched (n x m) |
l |
The number of rows in sketched matrix (l x m) |
eps |
If a value is smaller than eps, that is considered as equal to zero. The default value is 10^(-8) |
# Dummy data size_col <- 50 size_row <- 10^3 x <- matrix( c(rnorm(size_row * size_col), rnorm(size_row * size_col, mean=1)), ncol = size_col, byrow = TRUE ) x <- scale(x) y <- rep(1:2, each=size_row) # Show 2D plot using SVD frequentdirections::plot_svd(x, y) # Matrix Skethinc(l=6) b <- frequentdirections::sketching(x, 6, 10^(-8)) # Show 2D plot using sketched matrix and show similar result with the above # That means that 6 dim is enough to express the original data matrix (x) frequentdirections::plot_svd(x, y, b)
# Dummy data size_col <- 50 size_row <- 10^3 x <- matrix( c(rnorm(size_row * size_col), rnorm(size_row * size_col, mean=1)), ncol = size_col, byrow = TRUE ) x <- scale(x) y <- rep(1:2, each=size_row) # Show 2D plot using SVD frequentdirections::plot_svd(x, y) # Matrix Skethinc(l=6) b <- frequentdirections::sketching(x, 6, 10^(-8)) # Show 2D plot using sketched matrix and show similar result with the above # That means that 6 dim is enough to express the original data matrix (x) frequentdirections::plot_svd(x, y, b)