| mat_2scipy_sparse | R Documentation |
conversion of an R matrix to a scipy sparse matrix
mat_2scipy_sparse(x, format = "sparse_row_matrix")
x |
a data matrix |
format |
a character string. Either "sparse_row_matrix" or "sparse_column_matrix" |
This function allows the user to convert an R matrix to a scipy sparse matrix. This is useful because the nmslibR package accepts only python sparse matrices as input.
https://docs.scipy.org/doc/scipy/reference/sparse.html
try({
if (reticulate::py_available(initialize = FALSE)) {
if (reticulate::py_module_available("scipy")) {
library(nmslibR)
set.seed(1)
x = matrix(runif(1000), nrow = 100, ncol = 10)
res = mat_2scipy_sparse(x)
print(dim(x))
print(res$shape)
}
}
}, silent=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.