sp_matrix_libFM: Converts a sparse matrix to libFM format

Description Usage Arguments Details Value See Also Examples

Description

Converts a sparse matrix to libFM format

Usage

1

Arguments

mat

sparse matrix to be converted. Must be a sparse matrix from the package Matrix

y

The response variable. If unavailable (for test data), a 1 is used because libFM requires a response.

Details

If your data is sparse, sp_matrix_libFM is about 100 times faster than matrix_libFM. I recommend using the sparse version over the standard version whenever possible. If your data consists of factor variables with a lot of levels, model_frame_libFM is faster than sp_matrix_libFM.

Value

a character vector with one value per observation

See Also

model_frame_libFM, matrix_libFM

Examples

1
2
3
4
5
6
7
8
9
data(movie_lens)
movie_lens_sub = tail(movie_lens, 1000)

# model.matrix will remove the reference level
# which may not be desireable is some situations
movie_lens_mm = Matrix::sparse.model.matrix(Rating ~ User + Movie - 1, data = movie_lens_sub)

movie_lens_libFM = sp_matrix_libFM(movie_lens_mm, movie_lens_sub$Rating)
head(movie_lens_libFM)

andland/libFMexe documentation built on May 12, 2019, 2:41 a.m.