Description Usage Arguments Examples
Making predictions with analysis
1 | cmf_pred_anal(model_fname = "ligands-model-pred.RData", kernels_pred_fname = "ligands-kernels-pred.RData", act_colnum = 2, sep = ",", act_pred_fname = "activity-pred.txt", is_train = FALSE, ...)
|
model_fname |
|
kernels_pred_fname |
|
act_colnum |
|
sep |
|
act_pred_fname |
|
is_train |
|
... |
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 67 68 69 | ##---- 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_fname = "ligands-model-pred.RData", kernels_pred_fname = "ligands-kernels-pred.RData",
act_colnum = 2, sep = ",", act_pred_fname = "activity-pred.txt",
is_train = FALSE, ...)
{
iprop <- act_colnum
load(kernels_pred_fname)
load(model_fname)
if (is_train)
kernels_pred <- kernels
alphas_pred <- kernels_pred$alphas
if (iprop > 0) {
act <- read.table(act_pred_fname, header = TRUE, sep = sep)
y_exp <- act[, iprop]
}
else {
y_exp <- NA
}
mfields <- names(model$h)
nfields <- length(mfields)
K_pred <- cmf_calc_combined_kernels(kernels_pred, model$h,
model$alpha, alphas_pred)
npred <- dim(K_pred)[1]
ntrain <- dim(K_pred)[2]
y_pred <- K_pred %*% model$a + model$b
if (iprop > 0) {
regr <- regr_param(y_pred, y_exp)
cat(sprintf("R2=%g RMSE=%g\n", regr$R2, regr$RMSE))
flush.console()
plot(y_pred, y_exp, xlab = "Predicted", ylab = "Experiment")
abline(coef = c(0, 1))
}
contrib <- array(0, c(nfields, npred, ntrain))
for (f in 1:nfields) {
fname <- mfields[f]
kernels_interp <- cmf_kernels_interpolate(kernels_pred[[fname]],
model$alpha[[fname]], alphas_pred)
for (p in 1:npred) {
for (t in 1:ntrain) {
contrib[f, p, t] <- model$h[[fname]] * model$a[t] *
kernels_interp[p, t]
}
}
}
anal <- list()
anal$contrib <- contrib
anal$fields <- mfields
anal$fld_contrib_av <- numeric(nfields)
anal$fld_contrib <- array(0, c(npred, nfields))
for (f in 1:nfields) {
anal$fld_contrib_av[f] <- sum(contrib[f, , ])/npred
for (p in 1:npred) {
anal$fld_contrib[p, f] <- sum(contrib[f, p, ])
}
}
anal$tp_contrib_av <- numeric(ntrain)
anal$tp_contrib <- array(0, c(npred, ntrain))
for (t in 1:ntrain) {
anal$tp_contrib_av[t] <- sum(contrib[, , t])/npred
for (p in 1:npred) {
anal$tp_contrib[p, t] <- sum(contrib[, p, t])
}
}
anal
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.