mat_2scipy_sparse: conversion of an R matrix to a scipy sparse matrix

Description Usage Arguments Details References Examples

View source: R/mat_2scipy_sparse.R

Description

conversion of an R matrix to a scipy sparse matrix

Usage

1
mat_2scipy_sparse(x, format = "sparse_row_matrix")

Arguments

x

a data matrix

format

a character string. Either "sparse_row_matrix" or "sparse_column_matrix"

Details

This function allows the user to convert an R matrix to a scipy sparse matrix. This is useful because the Regularized Greedy Forest algorithm accepts only python sparse matrices as input.

References

https://docs.scipy.org/doc/scipy/reference/sparse.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
try({
    if (reticulate::py_available() && reticulate::py_module_available("scipy")) {

        library(RGF)

        set.seed(1)

        x = matrix(runif(1000), nrow = 100, ncol = 10)

        res = mat_2scipy_sparse(x)

        print(dim(x))

        print(res$shape)
    }
}, silent=TRUE)

mlampros/RGF documentation built on March 17, 2021, 1:50 p.m.