View source: R/predict.uvarpro.R
predict.uvarpro | R Documentation |
Obtain predicted values on test data for unsupervised forests.
## S3 method for class 'uvarpro'
predict(object, newdata, ...)
object |
Unsupervised VarPro object from a previous call to |
newdata |
Optional test data. If not provided, the training data is used. |
... |
Additional arguments passed to internal methods. |
Applies to unsupervised VarPro objects built using the autoencoder (method = "auto"
). The object contains a multivariate random forest used to generate predictions for the test data.
Returns a matrix of predicted values, where each column corresponds to a feature (with one-hot encoding applied). The result includes the following attributes:
mse
: Standardized mean squared error averaged across features.
mse.all
: Standardized mean squared error for each individual feature.
Min Lu and Hemant Ishwaran
uvarpro
## ------------------------------------------------------------
##
## boston housing
## obtain predicted values for the training data
##
## ------------------------------------------------------------
## unsupervised varpro on boston housing
data(BostonHousing, package = "mlbench")
o <- uvarpro(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 <- uvarpro(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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.