match_instruments {harmonydata} | R Documentation |
Match Instruments Function
Description
This function takes a list of instruments, converts it to a format acceptable by the database, and matches the instruments using the 'Harmony Data API'. It returns the matched instruments.
Usage
match_instruments(
instruments,
topics = list(),
is_negate = TRUE,
clustering_algorithm = "affinity_propagation"
)
Arguments
instruments |
A list of instruments to be matched. |
topics |
A list of topics with which to tag the questions. Default is empty. |
is_negate |
A boolean indicating whether to apply negation-based preprocessing. Default is TRUE. This option addresses a common limitation in large language model (LLM) embeddings, where antonyms (e.g., "happy" and "sad") may be treated as similar due to contextual overlap.
When When The Harmony API defaults to |
clustering_algorithm |
A string value to select the clustering algorithm to use. Must be one of: "affinity_propagation", "kmeans", "deterministic", "hdbscan". Default is "affinity_propagation". |
Value
A list containing the matched instruments retrieved from the Harmony Data API. The returned object includes attributes such as the similarity matrix, identified clusters, associated cluster topics, and other relevant metadata.
Author(s)
Ulster University [cph]
Examples
instrument_A <- create_instrument_from_list(list(
"How old are you?",
"What is your gender?"
))
instrument_B <- create_instrument_from_list(list(
"Do you smoke?"
))
instruments <- list(instrument_A, instrument_B)
matched_instruments <- match_instruments(
instruments,
topics = list("anxiety", "depression")
)