get_target_entropy {covalchemy}R Documentation

Get Target Entropy

Description

This function adjusts the mutual information between two categorical variables (x and y) by modifying their contingency table using simulated annealing to reach a target entropy. The function first calculates the range of possible entropy values (min and max) and checks if the target entropy lies within that range. If so, it adjusts the mutual information to reach the target entropy, either by increasing or decreasing it, depending on the initial entropy value.

Usage

get_target_entropy(x, y, target_entropy, max_n = 10000, epsilon = 0.001)

Arguments

x

A vector of categorical values representing variable x.

y

A vector of categorical values representing variable y.

target_entropy

The target entropy value to be reached.

max_n

Maximum number of iterations for the optimization process (default is 10,000).

epsilon

The tolerance value for determining if the target entropy has been reached (default is 0.001).

Value

A list containing:

Examples

set.seed(33)
df <- data.frame(
  x = sample(paste("Categ", 1:4), 10000, replace = TRUE),
  y = sample(paste("Categ", 10:4), 10000, replace = TRUE)
)
target_entropy <- 1  # Set your target entropy here
res <- get_target_entropy(df$x, df$y, target_entropy)



[Package covalchemy version 1.0.0 Index]