dcaiman.train: Train D-CAIMAN model

Description Usage Arguments Examples

View source: R/dcaiman.train.R View source: R/caiman2-internal.R

Description

Function to train a D-CAIMAN model.

Usage

1
dcaiman.train(y, xtrain, xvalidation, grid)

Arguments

y

Label. Must be a factor.

xtrain

train dataset

xvalidation

validation dataset define an \alpha (see details) with cross-validation

grid

values of \alpha

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 (y, xtrain, xvalidation, grid) 
{
    classes = levels(y)
    df = xtrain %>% as.data.frame()
    df$y = y
    a = grid
    xtx = .genXtX(df, classes)
    centroidx = .genCentroide(df, classes)
    k = .genEspace(df, classes) %>% as.data.frame()
    k$y = y
    xtxk = .genXtX(k, classes)
    centroidk = .genCentroide(k, classes)
    valx = .genhiddenSpace(levels(y), x = xvalidation, xxt = xtx, 
        m = centroidx)
    valy = .genhiddenSpace(levels(y), x = valx, xxt = xtk, m = centroidk)
    erro = numeric(length(a))
    for (i in seq_along(a)) {
        valfinal = a[i] * valx + (1 - a[i]) * valy
        erro[i] = mean(validacao$V58 != genmin(levels(y), valfinal))
    }
    afinal = a[which.min(erro)]
    return(list(xtx = xtx, xtk = xtk, cx = centroidx, ck = centroidk, 
        a = afinal, classes = classes))
  }

pedroaraujo9/caiman2 documentation built on Dec. 2, 2018, 12:19 p.m.