caret.explainer 0.0.6
  • Reference
  • Articles
    • Introduction

    Introduction

    01-introduction.Rmd

    Setup

    Get the Data

    titanic %>% dplyr::glimpse()
    #> Observations: 2,207
    #> Variables: 8
    #> $ gender   <fct> male, male, male, female, female, male, male, female, male, …
    #> $ age      <dbl> 42.0000000, 13.0000000, 16.0000000, 39.0000000, 16.0000000, …
    #> $ class    <fct> 3rd, 3rd, 3rd, 3rd, 3rd, 3rd, 2nd, 2nd, 3rd, 3rd, 3rd, 3rd, …
    #> $ embarked <fct> Southampton, Southampton, Southampton, Southampton, Southamp…
    #> $ fare     <dbl> 7.1100, 20.0500, 20.0500, 20.0500, 7.1300, 7.1300, 24.0000, …
    #> $ sibsp    <dbl> 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, …
    #> $ parch    <dbl> 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, …
    #> $ survived <fct> Perished, Perished, Perished, Survived, Survived, Survived, …

    Build a caret model

    caret_model <- caret::train(
        survived ~ ., 
        data = titanic, 
        method = "glm", 
        trControl = caret::trainControl(method = "none", classProbs = TRUE)
    )

    Explain a caret model

    explanations <- caret.explainer::instantiate_explainer(caret_model)

    Instance Level Explanation

    Break down plot

    set.seed(1540)
    new_observation <- titanic %>% dplyr::sample_n(1)
    explanations$plot_break_down(new_observation = new_observation)

    Contents

    • Setup
    • Explain a caret model

    Developed by Harel Lustiger.

    Site built with pkgdown 1.4.1.