We are thrilled to announce the release of vetiver, a framework for MLOps tasks in R and Python! The goal of vetiver is to provide fluent tooling to version, share, deploy, and monitor a trained model. If you like perfume or candles, you may recognize this name; vetiver, also known as the “oil of tranquility”, is used as a stabilizing ingredient in perfumery to preserve more volatile fragrances.
You can install the released version of vetiver for R from CRAN:
You can install the released version of vetiver for Python from PyPI:
pip install vetiver
We are sharing more about what vetiver is and how it works over on the RStudio blog so check that out, but we want to share here as well!
For this example, let’s work with data on everyone’s favorite dataset on fuel efficiency for cars to predict miles per gallon. In R, we can train a decision tree model to predict miles per gallon using a tidymodels workflow:
library(tidymodels) car_mod <- workflow(mpg ~ ., decision_tree(mode = "regression")) %>% fit(mtcars)
In Python, we can train the same kind of model using scikit-learn:
from vetiver.data import mtcars from sklearn import tree car_mod = tree.DecisionTreeRegressor().fit(mtcars, mtcars["mpg"])
For both R and Python, the
car_mod object is a fitted model, with parameters estimated using our training data
We can create a
vetiver_model() in R or
VetiverModel() in Python from the trained model; a vetiver model object collects the information needed to store, version, and deploy a trained model.
library(vetiver) v <- vetiver_model(car_mod, "cars_mpg") v #> #> ── cars_mpg ─ <butchered_workflow> model for deployment #> A rpart regression modeling workflow using 10 features
from vetiver import VetiverModel v = VetiverModel(car_mod, model_name = "cars_mpg", save_ptype = True, ptype_data = mtcars) v.description #> "Scikit-learn <class 'sklearn.tree._classes.DecisionTreeRegressor'> model"
See our documentation for how to use these deployable model objects and:
Be sure to also read more on the RStudio blog.
We’d like to extend our thanks to all of the contributors who helped make these initial releases of vetiver for R and Python possible!