Utilizing Large Language Models for Machine Learning Explainability

Alexandros Vassiliades, Nikolaos Polatidis, Stamatios Samaras, Sotiris Diplaris, Ignacio Cabrera Martin, Yannis Manolopoulos, Stefanos Vrochidis, Ioannis KompatsiarisarXiv 2025

TL;DR

Can we trust Large Language Models (LLMs) to autonomously build machine learning pipelines that are not only accurate but also human-interpretable? This paper evaluates code generated by OpenAI GPT, Anthropic Claude, and DeepSeek across binary and multilabel classification tasks. The results show that LLM-generated pipelines achieve near-perfect explanation fidelity and concise feature sparsity, matching manually engineered human baselines.

What Problem Does This Paper Address?

As Large Language Models excel at code generation, engineers and data scientists are increasingly using them to automate machine learning workflows—from data preprocessing to model training. However, while an LLM can easily spit out syntactically correct Python code, a critical question remains: Are the resulting models explainable, or are they uninterpretable black boxes?

In high-stakes domains like healthcare, finance, and autonomous driving, code automation without transparency poses severe risks. This paper bridges the gap between automated machine learning (AutoML via LLMs) and Explainable AI (XAI) by systematically evaluating the interpretability of models generated entirely through LLM prompts.

Methods

The authors designed an experimental pipeline to test three state-of-the-art LLMs as autonomous code-generation agents: OpenAI GPT, Anthropic Claude, and DeepSeek.

Fig. 1. Overview of the experimental pipeline.

Each LLM was given a single-shot natural language prompt (at a temperature setting of 1.0 to encourage diverse solutions) and asked to generate training and evaluation code for four popular classifiers:

  • Random Forest (RF)
  • XGBoost
  • Multi-Layer Perceptron (MLP)
  • Long Short-Term Memory (LSTM) networks

To evaluate the explainability of the generated models, the authors utilized SHAP (SHapley Additive exPlanations) to measure two key metrics:

  1. Average SHAP Fidelity: The Mean Squared Error (MSE) between the model's actual predictions and the SHAP surrogate explanation. Lower error means the explanation faithfully tracks the model's true internal logic.
  2. Average SHAP Sparsity: The average number of features deemed influential (with non-zero attribution). Lower sparsity means a more concise, human-readable explanation.

Datasets

The pipelines were executed and evaluated on two distinct datasets:

  • Driver Alertness Dataset (Custom): A synthetic dataset containing 200,000 samples with 5 features (heart rate, yawning, straight-ahead gaze, eye closure, and an alertness label). This dataset features largely linear relationships, serving as a clean baseline for binary classification.
  • Yeast Dataset (Public Benchmark): A highly complex, imbalanced multilabel dataset containing 1,484 instances with 8 numerical features describing protein localization sites across 10 distinct target classes.

Key Insights and Ideas

  • LLMs Understand Architecture Context: For the complex multilabel yeast dataset, Claude and DeepSeek autonomously implemented sophisticated strategies, such as using OneVsRestClassifier wrappers for tree-based models and configuring multiple output neurons with sigmoid activations for neural networks.
  • High Explanation Faithfulness: Across nearly all generated pipelines, SHAP fidelity hovered remarkably close to 0. This proves that LLM-generated models do not introduce erratic, unexplainable decision boundaries; their logic remains transparent and auditable.
  • Model Selection Still Matters: While LLMs successfully generated LSTM code for tabular datasets, the authors noted that LSTMs provided no additional performance benefits over simpler tree ensembles, reminding us that LLM automation cannot replace foundational data science intuition.
  • Subtle LLM Divergences: Anthropic Claude and DeepSeek tended to generate slightly more robust pipelines for complex multilabel tasks (e.g., explicit probability stacking), resulting in marginally higher macro-F1 scores than OpenAI GPT, which occasionally defaulted to shallower architectures.

Key Results

Binary Classification (Driver Alertness)

Due to the linear nature of the custom dataset, all LLM-generated models achieved near-perfect predictive performance (Precision, Recall, and F1-scores of ~1.0000), perfectly matching the manually engineered baseline.

  • Fidelity: SHAP Fidelity was an absolute 0.00000 for almost all models, except for minor variations in OpenAI's LSTM (0.01000) and DeepSeek's LSTM (0.05994).
  • Sparsity: Every single model across all LLMs maintained a perfect sparsity score of 4.00, utilizing a concise, human-understandable subset of features.

Multilabel Classification (Yeast Protein Localization)

As expected, performance dropped due to class imbalances, with F1-scores ranging between 0.46 and 0.63.

  • Fidelity: Despite the increased difficulty, SHAP Fidelity remained perfect (0.00000) across the board.
  • Sparsity: Sparsity naturally expanded to accommodate the 10-class problem, ranging from 6.90 (for DeepSeek and Claude's MLP/LSTM models) to 8.00 (for OpenAI's models), showcasing that the models remained streamlined.

Limitations and Future Work

While the results are promising, the authors acknowledge several limitations in this initial study:

  • Narrow Scope: The evaluation was restricted to three LLMs, four standard machine learning models, and two datasets.
  • Single XAI Framework: The study relied exclusively on SHAP for interpretability metrics.
  • No Hyperparameter Optimization: The LLMs were evaluated on "first-attempt" single-shot prompts without iterative refinement, cross-validation, or fine-tuning.

Future Directions: The authors plan to extend this benchmarking framework to more complex tasks like regression and time-series forecasting, explore causal explainability, introduce fairness-aware evaluations, and directly compare LLM outputs against highly optimized human-engineered baselines.

Summary updated

BibTeX
@misc{vassiliades2025utilizing,
  author = {Alexandros Vassiliades and Nikolaos Polatidis and Stamatios Samaras and Sotiris Diplaris and Ignacio Cabrera Martin and Yannis Manolopoulos and Stefanos Vrochidis and Ioannis Kompatsiaris},
  title = {{Utilizing Large Language Models for Machine Learning Explainability}},
  year = {2025},
  eprint = {2510.06912},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.06912},
}
Figure