Making it easier to build stable, trustworthy data-science pipelines based on the PCS framework.
A library for making stability analysis simple. Easily evaluate the effect of judgment calls to your data-science pipeline (e.g. choice of imputation strategy)!
Why use vflow?
Using vflows simple wrappers facilitates many best practices for data science, as laid out in the predictability, computability, and stability (PCS) framework for veridical data science. The goal of vflow is to easily enable data science pipelines that follow PCS by providing intuitive low-code syntax, efficient and flexible computational backends via Ray, and well-documented, reproducible experimentation via MLflow.
| Computation | Reproducibility | Prediction | Stability | | ----------- | --------------- | ---------- | --------- | | Automatic parallelization and caching throughout the pipeline | Automatic experiment tracking and saving | Filter the pipeline by training and validation performance | Replace a single function (e.g. preprocessing) with a set of functions and easily assess the stability of downstream results |
Here we show a simple example of an entire data-science pipeline with several perturbations (e.g. different data subsamples, models, and metrics) written simply using vflow.
import sklearn
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracyscore, balancedaccuracy_score
from sklearn.modelselection import traintest_split
from sklearn.tree import DecisionTreeClassifier
from vflow import Vset, init_args
initialize data
X, y = make_classification()
Xtrain, Xtest, ytrain, ytest = init_args(
traintestsplit(X, y),
names=["Xtrain", "Xtest", "ytrain", "ytest"], # optionally name the args
)
subsample data
subsamplingfuncs = [sklearn.utils.resample for in range(3)]
subsampling_set = Vset(
name="subsampling", vfuncs=subsamplingfuncs, outputmatching=True
)
Xtrains, ytrains = subsamplingset(Xtrain, y_train)
fit models
models = [LogisticRegression(), DecisionTreeClassifier()]
modelingset = Vset(name="modeling", vfuncs=models, vfunckeys=["LR", "DT"])
modelingset.fit(Xtrains, y_trains)
predstest = modelingset.predict(X_test)
get metrics
binarymetricsset = Vset(
name="binary_metrics",
vfuncs=[accuracyscore, balancedaccuracy_score],
vfunckeys=["Acc", "BalAcc"],
)
binarymetrics = binarymetricsset.evaluate(predstest, y_test)
Once we've written this pipeline, we can easily measure the stability of metrics (e.g. "Accuracy") to our choice of subsampling or model.
Documentation
See the docs for reference on the API
Notebook examples>
Note that some of these require more dependencies than just those required for
>vflow. To install all, runpip install vflow[nb].
Synthetic classification>
Enhancer genomics>
fMRI voxel prediction>
Fashion mnist classification>
Feature importance stability>
Clinical decision rule vetting
Installation
Stable version
pip install vflow
Development version (unstable)
pip install vflow@git+https://github.com/Yu-Group/veridical-flow
References
- interface: easily build on scikit-learn and dvc (data version control)
- computation: integration with ray and caching with joblib
- tracking: mlflow
- pull requests very welcome! (see contributing.md)
@software{duncan2020vflow,
author = {Duncan, James and Kapoor, Rush and Agarwal, Abhineet and Singh, Chandan and Yu, Bin},
doi = {10.21105/joss.03895},
month = {1},
title = {{VeridicalFlow: a Python package for building trustworthy data science pipelines with PCS}},
url = {https://doi.org/10.21105/joss.03895},
year = {2022}
}