Highlight words which explains a prediction.

plot_text_explanations(explanations, ...)

Arguments

explanations

object returned by the lime.character function.

...

parameters passed to htmlwidgets::sizingPolicy()

See also

Other explanation plots: plot_explanations(), plot_features()

Examples

# We load a precalculated explanation set based on the procedure in the ?lime
# examples
explanations <- .load_text_example()

# We see that the explanations are in the expected format
print(explanations)
#>             model_type case label label_prob  model_r2 model_intercept feature
#> in      classification    1     1  0.6418385 0.9879563       0.3321225      in
#> we      classification    1     1  0.6418385 0.9879563       0.3321225      we
#> in1     classification    2     1  0.8022363 0.8551634       0.3210651      in
#> We      classification    2     1  0.8022363 0.8551634       0.3210651      We
#> those   classification    3     0  0.5432571 0.8868849       0.6909923   those
#> we1     classification    3     0  0.5432571 0.8868849       0.6909923      we
#> in2     classification    4     1  0.8719526 0.6569822       0.4941383      in
#> Section classification    4     1  0.8719526 0.6569822       0.4941383 Section
#> of      classification    5     1  0.7316587 0.3242455       0.3535088      of
#> our     classification    5     1  0.7316587 0.3242455       0.3535088     our
#>         feature_value feature_weight feature_desc
#> in                 in    -0.03694821           in
#> we                 we     0.34825310           we
#> in1                in    -0.01236806           in
#> We                 We     0.42784027           We
#> those           those     0.07281582        those
#> we1                we    -0.26484904           we
#> in2                in     0.01006400           in
#> Section       Section     0.33433000      Section
#> of                 of     0.01377475           of
#> our               our     0.28981386          our
#>                                                                                                                                                                                                                                                                      data
#> in                                                                                                                                                                                                                   we validate them in section  and conclude in section
#> we                                                                                                                                                                                                                   we validate them in section  and conclude in section
#> in1                                                            We developed a two-level machine learning approach that in the first level considers two different properties important for protein-protein binding derived from structural models of V3 and V3 sequences.
#> We                                                             We developed a two-level machine learning approach that in the first level considers two different properties important for protein-protein binding derived from structural models of V3 and V3 sequences.
#> those                                   specifically  we hypothesize that the judgments of those individuals high in this trait will be more influenced by previously presented anchors whereas those individuals low in this trait will be less influenced by the anchor
#> we1                                     specifically  we hypothesize that the judgments of those individuals high in this trait will be more influenced by previously presented anchors whereas those individuals low in this trait will be less influenced by the anchor
#> in2                                                                                                                                                                                                      Finally, in Section  we discuss the results and give conclusions
#> Section                                                                                                                                                                                                  Finally, in Section  we discuss the results and give conclusions
#> of      We also illustrate the application of our  SYMBOL -mixing generalization bounds to general classes of learning algorithms, including Support Vector Regression (SVR)  CITATION , Kernel Ridge Regression  CITATION , and Support Vector Machines (SVMs)  CITATION
#> our     We also illustrate the application of our  SYMBOL -mixing generalization bounds to general classes of learning algorithms, including Support Vector Regression (SVR)  CITATION , Kernel Ridge Regression  CITATION , and Support Vector Machines (SVMs)  CITATION
#>                   prediction
#> in      0.6418385, 0.3581615
#> we      0.6418385, 0.3581615
#> in1     0.8022363, 0.1977637
#> We      0.8022363, 0.1977637
#> those   0.4567429, 0.5432571
#> we1     0.4567429, 0.5432571
#> in2     0.8719526, 0.1280474
#> Section 0.8719526, 0.1280474
#> of      0.7316587, 0.2683413
#> our     0.7316587, 0.2683413

# We can now get the explanations in the context of the input text
plot_text_explanations(explanations)