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

Parameter-free probabilistic API mining across GitHub

Jaroslav M. Fowkes, Charles Sutton

Abstract

Learning to use new software libraries is a significant hurdle for developers, often due to incomplete or ambiguous documentation. API mining aims to alleviate this by automatically extracting common call sequences from open-source repositories. However, traditional frequency-based miners suffer from high redundancy and require manual parameter tuning. This paper presents PAM (Probabilistic API Miner), a near parameter-free approach based on probabilistic generative modeling. By using Structural Expectation-Maximization, PAM identifies statistically significant API patterns while handling interleaved calls and reducing output redundancy. Our evaluation on a large-scale GitHub corpus of 17 Java libraries demonstrates that PAM achieves 69% precision, outperforming state-of-the-art methods.

1. Introduction

Learning a new software library is a major hurdle for developers. While official documentation exists, it is often incomplete, ambiguous, or fails to show how different methods should be used together in real-world scenarios. To bridge this gap, researchers employ API mining—the process of automatically extracting common call sequences (e.g., init -> setKey -> build) from open-source repositories.

However, existing state-of-the-art tools like MAPO and UPMiner suffer from three major flaws:

  1. The "Black Art" of Tuning: They require users to set arbitrary "minimum frequency" thresholds, which can lead to either an explosion of patterns or none at all.
  2. Frequency vs. Interest: High frequency does not always imply logical relevance; unrelated but common calls can clutter results.
  3. High Redundancy: Current tools often return numerous slight variations of the same basic sequence, making the output difficult for humans to digest.

2. Methodology: The PAM Approach

The authors introduce PAM (Probabilistic API Miner), a "near parameter-free" approach based on probabilistic generative modeling. Instead of simple frequency counting, PAM assumes that a programmer’s code is a mixture of several "interesting" API patterns interleaved with each other.

To discover these patterns, PAM utilizes Structural Expectation-Maximization (Structural EM). The generative model treats API sequences as puzzles where different patterns are "spliced" together, allowing the algorithm to handle "gaps"—instances where custom code is inserted within a standard API sequence. In this framework, patterns "compete" to explain the code. If a specific, long pattern explains a sequence better than multiple generic, short patterns, the model prefers the specific one, naturally reducing redundancy. Patterns are then ranked by their probability under the model—measuring how much they improve code predictability—rather than raw frequency.

3. Experimental Setup

The study evaluated PAM using a massive crawl of the GitHub Java corpus, focusing on 17 popular libraries. The dataset included over 54,000 client methods from nearly 1,000 projects, totaling over 4 million lines of code. To establish a "gold standard," the authors utilized 300,000 lines of developer-written example code from the libraries' official examples/ directories to see if PAM could "re-discover" essential usage patterns.

Table 1: Summary of the 17 popular Java libraries and the scale of client and example code used for evaluation.

4. Results and Key Insights

PAM demonstrated significant improvements over existing methods in both precision and the quality of discovered patterns.

4.1 Performance Metrics

PAM achieved 69% precision on a held-out test set, significantly higher than MAPO and UPMiner. It reached a recall of 44%, which is remarkably close to the theoretical maximum (approximately 45%) for this specific dataset.

Figure 1: Interpolated Average Sequence Precision vs. Average Sequence Recall for PAM, MAPO, and UPMiner.

4.2 Pattern Quality and Diversity

Beyond raw metrics, PAM excelled in reducing redundancy. On average, a pattern mined by PAM was contained within only 0.5 other patterns, whereas patterns from older tools were often redundant across 12 or more sequences. Furthermore, PAM's top results showed greater diversity; for the twitter4j library, PAM's top results utilized 20 unique API methods compared to just 8 for its competitors.

One of the most surprising findings was the "documentation gap." PAM discovered many common, valid usage patterns in the wild that were completely absent from official developer-written examples, highlighting the value of mining "real-world" code.

5. Limitations and Future Work

While effective, PAM has limitations. Its current static analysis implementation is "best-effort" and may struggle with complex method resolution involving heavy inheritance. Additionally, the model treats code as a linear sequence, approximating complex control flow (branching and loops) by flattening paths.

Future work includes integrating PAM directly into IDEs like Eclipse or IntelliJ to provide real-time, data-driven code completion and helping library maintainers identify gaps in their official documentation.

Summary updated

BibTeX
@inproceedings{fowkes2016parameter,
  author = {Jaroslav M. Fowkes and Charles Sutton},
  title = {{Parameter-free probabilistic API mining across GitHub}},
  booktitle = {SIGSOFT FSE},
  year = {2016},
  doi = {10.1145/2950290.2950319},
}
Figure