NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Beta-CoRM: A Bayesian approach for n-gram profiles analysis

José A. Perusquía, Jim E. Griffin, Cristiano VillaComput. Stat. Data Anal 2020

TL;DR

This paper introduces Beta-CoRM, a novel Bayesian generative model for analyzing n-gram profiles, particularly for cybersecurity applications like malware classification. It addresses the challenge of high-dimensional n-gram data by incorporating a feature selection mechanism within the generative model, leading to improved classification accuracy.

What Problem Does This Paper Address?

Analyzing sequences of data, such as text or binary code, often involves using "n-grams" – contiguous subsequences of length 'n'. These n-grams can be used as features to characterize observations for tasks like classification or clustering. However, in domains like cybersecurity, the sheer number of possible n-grams can explode, leading to the "curse of dimensionality." Traditional machine learning methods, while good at prediction, often struggle to reveal underlying data structures or provide probabilistic uncertainty. This paper aims to bridge this gap by developing a Bayesian approach that not only models n-gram profiles but also inherently performs feature selection to identify the most discriminative n-grams for classification.

Methods

The core of the paper is the Beta-CoRM (Beta Compound Random Measure) model. It's a Bayesian approach that models grouped binary data (like the presence/absence of n-grams in different malware families) using a hierarchical structure.

  • Compound Random Measures (CoRM): This is the foundational Bayesian nonparametric tool used. CoRMs are flexible measures that can model correlated data structures, making them suitable for analyzing multiple related groups (e.g., different malware families).
  • Beta Process: The model specifically uses a beta process as a component of the CoRM. Beta processes are well-suited for generating binary data and have nice probabilistic properties.
  • Feature Selection within the Generative Model: A key innovation is the generalization of the Beta-CoRM model to incorporate a "spike-and-slab" prior interpretation for the score parameters. This prior structure naturally encourages some n-grams to have very low probabilities of being selected, effectively performing feature selection during the model fitting process.
  • Slice Sampling: To efficiently infer the model parameters, a slice sampling algorithm is derived. This is a computational technique that helps handle the complexity of Bayesian nonparametric models.

Datasets

  • Synthetic Data: A synthetic dataset was generated with 5 imbalanced groups, 250 observations, and 300 binary features to analyze the effect of different priors on feature selection and predictive performance.
  • Microsoft Malware Classification Challenge (Kaggle 2015): A subset of this dataset was used for real-world malware classification. It consists of 842 malware samples from nine families, with hexadecimal representations of their binary code. The authors focused on 4-grams, resulting in a large feature space (initially 10 million unique 4-grams, reduced to 826 features that appeared at least once in each family).

Key Insights and Ideas

  • Bayesian Generative Models for N-grams: The paper demonstrates that Bayesian generative models can offer a more interpretable and structured approach to n-gram analysis compared to purely predictive machine learning methods.
  • Integrated Feature Selection: The most significant insight is the development of a feature selection mechanism that is integrated into the generative model itself. This is more principled than post-hoc feature selection, as it considers the discriminative power of features within the context of the model's probabilistic structure.
  • Spike-and-Slab Priors for Feature Selection: The interpretation of the beta distribution's score parameter as a spike-and-slab prior is a clever way to induce sparsity and identify important features. Small values of the parameter 'a' lead to a strong "spike" at zero, effectively down-weighting less informative features.
  • Prior Sensitivity Matters for Feature Selection: The choice of prior distributions for the model's hyperparameters significantly impacts the feature selection process, with some priors (like objective Lomax and half-Cauchy) exhibiting a stronger shrinkage effect, leading to more pronounced feature selection.

Key Results

  • Improved Classification Accuracy: The generalized Beta-CoRM model with appropriate priors (particularly objective Lomax) achieved competitive or superior classification accuracy on both synthetic and real malware data compared to other models. For the malware dataset, the objective Lomax prior achieved the best results.
  • Effective Feature Reduction: The feature selection mechanism successfully identified a subset of optimal features, significantly reducing the dimensionality of the n-gram space while retaining discriminative power. For the malware dataset, the number of selected features varied depending on the prior, but the objective Lomax prior selected 124 features.
  • Comparison to Standard Classifiers: The Beta-CoRM model with the objective Lomax prior outperformed decision trees and showed similar performance to multinomial logistic regression on the malware dataset, though it was outperformed by XGBoost.

Limitations and Future Work

  • Computational Cost: While slice sampling improves efficiency, Bayesian nonparametric models can still be computationally intensive, especially with large datasets. The authors mention that for the malware dataset, algorithms took around 30 minutes.
  • Prior Choice Impact: The performance of the feature selection is sensitive to the choice of prior. While the paper explores several priors, selecting the "best" prior for a given problem might require further investigation or cross-validation.
  • Future Work: The authors suggest extending the Beta-CoRM models to other cybersecurity applications like masquerade attack detection and incorporating contextual information (e.g., device operation) by introducing more perturbation coefficients. They also mention exploring other non-conjugate shrinkage priors for potentially improved feature selection, albeit with a potential increase in computational cost.

Summary updated

BibTeX
@article{perusquia2020beta,
  author = {José A. Perusquía and Jim E. Griffin and Cristiano Villa},
  title = {{Beta-CoRM: A Bayesian approach for n-gram profiles analysis}},
  journal = {Comput. Stat. Data Anal.},
  year = {2020},
  url = {https://openreview.net/forum?id=ChKX6HuFps},
}
Figure