Generalized Naive Bayes

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

This paper introduces Generalized Naive Bayes (GNB), a structural extension of the classic Naive Bayes classifier. By relaxing the rigid assumption that features are independent given a class, the authors provide a more flexible framework that uses undirected graphical models—specifically "cherry junction trees"—to capture complex feature interactions while maintaining the interpretability and efficiency that make Naive Bayes a staple in machine learning.

TL;DR

The authors propose Generalized Naive Bayes (GNB), which relaxes the conditional independence assumption of standard Naive Bayes by allowing for dependencies between pairs of features. They introduce a greedy algorithm (GNB-A) and an optimal algorithm (GNB-O) that consistently outperform standard Naive Bayes and competitive extensions like Tree Augmented Naive Bayes (TAN) on real-world medical datasets.

What Problem Does This Paper Address?

The "Naive" in Naive Bayes comes from the assumption that all input features are conditionally independent given the class label. While this makes the model incredibly fast and easy to interpret, it is almost never true in real-world data. For example, in a medical diagnosis task, "blood pressure" and "age" are likely related, even when we know the patient's health status.

Existing methods like Tree Augmented Naive Bayes (TAN) try to fix this by adding a tree-like structure of dependencies between features. However, the authors argue that these methods often rely on directed graphs that don't fully capture the underlying probability distributions. The challenge is to find a structure that captures these dependencies without falling into the "black box" trap or becoming computationally impossible to solve.

Methods

The core innovation is the use of cherry junction trees (a specific type of Markov network) to represent the GNB structure.

  1. GNB Structure: Instead of looking at features in isolation, GNB groups them into "clusters" 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.
  2. Algorithm GNB-A (Greedy): This algorithm starts with the most informative triplet $(Y, X_1, X_2)$ and greedily adds new features one by one. At each step, it chooses the feature that maximizes information gain while minimizing redundancy.
  3. Algorithm GNB-O (Optimal): Under the assumption that the most informative triplet is included, this algorithm uses the Chu-Liu-Edmonds algorithm (a graph theory classic for finding maximum weighted arborescences) to find the globally optimal GNB structure in terms of Kullback-Leibler (KL) divergence.
  4. Feature Selection: The authors introduce a feature importance score based on how much "weight" (mutual information) a feature adds to the overall model structure.

Datasets

The algorithms were evaluated on five well-known medical datasets from the UCI Machine Learning Repository:

  • Wdbc: Wisconsin Breast Cancer (Diagnostic) data.
  • Heart Disease: The Cleveland dataset.
  • Diabetes: Pima Indians Diabetes data.
  • Thyroid Ann Train: Thyroid disease records.
  • Parkinson: Biomedical voice measurements for Parkinson's detection.

Continuous variables were discretized using a quantile-based method to ensure the algorithms could process them as discrete probabilities.

Key Insights and Ideas

  • Mathematical Guarantee: The authors prove that a GNB distribution will always fit the data at least as well as a standard Naive Bayes distribution. This is because GNB is a superset of NB; it can represent everything NB can, plus additional dependencies.
  • The "Cherry" Advantage: By using cherry junction trees, the model captures bivariate dependencies between features ($X_i$ and $X_j$) relative to the class $Y$. This is a more nuanced way of relaxing independence than simply adding edges between features.
  • Interpretability vs. Performance: Unlike deep learning models, GNB remains "transparent." A researcher can look at the resulting tree and see exactly which pairs of features the model found most relevant for a diagnosis, making it highly valuable for medical applications.

Key Results

  • Superior Accuracy: In head-to-head comparisons, 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).
  • Robustness: GNB-A and GNB-O showed strong performance across multiple metrics, including Precision, Recall, F1-score, and AUC. For instance, on the Parkinson dataset, GNB-A achieved a Precision of 0.9628.
  • 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 slower than the $O(dn)$ of standard Naive Bayes, it remains competitive with other augmented models like TAN and is feasible for most tabular datasets.

Limitations and Future Work

  • Discretization Sensitivity: The authors acknowledge that the model's performance is heavily dependent on the discretization method used for continuous data. While they used a general quantile method, they suggest that domain-specific discretization could yield even better results.
  • The "First Triplet" Assumption: The optimality of GNB-O relies on the assumption that the most informative triplet is part of the final structure. While statistically likely, it is a constraint.
  • Future Directions: The authors suggest that GNB could be extended to non-binary classification tasks and that exploring different discretization strategies (like those specifically optimized for Naive Bayes) is a promising next step.

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