Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alexplatasl/dplbnde/llms.txt
Use this file to discover all available pages before exploring further.
The DE result object
All algorithm functions return an S3 object of class DE containing:
| Field | Description |
|---|
$Best | bnc_bn object — the best Bayesian Network found |
$BestCLL | Conditional Log-Likelihood of the best network |
$pobFinal | List of all bnc_bn objects in the final population |
$CLLPobFinal | CLL values for every network in the final population |
$N.evals | Total number of CLL evaluations performed |
$convergence | Best CLL at each generation |
$evaluations | Cumulative evaluations at each generation |
Printing a summary
Number of evaluations: 780
Final population size: 30
Summary results of fitness in final population:
Best CLL: -1181.117
Worst CLL: -1251.721
Median: -1218.063
Std. Dev.: 17.96752
A smaller spread (lower Std. Dev.) indicates the population has converged. A large gap between Best and Worst CLL suggests the algorithm may benefit from more generations.
Plotting convergence
This produces two panels:
- Histogram of CLL values across the final population — shows population diversity
- Convergence plot — best CLL vs. cumulative evaluations — shows how quickly the algorithm improved
A flat convergence curve at the end indicates the algorithm has converged. If the curve is still declining at the last generation, increase G.
Predicting and measuring accuracy
The $Best field is a bnc_bn object compatible with all bnclassify functions:
# Predict class labels
predictions <- predict(result$Best, car)
# Compute classification accuracy
acc <- accuracy(predictions, car$class)
cat("Accuracy:", round(acc * 100, 2), "%\n")
accuracy() expects character or factor vectors of equal length. Both predictions and the true labels must use the same factor levels.
Comparing multiple runs
library(dplbnDE)
data(car)
cn <- names(car)[7]
algorithms <- list(
debest = DEbest(NP=20, G=25, data=car, class.name=cn, structure="tan", verbose=0),
lshade = lshade(NP=20, G=25, data=car, class.name=cn, structure="tan", verbose=0),
jade = jade(NP=20, G=25, data=car, class.name=cn, structure="tan", verbose=0)
)
for (name in names(algorithms)) {
p <- predict(algorithms[[name]]$Best, car)
cat(name, "accuracy:", round(accuracy(p, car$class) * 100, 2), "%",
"| Best CLL:", algorithms[[name]]$BestCLL, "\n")
}
CLL and classification accuracy are correlated but not identical. Always evaluate both metrics when selecting an algorithm.