Make Predictions from an "FFMRanker" Object

# S3 method for FFMRanker
predict(
  model,
  data,
  key,
  features = NULL,
  handle.missing = NULL,
  thread.ratio = NULL
)

Format

S3 methods

Arguments

model

R6Class object
A "FFMRanker" object for prediction.

data

DataFrame
DataFrame containting data of user-item interaction and global side features for prediction.

key

character
Name of the ID column.

features

list of characters, optional
Name of feature columns in data.
If not provided, it defaults all non-ID columns of data.

handle.missing

c("remove", "replace"), optional
Specifies how to handle missing features of data:

  • "remove" remove missing rows

  • "replace" replace missing rows with 0

thread.ratio

double, optional
Controls the proportion of available threads that can be used by this function.
The value range is from 0 to 1, where 0 indicates a single thread, and 1 indicates all available threads.
Values between 0 and 1 will use up to that percentage of available threads.Values outside this range are ignored.
Defaults to 0.

Value

DataFrame
Prediction made by the model, structured as follows:

  • ID: id.

  • SCORE: Predict value.

  • CONFIDENCE: the confidence of a category.

Examples


> data$Collect()
  ID USER  MOVIE TIMESTAMP
1  1    A Movie0         3
2  2    A Movie4         1
3  3    B Movie3         2
4  4    B   <NA>         5
5  5    C Movie2         2
6  6    F Movie4         3
7  7    D Movie2         2
8  8    D Movie4         1
9  9    E Movie7         4

Call the function:


> ranking.result <- predict.FFMRanker(model = FFMrank,
                                      data = data.pred.df.fit,
                                      thread.ratio = 1)

Output:


> ranking.result$Collect()
  ID    SCORE CONFIDENCE
1  1     high  0.2942058
2  2   medium  0.2098934
3  3  too low  0.3166094
4  4     high  0.2196706
5  5 too high  0.2225450
6  6     high  0.3856211
7  7  too low  0.4076951
8  8  too low  0.2952001
9  9     high  0.2826328

See also