TL;DR
This paper introduces a novel four-step methodology for creating representative samples of software repositories, crucial for empirical software engineering research. By carefully selecting and analyzing variables of interest, their approach ensures that the generated samples accurately reflect the characteristics of the entire repository population, overcoming limitations of existing random or popularity-based sampling methods.
What Problem Does This Paper Address?
Empirical software engineering, particularly the Mining Software Repositories (MSR) field, heavily relies on data from platforms like GitHub and Hugging Face. These platforms host millions of software repositories, making it impossible to analyze them all. Consequently, researchers must sample these repositories to create manageable datasets. However, existing sampling methods are often too simplistic, relying on random selection or superficial metrics like popularity (e.g., number of stars), which fail to capture the true diversity and characteristics relevant to specific research questions. This leads to biased samples and potentially unreliable research findings. The paper addresses the critical need for a robust methodology that generates samples representative of the population based on variables that truly matter for a given empirical study.
Methods
The authors propose a four-step methodology for creating representative samples:
- Variable Selection: Researchers identify the key variables that define representativeness for their specific study. These can be numerical (e.g., likes, downloads) or categorical (e.g., repository type).
- Variable Analysis: This phase involves two sub-steps:
- Preprocessing: Handling missing data (NaN values) is crucial. For numerical variables, NaN values are typically removed to avoid introducing false information. For categorical variables, NaN values are treated as a distinct category. Statistical metrics like population size, mean, and standard deviation are calculated.
- Stratification: The population is divided into strata (subgroups) based on the selected variables. For numerical variables, a clustering algorithm like K-means is used to define strata. For categorical variables, the categories themselves form the strata.
- Composition: If multiple variables are selected, this phase combines the strata from each variable to create a more complex set of strata. This involves generating all possible combinations of strata from the chosen variables.
- Sample Creator: This final step involves extracting samples from each stratum. For numerical variables, probabilistic sampling methods like simple random sampling are applied. For categorical variables, sampling is done while maintaining the population proportions. The process can be iterated to select the best sample based on statistical parameters.
The methodology emphasizes the use of stratified sampling and proportional allocation to ensure that each stratum is adequately represented in the final sample.
Datasets
The paper uses the HFCOMMUNITY dataset, an offline database built from data available at the Hugging Face Hub (HFH). HFH hosts machine learning models, datasets, and spaces as Git repositories. HFCOMMUNITY provides data from HFH and Git repositories in a relational database format. The authors illustrate their approach with three use cases based on this dataset, focusing on repositories hosted on Hugging Face.
Key Insights and Ideas
- Representativeness is Study-Specific: The core idea is that "representativeness" isn't a one-size-fits-all concept. It must be aligned with the specific variables of interest for a given empirical study.
- Stratification is Key: Dividing the population into meaningful subgroups (strata) based on relevant variables is essential for ensuring that diverse segments of the population are captured in the sample.
- Handling Different Variable Types: The methodology provides distinct but complementary approaches for dealing with numerical and categorical variables, acknowledging their different statistical properties.
- Composition for Multi-Variable Sampling: When multiple variables are important, combining their strata allows for the creation of samples that are representative across a more complex set of characteristics.
- Tool Support for Practicality: The authors have developed a Python tool to implement their methodology, making it accessible to researchers without requiring them to delve into the complex mathematical underpinnings.
Key Results
The paper demonstrates its methodology through three use cases on the HFCOMMUNITY dataset:
- Case #1 (Numerical Variable - Likes): The methodology successfully stratified repositories based on the number of likes, using K-means clustering. A sample size of 57,258 observations was determined with a margin of error of 0.114 and a 0.95 confidence interval.
- Case #2 (Categorical Variable - Type): Repositories were stratified by type (dataset, model, space). A sample size of 385 was determined with a margin of error of 0.05 and a 0.95 confidence interval, showing a sample distribution similar to the population.
- Case #3 (Mixed Variables - Likes and Type): The approach combined strata from both numerical (likes) and categorical (type) variables, resulting in 9 strata. A sample size of 385 observations was generated, with stratum sizes detailed in Table 1.
The paper also provides a tool implementation with a reproducibility package, enabling others to replicate their findings.
Limitations and Future Work
- Sample Size Parameterization: The current implementation focuses on achieving a desired margin of error and confidence level, which can lead to large sample sizes. Future work aims to allow users to parameterize the sample size directly and report on how this affects representativeness.
- Extending to Multiple Datasets/Evolving Datasets: The approach is currently focused on a single dataset. Future plans include extending support for sampling from multiple datasets or handling evolving datasets (where data is added or removed over time).
- Application to Additional Use Cases: The authors intend to apply their methodology to more diverse use cases to further validate and refine it.
Summary updated