install.packages("vetiver")
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:
- a tidymodels workflow (including stacks)
- caret
- mlr3
- XGBoost
- ranger
lm()
andglm()
- GAMS fit with mgcv
You can install the released version of vetiver from CRAN:
And the development version from GitHub with:
# install.packages("devtools")
::install_github("tidymodels/vetiver-r") devtools
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
= LinearRegression().fit(mtcars.drop(columns="mpg"), mtcars["mpg"]) car_mod
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)
<- vetiver_model(car_mod, "cars_mpg")
v v
── cars_mpg ─ <bundled_workflow> model for deployment
A lm regression modeling workflow using 10 features
from vetiver import VetiverModel
= VetiverModel(car_mod, model_name = "cars_mpg",
v = mtcars.drop(columns="mpg"))
prototype_data v.description
'A scikit-learn LinearRegression model'
Think of this vetiver model as a deployable model object.