calc_kl: Calculate KL divergence of features

View source: R/kl_divergence.R

calc_klR Documentation

Calculate KL divergence of features

Description

Computes Kullback-Leibler divergence between features and target vector.

Usage

calc_kl(feature, target, len_target, pos_target)

Arguments

feature

feature vector.

target

target.

len_target

length of the target vector.

pos_target

number of positive cases in the target vector.

Value

A numeric vector of length 1 representing Kullback-Leibler divergence value.

Note

Both target and features must be binary, i.e. contain only 0 and 1 values.

The function was designed to be as fast as possible subroutine of calc_criterion and might be cumbersome if directly called by a user.

References

Kullback S, Leibler RA On information and sufficiency. Annals of Mathematical Statistics 22 (1):79-86, 1951.

See Also

test_features. Kullback-Leibler divergence is calculated using KL.plugin.

Examples

tar <- sample(0L:1, 100, replace = TRUE)
feat <- sample(0L:1, 100, replace = TRUE)
calc_kl(feat, tar, 100, sum(tar))

michbur/biogram documentation built on Feb. 4, 2024, 6:38 p.m.