#################
### EXAMPLE 1 ###
#################
## Perform 2-fold cross validation using the default model arguments
## and the log-likelihood as loss function
# Load data
data(ecoli)
ecoli <- ecoli[,-c(1,9)]
# Learn DAG
dag <- LearningHC(ecoli)
# Run cross validation
cv = motbf.cv(data = ecoli, dag, k = 2, loss = 'logl')
cv
# \donttest{
#################
### EXAMPLE 2 ###
#################
## Choose different arguments to fit the model parameters
fit.args = list(numIntervals = 3, POTENTIAL_TYPE = 'MOP', maxParam = 4)
# Run cross validation using the classification accuracy as loss function
cv = motbf.cv(data = ecoli, dag, k = 2, loss = 'pred', target = 'lip',
fit.args = fit.args)
cv
summary(cv)
#################
### EXAMPLE 3 ###
#################
## Specify a loss matrix to increase the penalty of classification errors
lossFunctionMatrix = matrix(c(c(1,2), c(3, 1)),nrow = 2, ncol = 2, byrow = TRUE)
# Run cross validation using the weighted classification accuracy as loss function
cv = motbf.cv(data = ecoli, dag, k = 2, loss = 'pred', target = 'lip',
loss.args = list(loss.matrix = lossFunctionMatrix))
cv
summary(cv)
#################
### EXAMPLE 4 ###
#################
# Run cross validation using the root mean squared error as loss function
cv = motbf.cv(data = ecoli, dag, k = 2, loss = 'pred', target = 'mcg')
cv
# }
Run the code above in your browser using DataLab