rarefit.predict {rare} | R Documentation |
The function makes predictions using a rarefit
object at optimal
(lambda
, alpha
) chosen by rarefit.cv
.
rarefit.predict(fitObj, cvObj, newx)
fitObj |
Output of |
cvObj |
Output of |
newx |
Matrix of new values for x at which predictions are made. |
Returns a sequence of predictions.
## Not run: # See vignette for more details. set.seed(100) ts <- sample(1:length(data.rating), 400) # Train set indices # Fit the model on train set ourfit <- rarefit(y = data.rating[ts], X = data.dtm[ts, ], hc = data.hc, lam.min.ratio = 1e-6, nlam = 20, nalpha = 10, rho = 0.01, eps1 = 1e-5, eps2 = 1e-5, maxite = 1e4) # Cross validation ourfit.cv <- rarefit.cv(ourfit, y = data.rating[ts], X = data.dtm[ts, ], rho = 0.01, eps1 = 1e-5, eps2 = 1e-5, maxite = 1e4) # Prediction on test set pred <- rarefit.predict(ourfit, ourfit.cv, data.dtm[-ts, ]) pred.error <- mean((pred - data.rating[-ts])^2) ## End(Not run)