Is a Classification Procedure Good Enough?—A Goodness-of-Fit Assessment Tool for Classification Learning

Jiawei Zhang, Jie Ding, Yuhong Yang

Introduction

In the current landscape of machine learning, performance is almost exclusively measured through predictive accuracy. Whether using Random Forests, Gradient Boosting, or Deep Neural Networks, the primary goal is typically to minimize the error rate. However, accuracy can be a deceptive metric. A model might achieve high accuracy while still failing to capture the underlying data-generating process—a phenomenon known as underfitting.

Traditional statistical methods offer "Goodness-of-Fit" (GOF) tests, such as the Hosmer-Lemeshow test, to determine if a model adequately describes the data. Yet, these classical tests were designed for parametric models like logistic regression and often lack the power or theoretical grounding to assess complex, non-parametric "black-box" classifiers. To bridge this gap, we introduce BAGofT (Binary Adaptive Goodness-of-fit Test), a framework designed to assess whether a general classification procedure is "good enough."

The BAGofT Methodology

The core challenge in testing non-parametric models is the lack of a fixed functional form. BAGofT overcomes this by utilizing a two-stage approach centered on data splitting and adaptive partitioning.

1. Data Splitting

The dataset is divided into a training set ($D_{n1}$) and a validation set ($D_{n2}$). This separation is crucial: it ensures that the search for model weaknesses does not bias the final statistical test, thereby controlling the Type I error rate.

2. Adaptive Partitioning (The Diagnostic Step)

The classification model under assessment is first trained on $D_{n1}$. To find where the model fails, BAGofT employs an "adversarial" diagnostic tool—typically a Random Forest—trained on the Pearson residuals of the initial model. These residuals represent the difference between the observed outcomes and the model's predicted probabilities. By fitting a secondary model to these errors, BAGofT identifies specific regions in the covariate space where the original model's predictions deviate most significantly from reality. It then adaptively partitions the data into groups that highlight these weaknesses.

3. Statistical Testing

Using the partitions identified in the diagnostic step, a Pearson-type test statistic is calculated using the independent validation set ($D_{n2}$). If the original model is a good fit, the observed responses in these regions should align with the predicted probabilities. A significant p-value indicates that the model has systematically missed patterns in the data (underfitting).

Key Insights: Beyond Accuracy

BAGofT shifts the focus from "how often is the model right?" to "is the model's representation of the data distribution correct?"

  • Identifying Blind Spots: Unlike global metrics, BAGofT is inherently local. By partitioning the feature space, it can pinpoint which variables or interactions the model failed to learn. For instance, in experiments with the Fashion MNIST dataset, the tool identified that a simple neural network struggled specifically with the "gap between the legs" in images of trousers, a nuance it had not captured despite reasonable overall accuracy.
  • Rate-Dependent Testing: The framework is flexible enough to test if a model is converging at a specific theoretical rate. This allows researchers to verify if a neural network is performing as expected given the complexity of the underlying data (e.g., specific Besov classes).
  • Interpretability: The adaptive partition doesn't just provide a p-value; it reveals which variables are responsible for the underfitting, offering a roadmap for model improvement.

Empirical Results

The utility of BAGofT was demonstrated across several domains, showing significant advantages over traditional GOF tests.

Detecting Hidden Patterns

In a study involving Micro-RNA data for Alzheimer’s disease prediction (n=1309), BAGofT successfully rejected an underfitted model (p < 0.01) that omitted a critical principal component. In contrast, traditional tests like the Hosmer-Lemeshow and GRP tests failed to detect any issue, returning p-values greater than 0.17.

Accuracy vs. Fit in Medical Imaging

The most striking example of the "accuracy trap" appeared in the analysis of COVID-19 CT scan features. Two neural networks—one with a single neuron and one with seven—showed nearly identical accuracies of approximately 70%. However, BAGofT revealed a systematic defect in the 1-neuron network (p = 0.03), while the 7-neuron network was found to be a statistically adequate fit (p = 0.62). This demonstrates that BAGofT can distinguish between models that are "lucky" and models that are statistically sound.

Conclusion and Future Directions

BAGofT provides a much-needed rigorous framework for evaluating modern machine learning models. By using residuals to adaptively find model weaknesses, it offers both a statistical verdict and diagnostic interpretability.

Currently, the framework is optimized for binary classification and the detection of underfitting. Future work aims to extend these methods to multi-class problems and to develop complementary tests for overfitting. As machine learning continues to move into high-stakes fields like medicine and finance, tools like BAGofT will be essential for ensuring that our models are truly fit for purpose.

Summary updated

Abstract

In recent years, many nontraditional classification methods, such as random forest, boosting, and neural network, have been widely used in applications. Their performance is typically measured in terms of classification accuracy. While the classification error rate and the like are important, they do not address a fundamental question: Is the classification method underfitted? To our best knowledge, there is no existing method that can assess the goodness of fit of a general classification procedure. Indeed, the lack of a parametric assumption makes it challenging to construct proper tests. To overcome this difficulty, we propose a methodology called BAGofT that splits the data into a training set and a validation set. First, the classification procedure to assess is applied to the training set, which is also used to adaptively find a data grouping that reveals the most severe regions of underfitting. Then, based on this grouping, we calculate a test statistic by comparing the estimated success probabilities and the actual observed responses from the validation set. The data splitting guarantees that the size of the test is controlled under the null hypothesis, and the power of the test goes to one as the sample size increases under the alternative hypothesis. For testing parametric classification models, the BAGofT has a broader scope than the existing methods since it is not restricted to specific parametric models (e.g., logistic regression). Extensive simulation studies show the utility of the BAGofT when assessing general classification procedures and its strengths over some existing methods when testing parametric classification models. Supplementary materials for this article are available online.
BibTeX
@article{zhang2021is,
  author = {Jiawei Zhang and Jie Ding and Yuhong Yang},
  title = {{Is a Classification Procedure Good Enough?—A Goodness-of-Fit Assessment Tool for Classification Learning}},
  journal = {Journal of the American Statistical Association},
  year = {2021},
  doi = {10.1080/01621459.2021.1979010},
}
Figure