calculate_prediction_errors: Calculate mean prediction error for preprocessing decisions.

Description Usage Arguments Value Examples

View source: R/calculate_prediction_errors.R

Description

Use scaled positions to predict preprocessing decisions.

Usage

1
calculate_prediction_errors(positions_list, preprocessing_choices)

Arguments

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.

Value

A vector of mean prediction errors.

Examples

 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)

preText documentation built on Jan. 13, 2018, 1:05 a.m.