R-Ladies Rome
2023-01-24
you can operationalize that model!
you likely should operationalize that model!
glimpse(housing_prices)
#> Rows: 21,613
#> Columns: 6
#> $ price <dbl> 221900, 538000, 180000, 604000, 510000, 1225000, 257500, 2β¦
#> $ bedrooms <int> 3, 3, 2, 4, 3, 4, 3, 3, 3, 3, 3, 2, 3, 3, 5, 4, 3, 4, 2, 3β¦
#> $ bathrooms <dbl> 1.00, 2.25, 1.00, 3.00, 2.00, 4.50, 2.25, 1.50, 1.00, 2.50β¦
#> $ sqft_living <int> 1180, 2570, 770, 1960, 1680, 5420, 1715, 1060, 1780, 1890,β¦
#> $ yr_built <int> 1955, 1951, 1933, 1965, 1987, 2001, 1995, 1963, 1960, 2003β¦
#> $ date <dttm> 2014-10-13, 2014-12-09, 2015-02-25, 2014-12-09, 2015-02-1β¦
housing_wf
#> ββ Workflow [trained] ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Preprocessor: Formula
#> Model: rand_forest()
#>
#> ββ Preprocessor ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> price ~ bedrooms + bathrooms + sqft_living + yr_built
#>
#> ββ Model βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Ranger result
#>
#> Call:
#> ranger::ranger(x = maybe_data_frame(x), y = y, num.trees = ~200, num.threads = 1, verbose = FALSE, seed = sample.int(10^5, 1))
#>
#> Type: Regression
#> Number of trees: 200
#> Sample size: 11756
#> Number of independent variables: 4
#> Mtry: 2
#> Target node size: 5
#> Variable importance mode: none
#> Splitrule: variance
#> OOB prediction error (MSE): 58388723094
#> R squared (OOB): 0.5796486
a set of practices to deploy and maintain machine learning models in production reliably and efficiently
β managing change in models
π― putting models in REST APIs
π tracking model performance
library(plumber)
pr() %>%
vetiver_api(v)
#> # Plumber router with 2 endpoints, 4 filters, and 1 sub-router.
#> # Use `pr_run()` on this object to start the API.
#> βββ[queryString]
#> βββ[body]
#> βββ[cookieParser]
#> βββ[sharedSecret]
#> βββ/logo
#> β β # Plumber static router serving from directory: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/vetiver
#> βββ/ping (GET)
#> βββ/predict (POST)
## next pipe to `pr_run()` for local API
Positβs pro products, like Connect: vetiver_deploy_rsconnect()
A public or private cloud, using Docker: vetiver_prepare_docker()
new_metrics <-
augment(v, housing_val) %>%
vetiver_compute_metrics(date, "week", price, .pred)
vetiver_pin_metrics(
board,
new_metrics,
"julia.silge/housing-metrics",
overwrite = TRUE
)
#> # A tibble: 90 Γ 5
#> .index .n .metric .estimator .estimate
#> <dttm> <int> <chr> <chr> <dbl>
#> 1 2014-11-02 00:00:00 224 rmse standard 202771.
#> 2 2014-11-02 00:00:00 224 rsq standard 0.426
#> 3 2014-11-02 00:00:00 224 mae standard 139488.
#> 4 2014-11-06 00:00:00 373 rmse standard 222177.
#> 5 2014-11-06 00:00:00 373 rsq standard 0.554
#> 6 2014-11-06 00:00:00 373 mae standard 150809.
#> 7 2014-11-13 00:00:00 427 rmse standard 255889.
#> 8 2014-11-13 00:00:00 427 rsq standard 0.554
#> 9 2014-11-13 00:00:00 427 mae standard 148054.
#> 10 2014-11-20 00:00:00 376 rmse standard 251007.
#> # β¦ with 80 more rows
Version
Deploy
Monitor
your R and Python models
a set of practices to deploy and maintain machine learning models in production reliably and efficiently
Documentation at https://vetiver.rstudio.com/
Isabel Zimmermanβs talk from rstudio::conf() 2022 on Demystifying MLOps
Webinar by Julia and Isabel for Posit Enterprise Meetup
Juliaβs recent screencast on deploying a model with Docker
End-to-end demos from Posit Solution Engineering in R and Python
Sketch courtesy of the Smithsonian Institute