Description Usage Arguments Details Examples
Find the row numbers corresponding the largest values in a particular column of a matrix
1 |
mat |
(Sparse matrix of class 'dgCmatrix' or a integer/numeric matrix or 'big.matrix') Rating matrix. |
col |
(positive integer) Column number in which top rows are to be selected. |
k |
(positive integer) Number of row numbers to be recommended. This might not be strictly adhered to, see Details. |
ignore |
(integer vector) Row numbers to be ignored. |
To find top-n recommendations of a ratings matrix given an item (or a user). Although k recommendations are expected to be returned, the function might sometimes return more or less than k recommendations.
Less: This happens when it is not possible to recommend k elements. For example, k is larger than the number of elements.
More:
This happens when a few elements have same rating. The function returns the
index corresponding to all the elements which have the same rating. If
ratings were 3,2,2,2,3
:
k = 3: returns
1, 5, 2, 3, 4
k = 2: returns 1, 5
k = 1: returns
1, 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
temp <- slim(mat = ft_implicit # input sparse ratings matrix
, alpha = 0.5 # 0 for ridge, 1 for lasso
#, lambda # suggested not to set lambda
#, nlambda # using default nlambda = 100
, nonNegCoeff = TRUE # better accuracy, lower interpretability
, directory = td # dir where output matrices are stored
, coeffMat = TRUE # helpful in 'predict'ing later
, returnMat = TRUE # return matrices in memory
, computeRMSE = TRUE # RMSE over rated items
, nproc = 2L # number of concurrent processes
, progress = TRUE # show a progressbar
, check = TRUE # do basic checks on input params
, cleanup = FALSE # keep output matrices on disk
)
str(temp)
# output ratings matrix would be comparatively denser
predMat <- temp[["ratingMat"]] != 0
sum(predMat)/((dim(predMat)[1])*(dim(predMat)[2]))
# recommend top 5 items for a user 10
top_cols(temp[["ratingMat"]]
, row = 10
, k = 5
)
# if you intend to avoid recommending 10, 215 and 3
top_cols(temp[["ratingMat"]]
, row = 10
, k = 5
, ignore = c(10, 215, 3)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.