Title: | Environment for Evaluating Recommender Systems |
---|---|
Description: | Processes standard recommendation datasets (e.g., a user-item rating matrix) as input and generates rating predictions and lists of recommended items. Standard algorithm implementations which are included in this package are the following: Global/Item/User-Average baselines, Weighted Slope One, Item-Based KNN, User-Based KNN, FunkSVD, BPR and weighted ALS. They can be assessed according to the standard offline evaluation methodology (Shani, et al. (2011) <doi:10.1007/978-0-387-85820-3_8>) for recommender systems using measures such as MAE, RMSE, Precision, Recall, F1, AUC, NDCG, RankScore and coverage measures. The package (Coba, et al.(2017) <doi: 10.1007/978-3-319-60042-0_36>) is intended for rapid prototyping of recommendation algorithms and education purposes. |
Authors: | Ludovik Çoba [aut, cre, cph], Markus Zanker [ctb], Panagiotis Symeonidis [ctb] |
Maintainer: | Ludovik Çoba <[email protected]> |
License: | GPL-3 |
Version: | 0.9.7.2 |
Built: | 2024-11-07 05:13:19 UTC |
Source: | https://github.com/ludovikcoba/rrecsys |
Defines a structure for a dataset that distinguishes between binary and non-binary feedback datasets.
binary
:class "logical"
, determines if the item dataset contains binary (i.e. 1/0) or non-binary ratings.
minimum
:class "numeric"
, defines the minimal value present in the dataset.
maximum
:class "numeric"
, defines the maximal value present in the dataset.
intScale
:object of class "logical"
, if TRUE the range of ratings in the dataset contains as well half star values.
signature(object = "_ds")
signature(object = "_ds"): returns the sparsity of the dataset.
signature(object = "_ds"): summary of the characteristics of the dataset.
Container for the model learned using any average(global, user or item) based model.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
average
:average calculated either globally, on user or item, class "matrix"
.
show
signature(object = "algAverageClass")
Container for the model learned using any Bayesian Personalized Ranking based model.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
factors
:user(U) and items(V) factors, class "list"
.
parameters
:the parameters(such as number of factors k
, learning rate lambda
, user regularization term regU
, positive rated item regularization term regI
, negative rated item regularization term regJ
and the Boolean updateJ
to decide whatever negative updates are required) used in the model, class "list"
.
show
signature(object = "BPRclass")
This method visualizes data characteristics on a two dimensional graph, where "x" axes shows either items ordered by descending popularity, or users based on the number of ratings they have submitted. Moreover the "y" axes shows the number of ratings.
dataChart(data, x = "items", y = "num_of_ratings")
dataChart(data, x = "items", y = "num_of_ratings")
data |
the dataset, class |
x |
class |
y |
class |
Plot results.
See Also as _ds-class
.
data(mlLatest100k) a <- defineData(mlLatest100k) dataChart(a, x = "items", y = "num_of_ratings")
data(mlLatest100k) a <- defineData(mlLatest100k) dataChart(a, x = "items", y = "num_of_ratings")
Container for a dense dataset that distinguishes between binary and non-binary feedback datasets. Extends _ds
.
data
:the dataset, class "matrix"
.
binary
:class "logical"
, determines if the item dataset contains binary (i.e. 1/0) or non-binary ratings.
minimum
:class "numeric"
, defines the minimal value present in the dataset.
maximum
:class "numeric"
, defines the maximal value present in the dataset.
intScale
:object of class "logical"
, if TRUE the range of ratings in the dataset contains as well half star values.
signature(object = "dataSet"): number of rows of the dataset.
signature(object = "dataSet"): number of columns of the dataset.
signature(object = "dataSet"): returns the dimensions of the dataset.
signature(object = "dataSet"): returns the number of ratings on each row.
signature(object = "dataSet"): returns the number of ratings on each column.
signature(object = "dataSet"): returns the total number of ratings.
signature(x = "dataSet", i = "ANY", j = "ANY", drop = "ANY")): returns a subset of the dataset.
signature(from = "dataSet", to = "matrix")
signature(object = "dataSet"): returns the average rating on each row.
signature(object = "dataSet"): returns the average rating on each column.
x <- matrix(sample(c(0:5), size = 100, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) x <- defineData(x) colRatings(x) rowRatings(x) numRatings(x) sparsity(x) a <- x[1:10,2:3]
x <- matrix(sample(c(0:5), size = 100, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) x <- defineData(x) colRatings(x) rowRatings(x) numRatings(x) sparsity(x) a <- x[1:10,2:3]
Defines your dataset, if either it is implicit or explicit.
data |
the dataset, class |
sparseMatrix |
class |
binary |
class |
minimum |
class |
maximum |
class |
intScale |
object of class |
positiveThreshold |
class |
Returns an object of class "dataSet"
.
See Also as dataSet-class
.
data(mlLatest100k) a <- defineData(mlLatest100k) b <- defineData(mlLatest100k,binary = TRUE ,positiveThreshold = 3)
data(mlLatest100k) a <- defineData(mlLatest100k) b <- defineData(mlLatest100k,binary = TRUE ,positiveThreshold = 3)
Metric for information retrival where positions are discounted logarithmically.
eval_nDCG(recommendedIDX, testSetIDX)
eval_nDCG(recommendedIDX, testSetIDX)
recommendedIDX |
indices of the recommended items. Object of class |
testSetIDX |
indices of the items in the test set. Object of class |
nDCG is computed as the ratio between Discounted Cumulative Gain(DCG) and idealized Discounted Cumulative Gain(IDCG):
Asela Gunawardana, Guy Shani, Evaluating Recommender Systems.
This method visualizes data characteristics on a two dimensional graph, where "x" axes shows either items ordered by descending popularity, or users based on the number of ratings they have submitted. Moreover the "y" axes shows the number of ratings.
evalChart(res, x = "items", y = "TP", x_label, y_label, y_lim)
evalChart(res, x = "items", y = "TP", x_label, y_label, y_lim)
res |
evaluation results, class |
x |
class |
y |
class |
x_label |
class |
y_label |
class |
y_lim |
class |
Plot results.
See Also as evalRecResults-class
.
Creates the dataset split for evaluation where ratings of each user are uniformly distributed over k random folds. The function returns the list of items that are assigned to each fold, such that algorithms can be compared on the same train/test splits.
evalModel(data, folds)
evalModel(data, folds)
data |
dataset, of class |
folds |
The number of folds to use in the k-fold cross validation, of class |
An object of class evalModel-class
.
evalModel-class
, evalRec
, _ds
.
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) d <- defineData(x) my_2_folds <- evalModel(d, 2) #output class evalModel. my_2_folds # 2 - fold cross validation model on the dataset with 20 users and 10 items. my_2_folds@data #the dataset. my_2_folds@folds #the number of folds in the model. my_2_folds@fold_indices #the index of each item in the fold.
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) d <- defineData(x) my_2_folds <- evalModel(d, 2) #output class evalModel. my_2_folds # 2 - fold cross validation model on the dataset with 20 users and 10 items. my_2_folds@data #the dataset. my_2_folds@folds #the number of folds in the model. my_2_folds@fold_indices #the index of each item in the fold.
Class that contains the data and a distribution of the uniform distribution of ratings onto k-folds.
The fold_indices list contains the indexes to access the dataset on one dimension. A matrix can be addressed as a one dimensional array, considered as an extension of each column after another. E.g: in a matrix M with 10 rows and 20 columns, M[10] == M[10, 1]; M[12] == M[2,2].
data
:the dataset, class "matrix"
.
folds
:number of k - folds, class "numeric"
.
fold_indices
:a list with k slots, each slot represents a fold and contains the index of items assigned to that fold, class "list"
.
fold_indices_x_user
:a list that specifies specifically for each user the distribution of the items in the folds, class "list"
.
show
signature(object = "evalModel")
Evaluates the prediction task of an algorithm with a given configuration and based on the given evaluation model. RMSE and MAE are both calculated individually for each user and then averaged over all users (in this case they will be referred as RMSE and MAE) as well as determined as the average error over all predictions (in this case they are named globalRMSE and globalMAE).
evalPred(model, ...) ## S4 method for signature 'evalModel' evalPred(model, alg, ... )
evalPred(model, ...) ## S4 method for signature 'evalModel' evalPred(model, alg, ... )
model |
Object of type |
alg |
The algorithm to be used in the evaluation. Of type |
... |
other attributes specific to the algorithm to be deployed. Refer to |
Returns a data frame with the RMSE
, MAE
, globalRMSE
and globalMAE
for each of the k-folds defined in the evaluation model and an average over all folds.
F. Ricci, L. Rokach, B. Shapira, and P. B. Kantor, editors. Recommender Systems Handbook. Springer, 2011. ISBN 978-0-387-85819-7. URL http://www.springerlink.com/content/978-0-387-85819-7.
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 2) SVDEvaluation <- evalPred(e, "FunkSVD", k = 4) SVDEvaluation IBEvaluation <- evalPred(e, "IBKNN", simFunct = "cos", neigh = 5, coRatedThreshold = 2) IBEvaluation
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 2) SVDEvaluation <- evalPred(e, "FunkSVD", k = 4) SVDEvaluation IBEvaluation <- evalPred(e, "IBKNN", simFunct = "cos", neigh = 5, coRatedThreshold = 2) IBEvaluation
Evaluates the recommendation task of an algorithm with a given configuration and based on the given evaluation model.
model |
Object of type |
alg |
The algorithm to be used in the evaluation. Of class |
topN |
Object of class |
topNGen |
Object of class |
positiveThreshold |
Object of class |
alpha |
Object of class |
... |
other attributes specific to the algorithm to be deployed. Refer to |
Returns an object of class evalRecResults
with the precision
, recall
, F1
, nDCG
, RankScore
, true positives(TP)
, false positives(FP)
, true negatives(TN)
, false negatives(FN)
for each of the k-folds defined in the evaluation model and the overall average.
F. Ricci, L. Rokach, B. Shapira, and P. B. Kantor, editors. Recommender Systems Handbook. Springer, 2011. ISBN 978-0-387-85819-7. URL http://www.springerlink.com/content/978-0-387-85819-7.
evalModel-class
, rrecsys
, evalRecResults-class
.
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 2) SVDEvaluation <- evalRec(e, "FunkSVD", positiveThreshold = 4, k = 4) SVDEvaluation
x <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 2) SVDEvaluation <- evalRec(e, "FunkSVD", positiveThreshold = 4, k = 4) SVDEvaluation
Defines a structure for the results obtained by evaluating an algorithm
data
:class "_ds"
, the dataset.
alg
:class "character"
, the name of the used algorithm.
topN
:class "numeric"
, the number N of Top-N items recommended to each user.
topNGen
:class "character"
, the name of the recommendation algorithm.
positiveThreshold
:class "numeric"
, indicating the threshold of the ratings to be considered a good. This attribute is not used when evaluating implicit feedback.
alpha
:class numeric
, is the half-life parameter for the rankscore metric.
parameters
:class "list"
, parameters used in the configuration of the algorithm.
TP
:class "numeric"
, True Positives count on each fold.
FP
:class "numeric"
, False Positives count on each fold.
TN
:class "numeric"
, True Negatives count on each fold.
FN
:class "numeric"
, False Negatives count on each fold.
precision
:class "numeric"
, precision measured on each fold.
recall
:class "numeric"
, recall measured on each fold.
F1
:class "numeric"
, F1 measured on each fold.
nDCG
:class "numeric"
, nDCG measured on each fold.
rankscore
:class "numeric"
, rankscore measured on each fold.
item_coverage
:class "numeric"
, item coverage.
user_coverage
:class "numeric"
, user coverage.
ex.time
:class "numeric"
, the execution time.
TP_count
:class "numeric"
, True positives count on each item.
rec_counts
:class "numeric"
, counts how many times an item was recommended.
rec_popularity
:class "numeric"
, popularity of recommendations.
show
signature(object = "evalRecResults")
results
signature(object = "evalRecResults", metrics = "character"): returns a subset of the results based on the required metric.
Computes the Area Under the ROC curve for a recommendation task of an algorithm with its given configuration and based on the given evaluation model.
getAUC(model, ...) ## S4 method for signature 'evalModel' getAUC(model, alg, ... )
getAUC(model, ...) ## S4 method for signature 'evalModel' getAUC(model, alg, ... )
model |
Object of type |
alg |
The algorithm to be used in the evaluation. Of class |
... |
other attributes specific to the algorithm to be deployed. Refer to |
Returns a data frame with the AUC
for each of the k-folds defined in the evaluation model and the overall average.
T. Fawcett, “ROC Graphs: Notes and Practical Considerations for Data Mining Researchers ROC Graphs : Notes and Practical Considerations for Data Mining Researchers,”, HP Inven., p. 27, 2003.
x <- matrix(sample(c(NA, 1:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 5) auc <- getAUC(e, "FunkSVD", k = 4) auc
x <- matrix(sample(c(NA, 1:5), size = 200, replace = TRUE, prob = c(.6,.8,.8,.8,.8,.8)), nrow = 20, byrow = TRUE) x <- defineData(x) e <- evalModel(x, 5) auc <- getAUC(e, "FunkSVD", k = 4) auc
Histogram of the ratings grouped by value.
histogram(data, title = "", x = "Rating values", y = "# of ratings")
histogram(data, title = "", x = "Rating values", y = "# of ratings")
data |
class |
title |
class |
x |
class |
y |
class |
Container for the model learned using any k-nearest neighbor item-based collaborative filtering algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
sim
:The item - item similarity matrix, class "matrix"
.
sim_index_kNN
:The index of the k nearest neighbors for each item, class "matrix"
.
parameters
:the parameters used in the model, class "list"
.
show
signature(object = "IBclass")
MovieLens data sets were collected by the GroupLens Research Project at the University of Minnesota.
This data set consists of:
100,000 ratings (1-5) from 943 users on 1682 movies.
Each user has rated at least 20 movies.
The data was collected through the MovieLens web site (movielens.umn.edu) during the seven-month period from September 19th, 1997 through April 22nd, 1998. This data has been cleaned up - users who had less than 20 ratings or did not have complete demographic information were removed from this data set. Detailed descriptions of the data file can be found at the end of this file.
http://grouplens.org/datasets/movielens/100k/
This dataset (ml-latest-small) is a 5-star rating dataset from [MovieLens](http://movielens.org), a movie recommendation service of the GroupLens research group at the University of Minnesota. It contains 100234 ratings across 8927 movies. The data was created by 718 users between March 26, 1996 and August 05, 2015. This dataset was generated on August 06, 2015. Users were selected at random for inclusion. All selected users had rated at least 20 movies. The data is edited and structured as a matrix and distributed as such. Below the usage license of this redistributed data is cited below.
data("mlLatest100k")
data("mlLatest100k")
The format is: num [1:718, 1:8915] 5 3 0 0 4 4 0 3 0 0 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:718] "1" "2" "3" "4" ... ..$ : chr [1:8915] "Toy Story (1995)" "Jumanji (1995)" "GoldenEye (1995)" "Twelve Monkeys (a.k.a. 12 Monkeys) (1995)" ...
http://grouplens.org/datasets/movielens/latest/
Container for the model learned by an unpersonalized popularity-based algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
indices
:the indices of items ordered by popularity, class "integer"
.
parameters
:the parameters used in the model, class "list"
.
show
signature(object = "PPLclass")
Generate predictions on any of the previously trained models.
model |
A previously trained model, see |
Round |
object of class |
All unrated items are predicted and the entire matrix is returned with the new ratings.
data("mlLatest100k") smallMl <- mlLatest100k[1:50, 1:100] exExpl <- defineData(smallMl) model1exp <- rrecsys(exExpl, alg = "funk", k = 10, learningRate = 0.01, regCoef = 0.001) pre1 <- predict(model1exp, Round = TRUE)
data("mlLatest100k") smallMl <- mlLatest100k[1:50, 1:100] exExpl <- defineData(smallMl) model1exp <- rrecsys(exExpl, alg = "funk", k = 10, learningRate = 0.01, regCoef = 0.001) pre1 <- predict(model1exp, Round = TRUE)
Rank Score extends the recall metric to take the positions of correct items in a ranked list into account.
rankScore(recommendedIDX, testSetIDX, alpha)
rankScore(recommendedIDX, testSetIDX, alpha)
recommendedIDX |
indices of the recommended items. Object of class |
testSetIDX |
indices of the items in the test set. Object of class |
alpha |
is the ranking half life. Object of class |
Rank Score is defined as the ratio of the Rank Score of the correct items to best theoretical Rank Score achievable for the user:
This method generates top-n recommendations based on a model that has been trained before. Two main methods: recommendHPR, recommendMF. The first method recommends the highest predicted ratings on a user. Instead recommendMF (currently available only for IBKNN and UBKNN), recommends the most frequent item in the user's neighborhood.
recommendHPR(model, topN = 3) recommendMF(model, topN = 3, pt)
recommendHPR(model, topN = 3) recommendMF(model, topN = 3, pt)
model |
the trained model of any algorithm. |
topN |
number of items to be recommended per user, class |
pt |
positive threshold, class |
Returns a list with suggested items for each user.
myratings <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) myratings <- defineData(myratings) r <- rrecsys(myratings, alg = "FunkSVD", k = 2) rec <- recommendHPR(r)
myratings <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) myratings <- defineData(myratings) r <- rrecsys(myratings, alg = "FunkSVD", k = 2) rec <- recommendHPR(r)
Based on the specific given algorithm a recommendation model will be trained.
rrecsys(data, alg, ...)
rrecsys(data, alg, ...)
data |
Training set of class |
alg |
A |
... |
other attributes, see details. |
Based on the value of alg the attributes will have different names and values. Possible configuration of alg
and it's meaning:
itemAverage. When alg = "itemAverage"
the average rating of an item is used to make predictions and recommendations.
userAverage. When alg = "userAverage"
the average rating of a user is used to make predictions and recommendations.
globalAverage. When alg = "globalAverage"
the overall average of all ratings is used to make predictions and recommendations.
Mostpopular. The most popular algorithm ( alg = "mostpopular"
) is the most simple algorithm for recommendations. Item will be ordered based on the number of times that they were rated. Recommendations for a particular user will be the most popular items from the data set which are not contained in the user's training set.
IBKNN. As alg = "IBKNN"
a k-nearest neighbor item-based collaborative filtering algorithm. Given two items a and b, we consider them as rating vectors and
. If the argument simFunct is set to "cos" the method computes the cosine similarity as:
If the argument simFunct is set to "adjCos" the method determines the "adjusted cosine" distance among the items as:
It extracts, based on the value of the neigh attribute, the number of closest neighbors for each item.
UBKNN. As alg = "UBKNN"
a k-nearest neighbor user-based collaborative filtering algorithm. Given two users u and u, we consider them as rating vectors and
. If the argument simFunct is set to "cos" the method computes the cosine similarity as:
If the argument simFunct is set to "Pearson" the method determines the "Pearson correlation" among the users as:
It extracts, based on the value of the neigh attribute, the number of closest neighbors for each item.
FunkSVD. It implements alg = "funkSVD"
a stochastic gradient descent optimization technique. The U(user) and V(item) factor matrices are initialized at small values and cropped to k features. Each feature is trained until convergence (the convergence value has to be specified by the user, by configuring the steps argument). On each loop the algorithm predicts and calculates the error as:
The factors are updated:
. The attribute learningRate represents the learning rate, while regCoef corresponds to the weight of the regularization term. If the argument biases is TRUE, the biases will be computed to update the features and generate predictions.
wALS. The alg = "wALS"
weighted Alternated Least squares method. For a given non-negative weight matrix W the algorithm will perform updates on the item V and user U feature matrix as follows:
Initially the V matrix is initialized with Gaussian random numbers with mean zero and small standard deviation. Than U and V are updated until convergence
. The attribute scheme
must specify the scheme(uni, uo, io, co
) to use.
BPR. In this implementation of BPR (alg = "BPR"
) is applied a stochastic gradient descent approach that randomly choose triples from and trains the model
. In this implementation the BPR optimization criterion is applied on matrix factorization. If
, where U and V are the usual feature matrix cropped to k features, the parameter vector of the model is
. The Boolean
randomInit
parameter determines whatever the feature matrix are initialized to a random value or at a static 0.1 value. The algorithm will use three regularization terms, RegU
for the user features U, RegI
for positive updates and RegJ
for negative updates of the item features V, lambda
is the learning rate, autoConvergence
is a toggle to the auto convergence validation, convergence
upper limit to the convergence, and updateJ
if true updates negative item features.
SlopeOne The Weighted Slope One (alg = "slopeOne"
) performs prediction for a missing rating for user
on item
as the following average:
The average deviation rating $dev_ij$ between co-rated items is defined by:
Where $c_ij$ is the number of co-ratings between items $i$ and $j$ and $r_ui$ is an existing rating for user $u$ on item $i$. The Weighted Slope One takes into account both, information from users who rated the same item and the number of observed ratings.
To view a full list of available algorithms and their default configuration execute rrecsysRegistry
.
Depending on the alg
value it will be either an object of type SVDclass
or IBclass
.
D. Jannach, M. Zanker, A. Felfernig, and G. Friedrich. Recommender Systems: An Introduction. Cambridge University Press, New York, NY, USA, 1st edition, 2010. ISBN 978-0-521-49336-9.
Funk, S., 2006, Netflix Update: Try This at Home, http://sifter.org/~simon/journal/20061211.html.
Y. Koren, R. Bell, and C. Volinsky. Matrix Factorization Techniques for Recommender Systems. Computer, 42(8):30–37, Aug. 2009. ISSN 0018-9162. doi: 10.1109/MC.2009.263. http://dx.doi.org/10.1109/MC.2009.263.
R. Pan, Y. Zhou, B. Cao, N. Liu, R. Lukose, M. Scholz, and Q. Yang. One-Class Collaborative Filtering. In Data Mining, 2008. ICDM ’08. Eighth IEEE International Conference on, pages 502–511, Dec 2008. doi: 10.1109/ICDM.2008.16.
S. Rendle, C. Freudenthaler, Z. Gantner, and L. Schmidt-Thieme. BPR: Bayesian Personalized Ranking from Implicit Feedback. In Proceedings of the Twenty-Fifth Conference on Uncertainty in Artificial Intelligence, UAI ’09, pages 452–461, Arlington, Virginia, United States, 2009. AUAI Press. ISBN 978-0-9749039-5-8. URL http://dl.acm.org/citation.cfm?id=1795114.1795167.
myratings <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) myratings <- defineData(myratings) r <- rrecsys(myratings, alg = "funkSVD", k = 2) r2 <- rrecsys(myratings, alg = "IBKNN", simFunct = "cos", neigh = 5) rrecsysRegistry$get_entries()
myratings <- matrix(sample(c(0:5), size = 200, replace = TRUE, prob = c(.6,.08,.08,.08,.08,.08)), nrow = 20, byrow = TRUE) myratings <- defineData(myratings) r <- rrecsys(myratings, alg = "funkSVD", k = 2) r2 <- rrecsys(myratings, alg = "IBKNN", simFunct = "cos", neigh = 5) rrecsysRegistry$get_entries()
Define stopping criteria for functions that need a convergence check.
setStoppingCriteria(autoConverge = FALSE, deltaErrorThreshold = 1e-05, nrLoops = NULL, minNrLoops = 10) showStoppingCriteria() showDeltaError()
setStoppingCriteria(autoConverge = FALSE, deltaErrorThreshold = 1e-05, nrLoops = NULL, minNrLoops = 10) showStoppingCriteria() showDeltaError()
autoConverge |
class |
deltaErrorThreshold |
class |
nrLoops |
class |
minNrLoops |
class |
If autoConvergence = TRUE
tells the package to monitor the difference of global RMSE on two consecutive iterations, and to see if it drops below a threshold value. Whenever it drops under the specified value the iteration is considered converged. If FALSE
the limit of iterations is delimited by nrLoops
showStoppingCriteria
Print on console the current configuration of the convergence algorithm.
showDeltaError
Report the delta error on each iteration of the algorithm that requires an auto-convergence algorithm.
M. D. Ekstrand, M. Ludwig, J. Kolb, and J. T. Riedl, “LensKit: a modular recommender framework,”, Proc. fifth ACM Conf. Recomm. Syst. - RecSys ’11, p. 349, 2011.
See Also as rrecsys
, SVDclass
, wALSclass
, BPRclass
.
setStoppingCriteria(autoConverge = TRUE) setStoppingCriteria(nrLoops = 30)
setStoppingCriteria(autoConverge = TRUE) setStoppingCriteria(nrLoops = 30)
Container for the model learned using Slope One algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
devcard
:Deviation and Cardinality between columns, class "list"
.
show
signature(object = "SVDclass")
Container for a sparse dataset that distinguishes between binary and non-binary feedback datasets. Data are stored as tuples (user, item, rating). Extends _ds
.
data
:the dataset, class "matrix"
.
binary
:class "logical"
, determines if the item dataset contains binary (i.e. 1/0) or non-binary ratings.
minimum
:class "numeric"
, defines the minimal value present in the dataset.
maximum
:class "numeric"
, defines the maximal value present in the dataset.
intScale
:object of class "logical"
, if TRUE the range of ratings in the dataset contains as well half star values.
userID
:class "numeric"
, array containing all user IDs.
itemID
:class "numeric"
, array containing all item IDs.
userPointers
:class "list"
, pointer to all users position in the dataset.
itemPointers
:class "list"
, pointer to all items position in the dataset.
signature(object = "sparseDataSet"): number of rows of the dataset.
signature(object = "sparseDataSet"): number of columns of the dataset.
signature(object = "sparseDataSet"): returns the dimensions of the dataset.
signature(object = "sparseDataSet"): returns the number of ratings on each row.
signature(object = "sparseDataSet"): returns the number of ratings on each column.
signature(object = "sparseDataSet"): returns the total number of ratings.
signature(x = "sparseDataSet", i = "ANY", j = "ANY", drop = "ANY")): returns a subset of the dataset.
signature(from = "sparseDataSet", to = "matrix")
signature(object = "sparseDataSet"): returns the average rating on each row.
signature(object = "sparseDataSet"): returns the average rating on each column.
Container for the model learned using any matrix factorization algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
factors
:user(U) and items(V) factors, class "list"
.
parameters
:the parameters used in the model, class "list"
.
baselines
:Global, user and item baselines, class "list"
.
show
signature(object = "SVDclass")
Container for the model learned using any k-nearest neighbor item-based collaborative filtering algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
sim
:The item - item similarity matrix, class "matrix"
.
sim_index_kNN
:The index of the k nearest neighbors for each item, class "matrix"
.
parameters
:the parameters used in the model, class "list"
.
show
signature(object = "UBclass")
Container for the model learned using any weighted Alternating Least Squares based algorithm.
alg
:The algorithm denominator, of class "character"
.
data
:the dataset used for training the model, class "matrix"
.
factors
:user(U) and items(V) factors, class "list"
.
weightScheme
:The weighting scheme used in updating the factors, class "matrix"
.
parameters
:the parameters(such as number of factors k
, learning rate lambda
, number of iterations until convergence
and the weighting scheme) used in the model, class "list"
.
show
signature(object = "wALSclass")