library(vetiver) library(pins) model_board <- board_temp() cars_lm <- lm(mpg ~ ., data = mtcars) v <- vetiver_model(cars_lm, "cars_linear") options(rlib_message_verbosity = 'quiet') vetiver_pin_write(model_board, v)
library(tidyverse) library(vetiver) library(pins) library(yardstick) knitr::opts_chunk$set(echo = FALSE) # create a board manually # https://blog.sellorm.com/2022/06/25/5-tips-for-using-pins-with-r/ description <- "The data was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models)." metadata <- list(owner = "sellorm", deptartment = "R&D", r.version.string = version$version.string, url = "https://blog.sellorm.com") # package versions? / computer hostname # data status, eg.not-validated # data infoeg. location / demographic / project related info b_tmp <- board_temp() # v board_local() b_tmp %>% pin_write(x = mtcars, name = "motor_trend_cars", title = "Motor Trend Car Road Tests", metadata = metadata, description = description) %>% # use httr’s with_verbose() for more connection details httr::with_verbose() -> brd_lcl pin_meta(board = brd_lcl) # Get the pin b_tmp %>% pin_list() nm <- b_tmp %>% pin_list() %>% head(1) b_tmp %>% pin_read(nm) %>% head() # Get its metadata b_tmp %>% pin_meta(nm) # Get path to underlying data b_tmp %>% pin_download(nm) v <- vetiver_pin_read(params$board, params$name, version = params$version) v_meta <- pin_meta(params$board, params$name) theme_set(theme_light())
A model card provides brief, transparent, responsible reporting for a trained machine learning model.
r cli::pluralize("{v$description} using {ncol(v$ptype)} feature{?s}")
r v$metadata$version
of this model was published at r v_meta$created
```r glimpse(v$ptype)
- The evaluation dataset used in this model card is ... - We chose this evaluation data because ... ```r ## EVALUATION DATA: data(Sacramento, package = "modeldata") ## consider using a package like skimr or DataExplorer for automated ## presentation of evaluation data characteristics
## compute predictions for your evaluation data ## `handler_startup` is designed to get the R process ready to make predictions suppressPackageStartupMessages(handler_startup(v)) preds <- augment(v, Sacramento)
preds %>% metrics(price, .pred)
preds %>% group_by(type) %>% metrics(price, .pred)
preds %>% ggplot(aes(price, .pred, color = type)) + geom_abline(slope = 1, lty = 2, color = "gray60", size = 1.2) + geom_point(alpha = 0.5, show.legend = FALSE) + facet_wrap(vars(type))
preds %>% mutate(.resid = price - .pred) %>% ggplot(aes(longitude, latitude, color = .resid)) + geom_point(alpha = 0.8) + scale_color_gradient2() + coord_fixed()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.