Make Predictions from an "FRM" Object

# S3 method for FRM
predict(
  model,
  data,
  key = NULL,
  user.info = NULL,
  item.info = NULL,
  thread.ratio = NULL
)

Format

S3 methods

Arguments

model

R6Class object
A "FRM" object for prediction.

data

DataFrame
DataFrame containting data of user-item interaction and global side features, structured as follows:

  • Data ID column(optional).

  • USER ID column.

  • ITEM ID column.

  • Side feature columns.

key

character, optional
Name of the ID column. If not provided, the data is assumed to have no ID column.
No default value.

user.info

DataFrame
DataFrame containting information of side features about user, structured as follows:

  • USER ID column.

  • Side feature columns.

item.info

DataFrame DataFrame containing information of side features about item, structured as follows:

  • ITEM ID column.

  • Side feature columns.

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 column

  • USER ID column

  • ITEM ID column

  • Predicted rating value.

Examples

Input DataFrames:


> predict.data$Collect()
  ID USER     MOVIE TIMESTAMP
 1 1    A    Movie3        NA
 2 2    A    Movie7         4
 3 3    B    Movie1         2
 4 4    B    Movie6         3
 5 5    C    Movie3         2
 6 6    D    Movie2         1
 7 7    D    Movie5         3
 8 8    E Bad_Movie         2

> user.info$Collect()
   USER     USER_SIDE_FEATURE
1    NA                    NA

> item.info$Head(5)$Collect()
   MOVIE  GENRES
1 Movie1  Sci-Fi
2 Movie2  Drama,Romance
3 Movie3  Drama,Sci-Fi
4 Movie4  Crime,Drama
5 Movie5  Crime,Drama

Call the function with a "FRM" object fm:

result <- predict(model = fm,
                  predict.data = predict.data,
                  user.info = user.info,
                  item.info = item.info)

Output:


> result$Collect()
 ID USER      ITEM  PREDICTION
1 1    A   Movie3     3.705492
2 2    A   Movie7     3.401231
3 3    B   Movie1     5.457519
4 4    B   Movie6     5.815021
5 5    C   Movie3     3.421293
6 6    D   Movie2     4.441541
7 7    D   Movie5     4.314721
8 8    E   Bad_Movie  2.585036

See also