mlfinlab.microstructural_features.entropy
Entropy calculation module (Shannon, Lempel-Ziv, Plug-In, Konto)
Module Contents
Functions
|
Function returns the Shannon entropy of an encoded message (encoding should consist |
|
Function returns the Lempel-Ziv entropy of an encoded message (encoding should consist |
|
Function returns the Plug-In entropy of an encoded message (encoding should consist |
|
Function returns the Kontoyiannis entropy of an encoded message (encoding should consist |
- get_shannon_entropy(message: str | pandas.Series) float
-
Function returns the Shannon entropy of an encoded message (encoding should consist of exclusively 1s and 0s).
- Parameters:
-
message – (str or pd.Series) Encoded message.
- Returns:
-
(float) Shannon entropy.
- get_lempel_ziv_entropy(message: str | pandas.Series) float
-
Function returns the Lempel-Ziv entropy of an encoded message (encoding should consist of exclusively 1s and 0s).
- Parameters:
-
message – (str or pd.Series) Encoded message.
- Returns:
-
(float) Lempel-Ziv entropy.
- get_plug_in_entropy(message: str | pandas.Series, word_length: int = 1) float
-
Function returns the Plug-In entropy of an encoded message (encoding should consist of exclusively 1s and 0s).
A key component of the algorithm is specifying a constant that represents the average word length in the encoded message. For our purposes, this average will always be 1, since each trade classification is represented by a single digit.
- Parameters:
-
-
message – (Option: str/pd.Series) Encoded message.
-
word_length – (int) Average word length.
-
- Returns:
-
(float) Plug-in entropy.
- get_konto_entropy(message: str | pandas.Series, window_size: int | None = None) float
-
Function returns the Kontoyiannis entropy of an encoded message (encoding should consist of exclusively 1s and 0s).
A fixed window size can be specified for the calculation of the Kontoyiannis entropy. If no window size is specified then an expanding window is used.
- Parameters:
-
-
message – (Option: str/pd.Series) Encoded message.
-
window_size – (int) Window length to be used.
-
- Returns:
-
(float) Kontoyiannis entropy.