Optimizing parameters

Once we have identified our best model, the next step would be to optimize this model. Every recommendation model contains some parameters--numeric or categorical. For instance, IBCF takes account of the k-closest items, but how can we optimize the value of k?

  1. Instead of specifying a single value while evaluating the model, we can specify a range of values for the parameter and then evaluate the model to find out the optimal value for this parameter:
> vector_k <- c(5, 10, 20, 30, 40) 
> models_to_evaluate <- lapply(vector_k, function(k){ 
  list(name = "IBCF", param = list(method = "cosine", k = k)) 
}) 
> names(models_to_evaluate) <- paste0("IBCF_k_", vector_k)
  1. Now visualize the best performing k with ROC curve:
> plot(list_results, ...

Get R Data Analysis Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.