Error(s) in re-building vignettes:
  ...
--- re-building ‘methods.Rmd’ using rmarkdown
--- finished re-building ‘methods.Rmd’

--- re-building ‘overview.Rmd’ using rmarkdown
# Usage example 
\label{sec:usage}


The available functionalities can be split into four groups:

1. Learning network structure and parameters
1. Analyzing the model 
1. Evaluating the model 
1. Predicting with the model 

\noindent We illustrate these functionalities with the synthetic \code{car} data set with six features. We begin with a simple example for each functionality group and then elaborate on the options in the following sections. We first load the package and the dataset,
 

``` text
library(bnclassify)
data(car)
```

\noindent then learn a naive Bayes structure and its parameters,

``` text
nb <- nb('class', car) 
nb <- lp(nb, car, smooth = 0.01) 
```

\noindent get the number of arcs in the network,

``` text
narcs(nb)
[1] 6
```

\noindent get the 10-fold cross-validation estimate of accuracy,

``` text
cv(nb, car, k = 10) 
[1] 0.8611167
```

\noindent and finally classify the entire data set

``` text
p <- predict(nb, car)
head(p) 
[1] unacc unacc unacc unacc unacc unacc
Levels: unacc acc good vgood
```




## Learning 
The functions for structure learning, shown in \rtbl{algorithms}, correspond to the different algorithms. They all receive the name of the class variable and the data set as their first two arguments, which are then followed by optional arguments. The following runs the CL-ODE algorithm with the AIC score, followed by the FSSJ algorithm to learn another model:

``` text
ode_cl_aic <- tan_cl('class', car, score = 'aic')   
suppressWarnings(RNGversion("3.5.0"))
set.seed(3)
fssj <- fssj('class', car, k = 5, epsilon = 0)
```

The \code{bnc()} function is a shorthand for learning structure and parameters in a single step, 

``` text
ode_cl_aic <- bnc('tan_cl', 'class', car, smooth = 1, dag_args = list(score = 'aic'))
```
\noindent where the first argument is the name of the structure learning function while and optional arguments go in \code{dag\_args}.  

## Analyzing   
Printing the model, such as the above \code{ode\_cl\_aic} object, provides basic information about it.

``` text
ode_cl_aic

  Bayesian network classifier

  class variable:        class 
  num. features:   6 
  num. arcs:   9 
  free parameters:   131 
  learning algorithm:    tan_cl 
```
While plotting the network is especially useful for small networks, printing the structure in the \CRANpkg{deal} \citep{deal1237} and \pkg{bnlearn} format may be more useful for larger ones:
<!-- 
r , fig.width = 4, fig.height = 4}
plot(ode_cl_aic)
--> 


``` text
ms <- modelstring(ode_cl_aic)
strwrap(ms, width = 60)
[1] "[class] [buying|class] [doors|class] [persons|class]"
[2] "[maint|buying:class] [safety|persons:class]"         
[3] "[lug_boot|safety:class]"                             
```

We can query the type of structure; \code{params()} lets us access the conditional probability tables (CPTs); while \code{features()} lists the features:   

``` text
is_ode(ode_cl_aic)
[1] TRUE
```

``` text
params(nb)$buying
       class
buying         unacc          acc         good        vgood
  low   0.2132243562 0.2317727320 0.6664252607 0.5997847478
  med   0.2214885458 0.2994740131 0.3332850521 0.3999077491
  high  0.2677680077 0.2812467451 0.0001448436 0.0001537515
  vhigh 0.2975190903 0.1875065097 0.0001448436 0.0001537515
```

``` text
length(features(fssj))
[1] 5
```
For example, \code{fssj()} has selected five out of six features.  

\code{manb\_arc\_posterior()} provides the MANB posterior probabilities for arcs from the class to each of the features: 










Quitting from lines 92-94 [unnamed-chunk-25] (./includes/usage.rmd)

Quitting from lines 31-31 [unnamed-chunk-5] (overview.Rmd)
Error: processing vignette 'overview.Rmd' failed with diagnostics:
identical(features(x), names(ctgts)) is not TRUE
--- failed re-building ‘overview.Rmd’

--- re-building ‘usage.rmd’ using rmarkdown

Quitting from lines 168-170 [unnamed-chunk-11] (usage.rmd)
Error: processing vignette 'usage.rmd' failed with diagnostics:
identical(sort(feats), sort(features(bn))) is not TRUE
--- failed re-building ‘usage.rmd’

SUMMARY: processing the following files failed:
  ‘overview.Rmd’ ‘usage.rmd’

Error: Vignette re-building failed.
Execution halted