knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" )
Implements algorithms for learning discrete Bayesian network classifiers from data, as well as functions for using these classifiers for prediction, assessing their predictive performance, and inspecting and analyzing their properties.
Load a data set and learn a one-dependence estimator by maximizing Akaike's information criterion (AIC) score.
library(bnclassify) data(car) tn <- tan_cl('class', car, score = 'aic') tn plot(tn)
After learning the network's parameters, you can use it to classify data.
tn <- lp(tn, car, smooth = 0.01) p <- predict(tn, car, prob = TRUE) head(p) p <- predict(tn, car, prob = FALSE) head(p)
Estimate predictive accuracy with cross validation.
cv(tn, car, k = 10)
Or compute the log-likelihood
logLik(tn, car)
Make sure you have at least version 3.2.0 of R. You can install bnclassify
from CRAN:
install.packages('bnclassify')
Or get the current development version from Github:
# install.packages('devtools') devtools::install_github('bmihaljevic/bnclassify') # devtools::install_github('bmihaljevic/bnclassify', build_vignettes = TRUE)
Ideally, you would use the build_vignettes = TRUE
version, and thus get the vignettes, but it requires programs such as texi2dvi to be installed on your side.
See an overview of the package and examples of usage:
vignette('overview', package = 'bnclassify')
See the list of main functionalities.
?bnclassify
Use the usage vignette for more details on the functions.
vignette('usage', package = 'bnclassify')
Then have a look at the remaining vignettes.
browseVignettes("bnclassify")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.