| cv | R Documentation |
Estimate predictive accuracy of a classifier with stratified cross
validation. It learns the models from the training subsamples by repeating
the learning procedures used to obtain x. It can keep the network
structure fixed and re-learn only the parameters, or re-learn both structure
and parameters.
cv(x, dataset, k, dag = TRUE, mean = TRUE)
x |
List of |
dataset |
The data frame on which to evaluate the classifiers. |
k |
An integer. The number of folds. |
dag |
A logical. Whether to learn structure on each training subsample. Parameters are always learned. |
mean |
A logical. Whether to return mean accuracy for each classifier or to return a k-row matrix with accuracies per fold. |
A numeric vector of same length as x, giving the predictive
accuracy of each classifier. If mean = FALSE then a matrix with k
rows and a column per each classifier in x.
data(car)
nb <- bnc('nb', 'class', car, smooth = 1)
# CV a single classifier
cv(nb, car, k = 10)
nb_manb <- bnc('nb', 'class', car, smooth = 1, manb_prior = 0.5)
cv(list(nb=nb, manb=nb_manb), car, k = 10)
# Get accuracies on each fold
cv(list(nb=nb, manb=nb_manb), car, k = 10, mean = FALSE)
ode <- bnc('tan_cl', 'class', car, smooth = 1, dag_args = list(score = 'aic'))
# keep structure fixed accross training subsamples
cv(ode, car, k = 10, dag = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.