Skip to content

Instantly share code, notes, and snippets.

@mklew
Last active January 4, 2016 16:09
Show Gist options
  • Save mklew/8645738 to your computer and use it in GitHub Desktop.
Save mklew/8645738 to your computer and use it in GitHub Desktop.
recommenderlab z parametrami dla realRatingMatrix
recommenderRegistry$set_entry(
method="IBCF", dataType = "realRatingMatrix", fun=REAL_IBCF,
description="Recommender based on item-based collaborative filtering (real data).",
parameters=.REAL_IBCF_params)
.REAL_IBCF_params <- list(
k = 30,
method="Cosine",
normalize = "center",
normalize_sim_matrix = FALSE,
alpha = 0.5,
na_as_zero = FALSE,
minRating = NA
)
dissimilarity method for binaryRatingMatrix:
"jaccard"
"karypis"
"conditional"
dissimilarity method for realRatingMatrix:
"cosine"
"karypis"
"conditional"
"pearson"
similarity:
"cosine"
"karypis"
"conditional"
normalize:
"center"
"Z-score"
recommenderRegistry$set_entry(
method="PCA", dataType = "realRatingMatrix", fun=REAL_PCA,
description="Recommender based on PCA approximation (real data).",
parameters = .REAL_PCA_param)
.REAL_PCA_param <- list(
categories = 20,
method="Cosine",
normalize = "center",
normalize_sim_matrix = FALSE,
alpha = 0.5,
na_as_zero = FALSE,
minRating = NA
)
nie ma parametrów
Tutaj widać, że z recommenderRegistry brana jest odpowiednia metoda a potem dla tej metody wołana
jest funkcja do której przekazywane są parametry prosto z wywołania Recommender(parameter=...)
setMethod("Recommender", signature(data = "ratingMatrix"),
function(data, method, parameter = NULL) {
recom <- recommenderRegistry$get_entry(
method = method, dataType = class(data))
if(is.null(recom)) stop(paste("Recommender method", method,
"not implemented for data type", class(data),"."))
## this is expected to return a valid Recommender object
recom$fun(data = data, parameter = parameter)
})
.REAL_SVD_param <- list(
categories = 50,
method="Cosine",
normalize = "center",
normalize_sim_matrix = FALSE,
alpha = 0.5,
treat_na = "median",
minRating = NA
)
recommenderRegistry$set_entry(
method="SVD", dataType = "realRatingMatrix", fun=REAL_SVD,
description="Recommender based on SVD approximation (real data).",
parameters = .REAL_SVD_param)
.REAL_UBCF_param <- list(
method = "cosine",
nn = 25,
sample = FALSE,
## FIXME: implement weighted = TRUE,
normalize="center",
minRating = NA
)
recommenderRegistry$set_entry(
method="UBCF", dataType = "realRatingMatrix", fun=REAL_UBCF,
description="Recommender based on user-based collaborative filtering (real data).",
parameters=.REAL_UBCF_param)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment