predict.unsupv.varpro.Rd
Obtain predicted values on test data for unsupervised forests.
predict.unsupv(object, newdata, ...)
Applies to unsupervised VarPro objects built using autoencoder
(method
="auto"). The unsupervised object contains a
multivariate random forest which is used to predict on test data.
Returns a matrix containing predicted values where each column is predicted value for a feature (hot-encoding is applied) and with attributes:
mse
: standardized mean-squared error averaged across
feature.
mse.all
: standardized mean-squared error for each
feature.
# \donttest{
## ------------------------------------------------------------
##
## boston housing
## obtain predicted values for the training data
##
## ------------------------------------------------------------
## unsupervised varpro on boston housing
data(BostonHousing, package = "mlbench")
o <- unsupv(data=BostonHousing)
## predicted values for the training features
print(head(predict(o)))
## ------------------------------------------------------------
##
## mtcars
## obtain predicted values for test data
## also illustrates hot-encoding working on test data
##
## ------------------------------------------------------------
## mtcars with some factors
d <- data.frame(mpg=mtcars$mpg,lapply(mtcars[, c("cyl", "vs", "carb")], as.factor))
## training
o <- unsupv(d[1:20,])
## predicted values on test data
print(predict(o, d[-(1:20),]))
## predicted values on bad test data with strange factor values
dbad <- d[-(1:20),]
dbad$carb <- as.character(dbad$carb)
dbad$carb <- sample(LETTERS, size = nrow(dbad))
print(predict(o, dbad))
# }