predict.ALS.RdSimilar to other predict methods, this function predicts fitted values from a fitted "ALS" object.
# S3 method for ALS predict(model, data, key, used.cols = NULL, thread.ratio = NULL, ...)
| model |
|
|---|---|
| data |
|
| key |
|
| used.cols |
Default to the first two non-ID columns if not provided.. |
| thread.ratio |
|
| ... | Reserved parameter. |
S3 methods
Predicted values are returned as a DataFrame, structured as follows.
ID column, with same name and type as `data`'s ID column.
user column, representing user names/IDs.
item column, represnetiing item names/IDs.
PREDICTION column, predicted feedback of user to item.
Perform the predict on DataFrame data2 using "ALS" object als:
> data2$Collect() ID USER MOVIE 1 1 A Movie3 2 2 A Movie7 3 3 B Movie1 4 4 B Movie6 5 5 C Movie3 6 6 D Movie2 7 7 D Movie5 8 8 E Bad_Movie
Call the function and obtain the result:
> pred.res <- predict(als, data = data2,
key = "ID",
used.cols = c(user = "USER"))
> pred.res$Collect()
ID USER MOVIE PREDICTION
1 1 A Movie3 3.868747
2 2 A Movie7 2.870243
3 3 B Movie1 5.787559
4 4 B Movie6 5.837218
5 5 C Movie3 3.323575
6 6 D Movie2 4.156372
7 7 D Movie5 4.325851
8 8 E Bad_Movie 2.545807