Description
The KNNRecommender Predict function applies the model output by the KNNRecommender Train function to predict the ratings or preferences that users would assign to entities like books, songs, movies and other products.
Usage
td_knn_recommender_predict_mle ( object = NULL, ratings.data = NULL, weights.data = NULL, bias.data = NULL, userid.column = NULL, itemid.column = NULL, rating.column = NULL, topk = 3, ratings.data.sequence.column = NULL, weights.data.sequence.column = NULL, bias.data.sequence.column = NULL, ratings.data.partition.column = NULL ) ## S3 method for class 'td_knn_recommender_mle' predict( object = NULL, ratings.data = NULL, weights.data = NULL, bias.data = NULL, userid.column = NULL, itemid.column = NULL, rating.column = NULL, topk = 3, ratings.data.sequence.column = NULL, weights.data.sequence.column = NULL, bias.data.sequence.column = NULL, ratings.data.partition.column = NULL )
Arguments
object |
Specifies the name of the object returned by the |
ratings.data |
Required Argument. |
ratings.data.partition.column |
Required Argument. |
weights.data |
Optional Argument. |
bias.data |
Optional Argument. |
userid.column |
Optional Argument. |
itemid.column |
Optional Argument. |
rating.column |
Optional Argument. |
topk |
Optional Argument. |
ratings.data.sequence.column |
Optional Argument. |
weights.data.sequence.column |
Optional Argument. |
bias.data.sequence.column |
Optional Argument. |
Value
Function returns an object of class "td_knn_recommender_predict_mle"
which is a named list containing Teradata tbl object.
Named list member can be referenced directly with the "$" operator
using name: result.
Examples
# Get the current context/connection con <- td_get_context()$connection # Load example data. loadExampleData("knnrecommender_example", "ml_ratings") loadExampleData("knnrecommenderpredict_example", "ml_ratings_10") # The ml_ratings table has movie ratings from 50 users. ml_ratings <- tbl(con, "ml_ratings") # Build/generate the KNN Recommender model on the user ratings data td_knn_recommender_out <- td_knn_recommender_mle(rating.table = ml_ratings, userid.column = "userid", itemid.column = "itemid", rating.column = "rating" ) # ml_ratings_10 table has movie ratings from a subset of users from the ml_ratings # table. The ml_bias and ml_weights table has the weights and bias values # from the trained KNN Recommender model. ml_ratings_10 <- tbl(con, "ml_ratings_10") ml_weights <- td_knn_recommender_out$weight.model.table ml_bias <- td_knn_recommender_out$bias.model.table # Here "bias.data" and "weights.data" have been made optional with the argument "object" # having the td_knn_recommender_mle output object td_knn_recommender_predict_out <- td_knn_recommender_predict_mle( object = td_knn_recommender_out, ratings.data = ml_ratings_10, ratings.data.partition.column = c("userid"), topk = 5 ) # Alternatively use the S3 predict function to make user predictions. td_knn_recommender_predict_out1 <- predict(object = td_knn_recommender_out, ratings.data = ml_ratings_10, ratings.data.partition.column = c("userid"), topk = 5 ) # Use the generated model to make user rating predictions. Here the argument "object" # has been made optional with the specification of both the arguments "bias.data" and # "weights.data" td_knn_recommender_predict_out2 <- td_knn_recommender_predict_mle( ratings.data = ml_ratings_10, ratings.data.partition.column = c("userid"), weights.data = ml_weights, bias.data = ml_bias, topk = 5 )