reconcile_clusterings_mapping: Relabels clusters to match another cluster assignment

View source: R/reconcile_clusterings.R

reconcile_clusterings_mappingR Documentation

Relabels clusters to match another cluster assignment

Description

When forcing one-to-one, the user needs to decide what to prioritize:

  • "accuracy": optimize raw count of all observations with the same label across the two assignments

  • "precision": optimize the average percent of each alt cluster that matches the corresponding primary cluster

Usage

reconcile_clusterings_mapping(
  primary,
  alternative,
  one_to_one = TRUE,
  optimize = "accuracy"
)

Arguments

primary

A vector containing cluster labels, to be matched

alternative

Another vector containing cluster labels, to be changed

one_to_one

Boolean; should each alt cluster match only one primary cluster?

optimize

One of "accuracy" or "precision"; see description.

Details

Retains the cluster labels of the primary assignment, and relabel the alternate assignment to match as closely as possible. The user must decide whether clusters are forced to be "one-to-one"; that is, are we allowed to assign multiple labels from the alternate assignment to the same primary label?

Value

A tibble with 3 columns; primary, alt, alt_recoded

Examples


factor1 <- c("Apple", "Apple", "Carrot", "Carrot", "Banana", "Banana")
factor2 <- c("Dog", "Dog", "Cat", "Dog", "Fish", "Fish")
reconcile_clusterings_mapping(factor1, factor2)

factor1 <- c("Apple", "Apple", "Carrot", "Carrot", "Banana", "Banana")
factor2 <- c("Dog", "Dog", "Cat", "Dog", "Fish", "Parrot")
reconcile_clusterings_mapping(factor1, factor2, one_to_one = FALSE)


tidyclust documentation built on July 3, 2024, 1:06 a.m.