Based on the specific given algorithm a recommendation model will be trained.
rrecsys(data, alg, ...)
Training set of class "matrix"
. The columns correspond to items and the rows correspond to users.
A "character"
string specifying the recommender algorithm to apply on the data.
other attributes, see details.
Depending on the alg
value it will be either an object of type SVDclass
or IBclass
.
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. It determines the "adjusted cosine" distance among the items as: $$ sim(\vec{a}, \vec{b}) = \frac{\sum_{u \in U} (r_{u,a} - \overline{r_{u}}) \ast (r_{u,b} - \overline{r_{u}})}{\sqrt{(r_{u,a} - \overline{r_{u}})^2} \ast \sqrt{(r_{u,b} - \overline{r_{u}})^2}}$$ The items a and b are considered as the corresponding rating vectors \(\vec{a}\) and \(\vec{b}\). 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). On each loop the algorithm predicts \(r'_{ui}\) and calculates the error as: $$r'_{ui} = u_{u} \ast v^{T}_{i}$$ $$e_{ui} =r_{ui} - r'_{ui}$$ The factors are updated: $$v_{ik} \gets v_{ik} + lambda \ast (e_{ui} \ast u_{uk} - gamma \ast v_{ik}) $$
$$u_{uk} \gets u_{uk} + lambda \ast (e_{ui} \ast v_{ik} - gamma \ast u_{uk}) $$. The attribute lambda represents the learning rate, while gamma corresponds to the weight of the regularization term.
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:
$$
U_i = R_i \ast \widetilde{W_i} \ast V \ast (V^T \ast \widetilde{W_i} \ast V + lambda (\sum_j W_{ij}) I ) ^{-1}
$$
$$
V_j = R_j^T \ast \widetilde{W_j} \ast U \ast (V^T \ast \widetilde{W_j} \ast u + lambda (\sum_i W_{ij}) I ) ^{-1}
$$
Initialy the V matrix is initialized with Guassian 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 \(D_R\) and trains the model \(\Theta\). In this implementation the BPR optimization criterion is applied on matrix factorization. If \(R = U \times V^T\), where U and V are the usual feature matrix cropped to k features, the parameter vector of the model is \(\Theta = \langle U,V \rangle\).
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.
To receive a list of all algorithms and their default configuration a call to rrecsysRegistry
is advised.
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<U+2013>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 <U+2019>08. Eighth IEEE International Conference on, pages 502<U+2013>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 <U+2019>09, pages 452<U+2013>461, Arlington, Virginia, United States, 2009. AUAI Press. ISBN 978-0-9749039-5-8. URL http://dl.acm.org/citation.cfm?id=1795114.1795167.
# NOT RUN {
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)
r1 <- rrecsys(myratings, alg = "funkSVD", k = 3,
gamma = 0.01, lambda = 0.002)
r2 <- rrecsys(myratings, alg = "IBKNN", neigh = 5)
rrecsysRegistry$get_entries()
# }
Run the code above in your browser using DataLab