03:00
Intro to MLOps with vetiver
Welcome!
Wi-Fi network name
Posit Conf 2024
Wi-Fi password
conf2024
You have intermediate R or Python knowledge
You can read data from CSV and other flat files, transform and reshape data, and make a wide variety of graphs
You can fit a model to data with your modeling framework of choice wide variety of graphs
You have exposure to basic modeling and machine learning practice
You do not need expert familiarity with advanced ML or MLOps topics
🧡 “I’m stuck and need help!”
💙 “I finished the exercise”
If you prefer, post on GitHub Discussions for help:
Optional
Post an introduction on GitHub Discussions: https://github.com/posit-conf-2024/vetiver/discussions
Illustration credit: https://vas3k.com/blog/machine_learning/
Illustration credit: Chapter 1 of Tidy Modeling with R
a set of practices to deploy and maintain machine learning models in production reliably and efficiently
Vetiver, the oil of tranquility, is used as a stabilizing ingredient in perfumery to preserve more volatile fragrances.
you can operationalize that model!
you likely should be the one to operationalize that model!
Activity
What language does your team use for machine learning?
What kinds of models do you commonly use?
Have you ever deployed a model?
03:00
class-work
in the vetiver
directoryActivity
Log in to Posit Workbench at https://vetiver.posit.team
Start a new session, either RStudio or VS Code.
We recommend that you open the vetiver
directory as a project (RStudio) or workspace (VS Code).
In your new session, open the folder class-work
in the vetiver
directory, and choose the first Quarto file!
05:00
mlr3data::kc_housing
N = 14633
price
bedrooms
, bathrooms
, sqft_living
, and yr_built
are numeric predictorswaterfront
could be a logical (or maybe nominal) predictordate
could be a date predictorprice | date | bedrooms | bathrooms | sqft_living | yr_built | waterfront | lat | long |
---|---|---|---|---|---|---|---|---|
350000 | 2014-09-11 | 2 | 1.50 | 1070 | 2003 | FALSE | 47.6761 | -122.300 |
250275 | 2014-06-17 | 2 | 1.00 | 790 | 1942 | FALSE | 47.4413 | -122.349 |
712198 | 2014-05-04 | 4 | 2.50 | 2450 | 2013 | FALSE | 47.7048 | -122.113 |
283200 | 2014-05-26 | 4 | 2.50 | 1982 | 2004 | FALSE | 47.3636 | -122.192 |
435000 | 2014-11-16 | 5 | 1.00 | 2170 | 1930 | FALSE | 47.7555 | -122.204 |
299950 | 2014-11-17 | 3 | 2.50 | 1570 | 2005 | FALSE | 47.7456 | -121.984 |
368500 | 2014-12-10 | 5 | 2.75 | 2530 | 1992 | FALSE | 47.4683 | -122.263 |
540000 | 2014-10-06 | 5 | 1.50 | 1940 | 1940 | FALSE | 47.7213 | -122.310 |
299950 | 2014-10-27 | 2 | 1.75 | 1460 | 1983 | FALSE | 47.4048 | -122.178 |
299880 | 2014-07-08 | 3 | 2.50 | 1460 | 2000 | FALSE | 47.5440 | -122.296 |
545000 | 2014-07-09 | 2 | 2.00 | 2930 | 1980 | FALSE | 47.4025 | -122.463 |
615000 | 2014-07-21 | 3 | 3.25 | 1470 | 2003 | FALSE | 47.6516 | -122.337 |
680000 | 2014-06-09 | 3 | 1.75 | 1760 | 1960 | FALSE | 47.5355 | -122.390 |
512000 | 2014-08-07 | 4 | 2.50 | 2550 | 1996 | FALSE | 47.4836 | -122.136 |
452000 | 2014-06-05 | 2 | 1.75 | 1740 | 1946 | FALSE | 47.6971 | -122.282 |
Activity
Explore the housing
data on your own!
price
?sqft_living
?Share something you noticed with your neighbor.
08:00
Or your model of choice!
Activity
Split your data in training and testing.
Fit a model to your training data.
05:00
Activity
Create your vetiver model object.
Check out the default description
that is created, and try out using a custom description.
Show your custom description to your neighbor.
05:00
The pins package publishes data, models, and other R and Python objects, making it easy to share them across projects and with your colleagues.
You can pin objects to a variety of pin boards, including:
Learn about the pins package for Python and for R
from pins import board_temp
from vetiver import vetiver_pin_write
board = board_temp(allow_pickle_read = True)
vetiver_pin_write(board, v)
#> Model Cards provide a framework for transparent, responsible reporting.
#> Use the vetiver `.qmd` Quarto template as a place to start,
#> with vetiver.model_card()
#> Writing pin:
#> Name: 'seattle-housing-python'
#> Version: 20240812T004027Z-258d7
library(pins)
board <- board_temp()
board |> vetiver_pin_write(v)
#> Creating new version '20240812T004027Z-f27f6'
#> Writing to pin 'seattle-housing-rstats'
#>
#> Create a Model Card for your published model
#> • Model Cards provide a framework for transparent, responsible reporting
#> • Use the vetiver `.Rmd` template as a place to start
Activity
Pin your vetiver model object to a temporary board.
Retrieve the model metadata with pin_meta()
.
05:00
from pins import board_connect
from vetiver import VetiverModel, vetiver_pin_write
from dotenv import load_dotenv
load_dotenv()
board = board_connect(allow_pickle_read = True)
v = VetiverModel(housing_fit, "isabel.zimmerman/seattle-housing-python", prototype_data = X_train)
vetiver_pin_write(board, v)
Activity
Either:
.Renviron
for R or .env
for Python).Create a new vetiver model object that includes your username, and pin this vetiver model to your Connect instance.
Visit your pin’s homepage on Connect.
Train your model again, using a different ML algorithm (decision tree or random forest are good options).
Write this new version of your model to the same pin, and see what versions you have with pin_versions
.
10:00