get_fscore: Calculate F-score, Precision, Recall, and Specificity for a...

View source: R/fitting.R

get_fscoreR Documentation

Calculate F-score, Precision, Recall, and Specificity for a Knowledge Matrix at a Given Threshold

Description

This function calculates the F-score, precision, recall, and specificity for a given knowledge matrix at a specified threshold. It uses the concept of true positives, false positives, and false negatives, determined from the knowledge matrix and an optional gold lexicon. The function is useful for evaluating the performance of a model in terms of its ability to correctly identify associations between words and referents.

Usage

get_fscore(thresh, mat, fscore_only = T, gold_lexicon = c(), verbose = F)

Arguments

thresh

A numeric value representing the threshold for considering an association between a word and a referent as positive.

mat

A matrix representing the knowledge matrix with words as rows and referents as columns.

fscore_only

Logical; if TRUE, only the F-score is returned. If FALSE, a data frame with precision, recall, specificity, and F-score for each threshold is returned.

gold_lexicon

Optional; a data frame or list where each row/element represents a word-object pair in the gold lexicon. If provided, it is used to calculate true positives, false positives, and false negatives.

verbose

Logical; if TRUE, additional details about true positives, false positives, and false negatives are printed.

Value

If fscore_only is TRUE, returns a single numeric value representing the F-score. If fscore_only is FALSE, returns a tibble (data frame) with columns for threshold, precision, recall, specificity, and F-score at each threshold.


kachergis/XSLmodels documentation built on Feb. 25, 2024, 10:43 p.m.