Description Usage Arguments Examples
To make predictions using ecvr results in memory
1 | cmf_krr_ecvr_pred_mem(ecvr, kernels, kernels_pred, y_exp, print_pred = TRUE, plot_pred = TRUE, ...)
|
ecvr |
|
kernels |
|
kernels_pred |
|
y_exp |
|
print_pred |
|
plot_pred |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (ecvr, kernels, kernels_pred, y_exp, print_pred = TRUE,
plot_pred = TRUE, ...)
{
ntrain <- dim(kernels_pred[[2]][[1]])[2]
npred <- dim(kernels_pred[[2]][[1]])[1]
nmodels <- ecvr$nmodels
models <- ecvr$models
permutations <- ecvr$permutations
indexes <- ecvr$indexes
mfields <- ecvr$mfields
YPred <- matrix(0, npred, nmodels)
for (imod in 1:nmodels) {
model <- models[[imod]]
permutation <- permutations[[imod]]
ind_train <- indexes[[imod]]
kernels_perm <- cmf_permute_kernels(kernels, permutation,
mfields)
kernels_pred_perm <- cmf_permute_kernels(kernels_pred,
permutation, mfields, for_pred = TRUE)
kernels_perm_ind <- cmf_extract_subkernels(kernels_perm,
ind_train, ind_train, mfields)
kernels_pred_perm_ind <- cmf_extract_subkernels(kernels_pred_perm,
1:npred, ind_train, mfields)
y_pred <- cmf_krr_pred_mem(model = model, kernels = kernels_perm_ind,
kernels_pred = kernels_pred_perm_ind, y_exp = y_exp,
print_pred = FALSE, plot_pred = FALSE, ...)
YPred[, imod] <- y_pred
}
YPredMean <- rowMeans(YPred)
YPredSD <- double(npred)
for (i in 1:npred) YPredSD[i] <- sd(YPred[i, ])
if (!is.na(y_exp[1])) {
if (print_pred) {
dif <- y_exp - YPredMean
cat("No. Prediction Experiment Difference\n")
for (ipred in 1:npred) {
cat(sprintf("%3d %.3f +- %.3f %.3f %6.3f\n",
ipred, YPredMean[ipred], YPredSD[ipred] * 2,
y_exp[ipred], dif[ipred]))
}
if (npred > 1) {
regr <- regr_param(YPredMean, y_exp)
cat(sprintf("R2pred=%g RMSEpred=%g (%g%%)\n",
regr$R2, regr$RMSE, regr$RMSE_pc))
}
flush.console()
}
if (plot_pred) {
cinf_plotxy(YPredMean, y_exp, xlab = "Predicted",
ylab = "Experiment", main = "Scatter Plot for Prediction")
abline(coef = c(0, 1))
}
}
if (plot_pred) {
cinf_plotxy(YPredMean, y_exp, xlab = "Predicted", ylab = "Experiment",
main = "Scatter Plot for Prediction")
abline(coef = c(0, 1))
}
list(YPred = YPred, YPredMean = YPredMean, YPredSD = YPredSD,
y_exp = y_exp)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.