Description Usage Arguments Details Value See Also Examples
Converts a matrix to libFM format
1 | matrix_libFM(mat, y)
|
mat |
matrix to be converted. Can either be a standard matrix or a sparse matrix |
y |
The response variable. If unavailable (for test data), a 1 is used because libFM requires a response. |
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
.
a character vector with one value per observation
sp_matrix_libFM
, model_frame_libFM
1 2 3 4 5 6 7 8 9 | data(movie_lens)
movie_lens_sub = tail(movie_lens, 10)
# model.matrix will remove the reference level
# which may not be desireable is some situations
movie_lens_mm = model.matrix(Rating ~ User + Movie - 1, data = movie_lens_sub)
movie_lens_libFM = matrix_libFM(movie_lens_mm, movie_lens_sub$Rating)
movie_lens_libFM
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.