Getting Started

The vetiver framework for MLOps tasks is built for data science teams using R and/or Python, with a native, fluent experience for both. It is built to be extensible, with methods that can support many kinds of models.

Installation

You can use vetiver with:

You can install the released version of vetiver from CRAN:

install.packages("vetiver")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("tidymodels/vetiver-r")

You can use vetiver with:

You can install the released version of vetiver from PyPI:

python -m pip install vetiver

And the development version from GitHub with:

python -m pip install git+https://github.com/rstudio/vetiver-python

Train a model

For this example, let’s work with data on fuel efficiency for cars to predict miles per gallon.

Let’s consider one kind of model supported by vetiver, a tidymodels workflow that encompasses both feature engineering and model estimation.

library(tidymodels)

car_mod <-
    workflow(mpg ~ ., linear_reg()) %>%
    fit(mtcars)

Let’s consider one kind of model supported by vetiver, a scikit-learn linear model.

from vetiver.data import mtcars
from sklearn.linear_model import LinearRegression

car_mod = LinearRegression().fit(mtcars.drop(columns="mpg"), mtcars["mpg"])

This car_mod object is a fitted model, with model parameters estimated using mtcars.

Create a vetiver model

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 ─ <bundled_workflow> model for deployment 
A lm regression modeling workflow using 10 features
from vetiver import VetiverModel
v = VetiverModel(car_mod, model_name = "cars_mpg", 
                 prototype_data = mtcars.drop(columns="mpg"))
v.description
'A scikit-learn LinearRegression model'

Think of this vetiver model as a deployable model object.