Skip to main content

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:
FieldDescription
$Bestbnc_bn object — the best Bayesian Network found
$BestCLLConditional Log-Likelihood of the best network
$pobFinalList of all bnc_bn objects in the final population
$CLLPobFinalCLL values for every network in the final population
$N.evalsTotal number of CLL evaluations performed
$convergenceBest CLL at each generation
$evaluationsCumulative evaluations at each generation

Printing a summary

print(result)
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

plot(result)
This produces two panels:
  1. Histogram of CLL values across the final population — shows population diversity
  2. 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.