mikropml: User-Friendly R Package for Supervised Machine Learning Pipelines

Begüm D. Topçuoğlu, Zena Lapp, Kelly L. Sovacool, Evan S. Snitkin, Jenna Wiens, Patrick D. SchlossJ. Open Source Softw 2021 · DOI · DBLP

The mikropml R package logo.

Introduction

Supervised machine learning (ML) has become a cornerstone of modern research across diverse fields such as healthcare, genomics, and economics. However, implementing a robust, reproducible ML pipeline remains a significant challenge. A standard workflow involves complex, non-trivial steps: data preprocessing (e.g., handling categorical variables, normalization), hyperparameter tuning via cross-validation, performance evaluation on independent test sets, and model interpretation.

For many researchers, particularly those new to the field, these steps are time-consuming and prone to "silent errors"—implementation mistakes that can lead to over-optimistic or misleading results. While existing R frameworks like caret or tidymodels provide essential building blocks, they do not automatically integrate them into a standardized, best-practice pipeline. mikropml addresses this gap by providing a high-level interface that enforces rigorous ML practices by default, streamlining the process into a single, reproducible workflow.

Methods

The mikropml package is built primarily on the well-established caret package in R. Its core functionality is centered around two primary functions designed to handle the end-to-end ML process.

Data Preprocessing

The preprocess_data() function automates the "grunt work" of data preparation. It performs several critical tasks:

  • Re-factoring categorical data into binary features.
  • Normalizing continuous data scales.
  • Removing features with near-zero variance.
  • Identifying and handling perfectly correlated features to prevent redundancy.

The Machine Learning Pipeline

The run_ml() function serves as the engine of the package. In a single call, it manages the entire training and evaluation cycle: splitting data into training and testing sets, performing internal cross-validation for hyperparameter tuning, training the final model, and evaluating its performance.

Overview of the mikropml machine learning pipeline.

Supported Algorithms and Interpretation

The package supports a variety of standard ML models, including:

  • Logistic and Linear Regression (glmnet)
  • Support Vector Machines (SVM) with radial basis kernels
  • Decision Trees (rpart)
  • Random Forest (randomForest)
  • Gradient-Boosted Trees (xgboost)

Beyond model training, mikropml emphasizes interpretability. It incorporates a "permutation importance" step post-training, which assesses how much model performance drops when the relationship between a feature and the outcome is broken. This provides a standardized method for interpreting feature importance across different model types.

Applications

As a software-focused contribution, mikropml is designed to be domain-agnostic and applicable to any tabular dataset for supervised classification or regression. It has already been successfully applied to diverse real-world datasets, including:

  • Microbiome Data: Categorizing patients with colorectal cancer based on gut bacterial profiles.
  • Genomic/Clinical Data: Identifying features associated with specific bacterial infections.
  • Bibliometric Data: Predicting gender-based biases in academic publishing.

Key Insights and Scalability

A significant contribution of mikropml is the abstraction of a complete, rigorous ML workflow into a single function. This drastically lowers the barrier to entry for reproducible science. Furthermore, by including permutation importance as a core feature, the authors encourage researchers to move away from "black box" modeling toward a deeper understanding of model drivers.

To support large-scale analyses, the authors provide example workflows using Snakemake. This allows users to scale their analysis from local machines to high-performance computing clusters, facilitating hundreds of different train/test splits to ensure result stability and robustness.

Results and Conclusion

The primary result of this work is the mikropml software itself, which is available via CRAN, GitHub, and conda. The package simplifies the user experience by automating hyperparameter tuning with reasonable default ranges. It also includes diagnostic tools, such as plot_hp_performance(), to help users verify the exhaustiveness of their parameter searches.

While mikropml automates the technical implementation of ML pipelines, it is not a replacement for domain expertise. Researchers remain responsible for the critical interpretation of results and ensuring data appropriateness for the chosen models. Future work will focus on maintaining compatibility with the evolving R ecosystem and expanding the suite of supported algorithms and preprocessing techniques.

Summary updated

BibTeX
@article{topcuoglu2021mikropml,
  author = {Begüm D. Topçuoğlu and Zena Lapp and Kelly L. Sovacool and Evan S. Snitkin and Jenna Wiens and Patrick D. Schloss},
  title = {{mikropml: User-Friendly R Package for Supervised Machine Learning Pipelines}},
  journal = {J. Open Source Softw.},
  year = {2021},
  doi = {10.21105/joss.03073},
}
Figure