tune_slim: tune_slim

Description Usage Arguments Details Value Examples

Description

Arrive at an optimal value of alpha for slim

Usage

1
2
tune_slim(mat, alphaRange = seq(0, 1, 0.1), nonNegCoeff = TRUE,
  nfold = 5L, seed, directory, nproc = 1L, progress = TRUE)

Arguments

mat

(sparse matrix of class 'dgCMatrix') Rating matrix with items along columns and users along rows.

alphaRange

(numeric vector) A vector of alpha values with 0 <= alpha <= 1. Default is values 0 to 1, with a difference of 0.1.

nonNegCoeff

(flag) Whether the regression coefficients should be non-negative. Default is TRUE.

nfold

(positive integer) Number of folds for cross-validation. Only values between(inclusive) 2 and 10 are allowed.

seed

(positive integer) Seed to be used to create folds for cross-validation. If missing, a random integer is chosen. Setting this is helpful for reproduciing the results. Default is 5.

directory

(string) A writable directory where a sub-directory is created at the run time and bigmatrix objects will be written to. The sub-directories are deleted at the end. If missing, this is set using tempdir()

nproc

(positive integer) Number of parallel processes to be used to compute coefficients for items. If the machine has k (>1) cores, the function does not employ more than k - 1 cores. This is set to 1L by default.

progress

(flag) If TRUE(default), shows a progress bar and expected time. This is set to TRUE by default.

Details

Runs nfold cross-validation to aid determining the optimal value of alpha(see slim for details). The coefficient matrix obtained from the training fold is used to predict ratings of the validation fold. The RMSE is evaluated for non-zero ratings and averaged over all the folds. Note that coefficient matrix is held in memory while computing RMSE. slim adjusts lambda while fitting an elastic-net, hence advantages in searching for optimal alpha might be limited.

Value

A dataframe with two columns: alpha and error.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require("slimrec")
data(ft_small)
## Not run: 
temp <- tune_slim(ft_small)
temp
temp <- tune_slim(ft_small, alphaRange = c(0, 0.5, 1))
temp
temp <- tune_slim(ft_small, alphaRange = c(0, 0.5, 1), nproc = 2)
temp
temp <- tune_slim(ft_small, nonNegCoeff = FALSE)
temp

## End(Not run)

talegari/slimrec documentation built on May 31, 2019, 2:51 a.m.