plot_predictor_words: Plot Predictor Words

Description Usage Arguments Value See Also Examples

View source: R/plot_predictor_words.R

Description

This function plots predictive words from the results of the assess_models function

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_predictor_words(
  ...,
  topX,
  colors = c("blue", "orange"),
  plot_titles,
  model_names,
  xaxis_range,
  standard_xaxis = TRUE,
  flip_graphs = FALSE,
  print_individual = TRUE,
  print_summary = TRUE
)

Arguments

...

Output(s) of the language_model function

topX

The number of most-predictive words to plot

colors

A two-element vector containing the colors of the plotted bars. Defaults to c("blue", "orange")

plot_titles

A vector of titles for the plots

model_names

A vector of names for the individual models

xaxis_range

A maximum value for the x-axis

standard_xaxis

If TRUE, the x-axis on all graphs will be the same. If FALSE, it will adjust to fit each individual graph. Defaults to TRUE.

flip_graphs

Flips the graphs horizontally. Defaults to FALSE (low-value outcome variable on the left, high-value outcome variable on the right)

print_individual

If TRUE, prints an individual graph for each model. Defaults to TRUE.

print_summary

If TRUE, prints a summary graph with all models. Defaults to TRUE.

Value

Nothing (this function plots a series of graphs)

See Also

language_model

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
strong_movie_review_data$cleanText = clean_text(strong_movie_review_data$text)
mild_movie_review_data$cleanText = clean_text(mild_movie_review_data$text)

# Using language to predict "Positive" vs. "Negative" reviews
# Only for strong reviews (ratings of 1 or 10)
movie_model_strong = language_model(strong_movie_review_data,
                                     outcome = "valence",
                                     outcomeType = "binary",
                                     text = "cleanText",
                                     progressBar = FALSE)

# Using language to predict "Positive" vs. "Negative" reviews
# Only for mild reviews (ratings of 4 or 7)
movie_model_mild = language_model(mild_movie_review_data,
                                     outcome = "valence",
                                     outcomeType = "binary",
                                     text = "cleanText",
                                     progressBar = FALSE)

# Analyze ROC curves
plot_predictor_words(movie_model_strong, movie_model_mild)

nlanderson9/languagePredictR documentation built on June 10, 2021, 11 a.m.