rarefit.predict {rare} | R Documentation |
Make predictions from a rarefit object and a rarefit.cv object
Description
The function makes predictions using a rarefit
object at optimal
(lambda
, alpha
) chosen by rarefit.cv
.
Usage
rarefit.predict(fitObj, cvObj, newx)
Arguments
fitObj |
Output of |
cvObj |
Output of |
newx |
Matrix of new values for x at which predictions are made. |
Value
Returns a sequence of predictions.
See Also
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 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)
[Package rare version 0.1.1 Index]