sketching: Compute a sketch matrix of input matrix

Description Usage Arguments Examples

Description

Compute a sketch matrix of input matrix

Usage

1
sketching(a, l, eps = 10^(-8))

Arguments

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)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 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)

Example output



frequentdirections documentation built on May 2, 2019, 3:27 a.m.