library(tidyverse)
library(vetiver)
library(pins)
library(yardstick)
knitr::opts_chunk$set(echo = FALSE)
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.

Model details

Intended use

Important aspects/factors

Metrics

Training data & evaluation data

## EVALUATION DATA:

data(Sacramento, package = "modeldata")

## consider using a package like skimr or DataExplorer for automated 
## presentation of evaluation data characteristics

Quantitative analyses {.tabset}

## compute predictions for your evaluation data
## load packages needed for prediction:
library(parsnip)
library(workflows)
preds <- augment(v, Sacramento)

Overall model performance

preds %>%
    metrics(price, .pred)

Disaggregated model performance

preds %>%
    group_by(type) %>%
    metrics(price, .pred)

Visualize model performance

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))

Make a custom plot

preds %>%
    mutate(.resid = price - .pred) %>%
    ggplot(aes(longitude, latitude, color = .resid)) +
    geom_point(alpha = 0.8) +
    scale_color_gradient2() +
    coord_fixed()

Ethical considerations

Caveats & recommendations



tidymodels/vetiver documentation built on Oct. 15, 2024, 4:16 p.m.