mlchem.ml.feature_selection.filters.shannon_entropy

shannon_entropy(vector: ndarray) float

Calculate Shannon entropy of a vector.

This function computes the entropy based on the frequency of unique elements in the input array.

Parameters:

vector (np.ndarray) – Input array for which Shannon entropy is calculated.

Returns:

Shannon entropy of the input vector.

Return type:

float

Examples

>>> shannon_entropy(np.array([1, 1, 2, 2, 3, 3]))