Skip to content

Class KaufmanEfficiency

  • Jump right in for a hands-on Open In Colab

Import

from NitroFE import KaufmanEfficiency

KaufmanEfficiency

It is calculated by dividing the net change in price movement over 'lookback_period' periods, by the sum of the absolute net changes over the same 'lookback_period' periods.

For your training/initial fit phase (very first fit) use fit_first=True, and for any production/test implementation pass fit_first=False

\[ Kaufman\_Efficiency[t]= \frac{|dataframe[t]-dataframe[t-lookback\_period]|}{\sum_{i=t-lookback\_period+1}^{t}|dataframe[i]-dataframe[i-1]|} \]

Methods

__init__(self, lookback_period=4, min_periods=None) special

Parameters:

Name Type Description Default
lookback_period int

Size of the rolling window for lookback, by default 4

4
min_periods int

Minimum number of observations in window required to have a value, by default None

None
Source code in nitrofe\time_based_features\indicator_features\_kaufmanefficiency.py
def __init__(self, lookback_period: int = 4, min_periods: int = None):
    """
    Parameters
    ----------
    lookback_period : int, optional
        Size of the rolling window for lookback, by default 4
    min_periods : int, optional
        Minimum number of observations in window required to have a value, by default None
    """
    self.lookback_period = lookback_period
    self.min_periods = min_periods

fit(self, dataframe, first_fit=True)

For your training/initial fit phase (very first fit) use fit_first=True, and for any production/test implementation pass fit_first=False

Parameters:

Name Type Description Default
dataframe Union[pandas.core.frame.DataFrame, pandas.core.series.Series]

dataframe containing column values to create feature over

required
first_fit bool

Indicator features require past values for calculation. Use True, when calculating for training data (very first fit) Use False, when calculating for subsequent testing/production data { in which case the values, which were saved during the last phase, will be utilized for calculation }, by default True

True
Source code in nitrofe\time_based_features\indicator_features\_kaufmanefficiency.py
def fit(self, dataframe: Union[pd.DataFrame, pd.Series], first_fit: bool = True):
    """
    For your training/initial fit phase (very first fit) use fit_first=True, and for any production/test implementation pass fit_first=False

    Parameters
    ----------
    dataframe : Union[pd.DataFrame, pd.Series]
        dataframe containing column values to create feature over
    first_fit : bool, optional
        Indicator features require past values for calculation.
        Use True, when calculating for training data (very first fit)
        Use False, when calculating for subsequent testing/production data { in which case the values, which
        were saved during the last phase, will be utilized for calculation }, by default True
    """

    if first_fit:
        self._kaufman_efficiency_object = weighted_window_features()

    _kaufman_efficiency = (
        self._kaufman_efficiency_object._template_feature_calculation(
            function_name="kaufman_efficiency",
            win_function=_identity_window,
            first_fit=first_fit,
            dataframe=dataframe,
            window=self.lookback_period,
            min_periods=self.min_periods,
            symmetric=None,
            operation=self._calculate_kaufman_efficiency,
            operation_args=(),
        )
    )

    return _kaufman_efficiency

References