Make predictions from a rarefit object and a rarefit.cv object
Make predictions from a rarefit object and a rarefit.cv object
The function makes predictions using a rarefit object at optimal (lambda, alpha) chosen by rarefit.cv.
rarefit.predict(fitObj, cvObj, newx)
Arguments
fitObj: Output of rarefit.
cvObj: Output of rarefit.cv.
newx: Matrix of new values for x at which predictions are made.
Returns
Returns a sequence of predictions.
Examples
## 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 setourfit <- 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 validationourfit.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 setpred <- rarefit.predict(ourfit, ourfit.cv, data.dtm[-ts,])pred.error <- mean((pred - data.rating[-ts])^2)## End(Not run)