An Explainable Probabilistic Classifier for Categorical Data Inspired to Quantum Physics

Emanuele Guidotti, Alfio FerraraarXiv 2021

Abstract

The Sparse Tensor Classifier (STC) is a novel supervised learning algorithm that applies principles of quantum mechanics—specifically superposition and wave-particle duality—to categorical data classification. It delivers state-of-the-art performance on structured and text data with almost no pre-processing or hyper-parameter tuning, while providing "native" explanations for its predictions that are easily understood by humans.

Introduction

Categorical data is notoriously difficult to handle because it is often heterogeneous, noisy, and imbalanced. Traditional machine learning workflows require significant "feature engineering"—labor-intensive steps like data cleaning, text normalization (removing stop words, stemming), and complex vectorization (Tf-Idf or word embeddings). Furthermore, as AI is deployed in sensitive areas, there is a growing demand for explainability. Most high-performing models (like deep neural networks) are "black boxes," requiring secondary tools like LIME or SHAP to interpret decisions. This paper introduces the Sparse Tensor Classifier (STC) to bridge this gap by creating a classifier that is mathematically robust, requires minimal setup, and is transparent by design.

Methodology

The STC represents observations as a "superposition of features." Key technical components include:

  • Tensor Representation: Instead of simple matrices, STC uses multi-dimensional tensors to represent the joint probability distribution of features and target labels.
  • Quantum Probability Framework: Borrowing from the Born rule in quantum mechanics, the model calculates the probability of a class by treating features as complex-valued wave functions. This allows the model to account for "interference" between features.
  • Entropic Weighting: To handle noise, the model calculates the Shannon entropy of each feature. Features that are distributed randomly across all classes (high entropy) are automatically down-weighted, while those that strongly point to a specific class (low entropy) are prioritized. This acts as a built-in feature selection mechanism.
  • Fallback Mechanism (Policy): To handle "sparsity" (when a model encounters a combination of features it hasn't seen in training), STC uses a reinforcement-learning-inspired "policy" to systematically drop dimensions of the tensor until a valid prediction can be made.

Experimental Evaluation

The researchers evaluated STC on two distinct types of data:

  1. The Zoo Dataset: A small, highly imbalanced structured dataset containing 101 animals and 16 attributes (like "has feathers" or "number of legs"). This tested the model's robustness to small samples and class imbalance.
  2. 20 Newsgroups: A classic text classification benchmark with ~19,000 documents across 20 categories. Crucially, the authors performed no text cleaning (no removing punctuation or stop words) to see if the model could handle "raw" noisy data.

Results and Discussion

Performance on Structured Data

On the Zoo dataset, the quantum version (STC-Q) outperformed all competitors, including SVM, Random Forest, and Logistic Regression, and showed the highest stability across different training/test splits. As shown in the performance metrics, STC-Q achieved the highest F1-macro score (0.871) among the tested models.

Performance comparison on the Zoo dataset showing STC-Q's superior metrics and its performance relative to standard classifiers.

Performance on Text Data

On the 20 Newsgroups text task, STC-Q achieved an accuracy of 0.873, outperforming specialized deep learning models like Cooperative Neural Networks (0.837) and Neural Attentive Bag-of-Entities (0.868), despite the deep learning models being specifically tuned for the task. STC's entropic weighting naturally ignored "noise" words that usually require manual removal in other pipelines.

Performance comparison on the 20 Newsgroups dataset against standard classifiers and specialized deep learning models.

Native Explainability

Because the model is built on explicit probability distributions, it doesn't need a "wrapper" to explain itself. You can look directly at the tensor weights to see exactly which feature contributed most to a specific prediction. In a survey of 45 evaluators, STC’s native explanations were rated as more meaningful and less noisy than those generated by LIME for other standard classifiers.

Conclusion and Future Work

STC demonstrates that quantum-inspired frameworks can achieve state-of-the-art results on categorical data without extensive pre-processing. While the results are promising, future work will focus on learning "phase factors" via gradient descent to unlock higher performance, extending the framework to handle continuous/numerical variables, and automating the optimization of tensor shapes.

Summary updated

Abstract

This paper presents Sparse Tensor Classifier (STC), a supervised classification algorithm for categorical data inspired by the notion of superposition of states in quantum physics. By regarding an observation as a superposition of features, we introduce the concept of wave-particle duality in machine learning and propose a generalized framework that unifies the classical and the quantum probability. We show that STC possesses a wide range of desirable properties not available in most other machine learning methods but it is at the same time exceptionally easy to comprehend and use. Empirical evaluation of STC on structured data and text classification demonstrates that our methodology achieves state-of-the-art performances compared to both standard classifiers and deep learning, at the additional benefit of requiring minimal data pre-processing and hyper-parameter tuning. Moreover, STC provides a native explanation of its predictions both for single instances and for each target label globally.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
ZooSTC-QF1-score weighted by class support0.945split: test
Source quote
L212: STC-Q │ 0.953 │ 0.953 │ 0.945 │ 0.871
ZooSVMF1-score weighted by class support0.934split: test
Source quote
L208: SVM │ 0.946 │ 0.941 │ 0.934 │ 0.847
20 Newsgroups (by-date version)STC-Q*Macro F1-score0.866STC-Q amplitude parameter p=1/3; macro-averaged evaluation. Text was tokenized only, wi…
Source quote
L259: 0.862 │ 0.839 │ N/A │ N/A │ 0.866
20 NewsgroupsNABoE (Neural Attentive Bag-of-Entities Model)Macro F1-score0.862Deep-learning result reported from the literature; table reports macro-averaged evaluat…
Source quote
L259: 0.862 │ 0.839 │ N/A │ N/A │ 0.866
20 Newsgroups human-evaluator explanation surveySTC (native global explanation)Mean human-evaluation interpretability score0.598split: test
Source quote
L283: We find that STC achieves a score of 0.598, corresponding to a better interpretability than {\sf RF} (0.376), {\sf SVM} (0.270), {\sf LR} (0.256), {\sf DT} (0.146), {\sf KNN} (-0.200). In this sense, STC is similar to one of the most well-known and interpretable models: {\sf MNB} (0.696). We also notice that the results achieved by all the competing algorithms are due to the exploitation of LIME, which is remarkably inefficient in terms of computation time (about 30s for each document, resulting in more than 60 hours for each algorithm). Next, we extend the comparison with {\sf MNB} by exploring the probability P(t \mid c) of a term t given the class c as internally computed by the model. We compare this explanation provided by {\sf MNB} natively ({\sf MNB-G}) with the STC global explanation ({\sf STC-G}) computed as described in Section \ref{sec:explanation}. A short example of the 6 top terms for the class {\sf rec.sport.baseball} is shown in Table~\ref{tab:lime}, where we also report the top terms obtained by aggregating the native local STC weights and those obtained with {\sf MNB} through LIME.
BibTeX
@misc{guidotti2021explainable,
  author = {Emanuele Guidotti and Alfio Ferrara},
  title = {{An Explainable Probabilistic Classifier for Categorical Data Inspired to Quantum Physics}},
  year = {2021},
  eprint = {2105.13988},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.13988},
}
Figure