Generalized Naive Bayes

Edith Kovács, Anna Ország, Dániel Pfeifer, András A. Benczúr · DOI

Abstract: In this paper we introduce the so-called Generalized Naive Bayes structure as an extension of the Naive Bayes structure. We give a new greedy algorithm that finds a good fitting Generalized Naive Bayes (GNB) probability distribution. We prove that this fits the data at least as well as the probability distribution determined by the classical Naive Bayes (NB). Then, under a not very restrictive condition, we give a second algorithm for which we can prove that it finds the optimal GNB probability distribution, i.e. best fitting structure in the sense of KL divergence. Both algorithms are constructed to maximize the information content and aim to minimize redundancy. Based on these algorithms, new methods for feature selection are introduced. We discuss the similarities and differences to other related algorithms in terms of structure, methodology, and complexity. Experimental results show, that the algorithms introduced outperform the related algorithms in many cases.

Introduction: Beyond the Independence Assumption

The "Naive" in Naive Bayes (NB) refers to the assumption that all input features are conditionally independent given the class label. While this assumption makes the model computationally efficient and easy to interpret, it is rarely satisfied in real-world datasets. For instance, in medical diagnostics, features like "age" and "blood pressure" are often correlated even when the patient's health status is known.

Existing extensions, such as Tree Augmented Naive Bayes (TAN), attempt to address this by adding a tree-like structure of dependencies between features. However, these often rely on directed graphs that may not fully capture the underlying probability distributions. This paper introduces Generalized Naive Bayes (GNB), which relaxes the conditional independence assumption by allowing for dependencies between pairs of features using undirected graphical models.

The GNB Framework and Cherry Junction Trees

The core innovation of GNB is the use of cherry junction trees (a specific type of Markov network) to represent the model structure. Instead of treating features in isolation, GNB groups them into "clusters" or cliques of three: the class variable ($Y$) and two features ($X_i, X_j$). These clusters are connected via "separators" consisting of the class variable and one feature.

The relationship between the GNB graph structure and its equivalent cherry junction tree representation.

By utilizing this structure, the model captures bivariate dependencies between features relative to the class. This approach provides a more nuanced way of relaxing independence than simply adding edges between features, ensuring the model remains a superset of standard Naive Bayes. Mathematically, this guarantees that a GNB distribution will always fit the data at least as well as a standard NB distribution.

Algorithmic Construction: GNB-A and GNB-O

The authors propose two primary algorithms for building these structures:

  1. Algorithm GNB-A (Greedy): This algorithm begins with the most informative triplet $(Y, X_1, X_2)$ and iteratively adds new features. At each step, it selects the feature that maximizes information gain while minimizing redundancy.
  2. Algorithm GNB-O (Optimal): Under the assumption that the most informative triplet is included in the final model, this algorithm utilizes the Chu-Liu-Edmonds algorithm to find the globally optimal GNB structure in terms of Kullback-Leibler (KL) divergence.
Iterative construction process of a GNB structure, illustrating how new features are added to the core model.

Both algorithms are designed to maximize information content. Furthermore, the authors introduce a feature selection method based on the mutual information "weight" a feature contributes to the overall model structure.

Experimental Evaluation

The algorithms were evaluated on five medical datasets from the UCI Machine Learning Repository, including the Wisconsin Breast Cancer (Wdbc), Heart Disease, and Parkinson datasets. Continuous variables were discretized using a quantile-based method to facilitate discrete probability processing.

Key results include:

  • Superior Accuracy: GNB-O achieved the highest accuracy on the Wdbc (0.9442) and Heart Disease (0.8133) datasets, significantly outperforming standard Naive Bayes (0.8419 and 0.7156, respectively).
  • Robust Metrics: GNB-A and GNB-O showed strong performance across Precision, Recall, F1-score, and AUC. For example, GNB-A achieved a Precision of 0.9628 on the Parkinson dataset.
  • Efficiency: The computational complexity for both GNB algorithms is $O(d^2n^2)$ (where $d$ is the number of features and $n$ is the number of samples). While higher than the $O(dn)$ of standard NB, it remains competitive with other augmented models like TAN and is feasible for most tabular datasets.

Conclusion

Generalized Naive Bayes offers a powerful middle ground between the simplicity of Naive Bayes and the complexity of black-box models. By using cherry junction trees, GNB maintains high interpretability—allowing researchers to see exactly which feature pairs are most relevant for a classification—while delivering performance that rivals or exceeds existing augmented Bayesian classifiers. Future work may explore domain-specific discretization strategies and extensions to non-binary classification tasks.

Summary updated

BibTeX
@inproceedings{kovacs2025generalized,
  author = {Edith Kovács and Anna Ország and Dániel Pfeifer and András A. Benczúr},
  title = {{Generalized Naive Bayes}},
  booktitle = {Pattern},
  year = {2025},
  doi = {10.1016/j.patcog.2025.112927},
}
Figure