Predictions function, to apply a trained model on datas

automl_predict(model, X, layoutputnum)

Arguments

model

model trained previously with automl_train or automl_train_manual

X

inputs matrix or data.frame (containing numerical values only)

layoutputnum

which layer number to output especially for auto encoding (default 0: no particular layer, the last one)

Examples

##REGRESSION (predict Sepal.Length given other parameters) data(iris) xmat <- as.matrix(cbind(iris[,2:4], as.numeric(iris$Species))) ymat <- iris[,1] amlmodel <- automl_train_manual(Xref = xmat, Yref = ymat, hpar = list(modexec = 'trainwpso', verbose = FALSE)) res <- cbind(ymat, automl_predict(model = amlmodel, X = xmat)) colnames(res) <- c('actual', 'predict') head(res)
#> actual predict #> [1,] 5.1 5.113573 #> [2,] 4.9 4.562844 #> [3,] 4.7 4.715187 #> [4,] 4.6 4.740938 #> [5,] 5.0 5.223718 #> [6,] 5.4 5.629219
# if (FALSE) { ##CLASSIFICATION (predict Species given other Iris parameters) data(iris) xmat = iris[,1:4] lab2pred <- levels(iris$Species) lghlab <- length(lab2pred) iris$Species <- as.numeric(iris$Species) ymat <- matrix(seq(from = 1, to = lghlab, by = 1), nrow(xmat), lghlab, byrow = TRUE) ymat <- (ymat == as.numeric(iris$Species)) + 0 amlmodel <- automl_train_manual(Xref = xmat, Yref = ymat, hpar = list(modexec = 'trainwpso', verbose = FALSE)) res <- cbind(ymat, round(automl_predict(model = amlmodel, X = xmat))) colnames(res) <- c(paste('act',lab2pred, sep = '_'), paste('pred',lab2pred, sep = '_')) head(res) }