Learn R Programming

poismf (version 0.4.0-4)

predict.poismf: Predict expected count for new row(user) and column(item) combinations

Description

Predict expected count for new row(user) and column(item) combinations

Usage

# S3 method for poismf
predict(object, a, b = NULL, nthreads = parallel::detectCores(), ...)

Value

  • If `a` and `b` were passed, will return a vector of length N with the predictions for the requested row/column combinations.

  • If `b` was not passed, will return a sparse matrix with the same entries and shape as `a`, but with the values being the predictions from the model for the non-missing entries. In such case, the output will be of class `Matrix::dgTMatrix`.

Arguments

object

A Poisson factorization model as returned by `poismf`.

a

Can be either:

  • A vector of length N with the users/rows to predict - each entry will be matched to the corresponding entry at the same position in `b` - e.g. to predict value for entries (3,4), (3,5), and (3,6), should pass `a=c(3,3,3), b=c(3,5,6)`. If `X` passed to `poismf` was a `data.frame`, should match with the entries in its first column. If `X` passed to `poismf` was a matrix, should indicate the row numbers (numeration starting at 1).

  • A sparse matrix, ideally in COO (triplets) format from package `Matrix` (`Matrix::dgTMatrix`) or from package `SparseM` (`matrix.coo`), in which case it will make predictions for the non-zero entries in the matrix and will output another sparse matrix with the predicted entries as values. In this case, `b` should not be passed. This option is not available if the `X` passed to `poismf` was a `data.frame`.

b

A vector of length N with the items/columns to predict - each entry will be matched to the corresponding entry at the same position in `a` - e.g. to predict value for entries (3,4), (3,5), and (3,6), should pass `a=c(3,3,3), b=c(3,5,6)`. If `X` passed to `poismf` was a `data.frame`, should match with the entries in its second column. If `X` passed to `poismf` was a matrix, should indicate the column numbers (numeration starting at 1). If `a` is a sparse matrix, should not pass `b`.

nthreads

Number of parallel threads to use.

...

Not used.

See Also

poismf topN factors