Description Usage Arguments Value Examples
Use scaled positions to predict preprocessing decisions.
1 | calculate_prediction_errors(positions_list, preprocessing_choices)
|
positions_list |
A list of scaled document positions generated by the 'scaling_comparison()' functions and returned from that function in the '$scaled_positions' slot in the list object. |
preprocessing_choices |
A data frame containing binary indicators of whether each preprocessing decision was applied for each dfm. This is returned by the 'factorial_preprocessing()' function as part of its output. |
A vector of mean prediction errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
# *** This function is used automatically inside of the preText() function.
# load the package
library(preText)
# load in the data
data("UK_Manifestos")
# preprocess data
preprocessed_documents <- factorial_preprocessing(
UK_Manifestos,
use_ngrams = TRUE,
infrequent_term_threshold = 0.02,
verbose = TRUE)
# scale documents
scaling_results <- scaling_comparison(preprocessed_documents$dfm_list,
dimensions = 2,
distance_method = "cosine",
verbose = TRUE)
# get prediction errors
pred_errors <- calculate_prediction_errors(
scaling_results$scaled_positions,
preprocessed_documents$choices)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.