calculate_accuracy: Calculate Accuracy

View source: R/ClusterModeling_analysisfunctions.R

calculate_accuracyR Documentation

Calculate Accuracy

Description

Fit a model with fit_model() and calculate posterior probabilities of writership with analyze_questioned_documents() of a set of test documents where the ground truth is known. Then use calculate_accuracy() to measure the accuracy of the fitted model on the test documents. Accuracy is calculated as the average posterior probability assigned to the true writer.

Usage

calculate_accuracy(analysis)

Arguments

analysis

Writership analysis output by analyze_questioned_documents

Value

The model's accuracy on the test set as a number

Examples

# calculate the accuracy for example analysis performed on test documents and a model with 1 chain
calculate_accuracy(example_analysis_1chain)

# calculate the accuracy for example analysis performed on test documents and a model with 2 chains
calculate_accuracy(example_analysis_2chains)

## Not run: 
template_dir <- "/path/to/template_dir"
test_images_dir <- "/path/to/test_images"
analysis <- analyze_questioned_documents(
  template_dir = template_dir,
  questioned_images_dir = test_images_dir,
  model = model,
  num_cores = 2,
  num_graphs = "All",
  writer_indices = c(2, 5),
  doc_indices = c(7, 18)
)
calculate_accuracy(analysis)

## End(Not run)


handwriter documentation built on Oct. 13, 2023, 5:10 p.m.