cmf_krr_pred_mem: To meke predictions in memory

Description Usage Arguments Examples

Description

To meke predictions in memory

Usage

1
cmf_krr_pred_mem(model, kernels_pred, y_exp, print_pred = TRUE, plot_pred = TRUE, ...)

Arguments

model
kernels_pred
y_exp
print_pred
plot_pred
...

Examples

 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
##---- 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 (model, kernels_pred, y_exp, print_pred = TRUE, plot_pred = TRUE, 
    ...) 
{
    alphas_pred <- kernels_pred$alphas
    y_train <- model$y_exp
    K_pred <- cmf_calc_combined_kernels(kernels_pred, model$h, 
        model$alpha, alphas_pred)
    y_pred <- K_pred %*% model$a + model$b
    if (!is.na(y_exp[1])) {
        if (print_pred) {
            regr <- regr_param(y_pred, y_exp)
            r2ex <- regr_param_ex(y_pred, y_exp, model$y_exp)
            cat(sprintf("R2pred=%g RMSEpred=%g (%g%%) R2pred_ex=%g\n", 
                regr$R2, regr$RMSE, regr$RMSE_pc, r2ex))
            flush.console()
        }
        if (plot_pred) {
            cinf_plotxy(y_pred, y_exp, xlab = "Predicted", ylab = "Experiment", 
                main = "Scatter Plot for External Prediction")
            abline(coef = c(0, 1))
        }
    }
    y_pred
  }

conmolfields documentation built on May 2, 2019, 4:18 p.m.