weighted window features
Class weighted_window_features
Import
from NitroFE import weighted_window_features
caluclate_barthann_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create Bartlett–Hann weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which Bartlett–Hann weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_barthann_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create Bartlett–Hann weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which Bartlett–Hann weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_barthann_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_barthann_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_bartlett_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create bartlett weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which bartlett weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_bartlett_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create bartlett weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which bartlett weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_bartlett_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_bartlett_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_blackman_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create blackman weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which blackman weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_blackman_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create blackman weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which blackman weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_blackman_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_blackman_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_blackmanharris_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create blackman-harris weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which blackman-harris weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_blackmanharris_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create blackman-harris weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which blackman-harris weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_blackmanharris_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_blackmanharris_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_bohman_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create bohman weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which bohman weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_bohman_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create bohman weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which bohman weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_bohman_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_bohman_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_cosine_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create cosine weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which cosine weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_cosine_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create cosine weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which cosine weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_cosine_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_cosine_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_equal_feature(self, dataframe, first_fit=True, window=3, min_periods=1, operation=None, operation_args=())
Create equally weighted rolling window feature
All elemets are weighted equally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which equally weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_equal_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create equally weighted rolling window feature
All elemets are weighted equally
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which equally weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_equal_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_equal_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=None,
operation=operation,
operation_args=operation_args,
)
caluclate_exponential_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=(), center=None, tau=1)
Create exponential weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which exponential weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
center |
float |
Parameter defining the center location of the window function. The default value if not given is center = (M-1) / 2. This parameter must take its default value for symmetric windows. |
None |
tau |
float |
Parameter defining the decay. For center = 0 use tau = -(M-1) / ln(x) if x is the fraction of the window remaining at the end, by default 1 |
1 |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_exponential_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
center: float = None,
tau: float = 1,
):
"""
Create exponential weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which exponential weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
center : float , optional
Parameter defining the center location of the window function.
The default value if not given is center = (M-1) / 2. This parameter must take its default value for symmetric windows.
tau : float , optional
Parameter defining the decay. For center = 0 use tau = -(M-1) / ln(x) if x is the fraction of the window remaining at the end, by default 1
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_exponential_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_exponential_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
center=center,
tau=tau,
)
caluclate_flattop_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create flattop weighted rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_flattop_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop weighted rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_flattop_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_flattop_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_gaussian_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=(), std=1)
Create flattop gaussian rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop gaussian rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
std |
float |
The standard deviation, sigma. |
1 |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_gaussian_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
std: float = 1,
):
"""
Create flattop gaussian rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop gaussian rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
std : float, optional
The standard deviation, sigma.
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_gaussian_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_gaussian_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
std=std,
)
caluclate_hamming_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create flattop hamming rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop hamming rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_hamming_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop hamming rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop hamming rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_hamming_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_hamming_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_hann_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create flattop hann rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop hann rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_hann_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop hann rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop hann rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_hann_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_hann_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_kaiser_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, beta=7, operation=None, operation_args=())
Create flattop kaiser rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop kaiser rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
beta |
float |
Shape parameter, determines trade-off between main-lobe width and side lobe level, by default 7 As beta gets large, the window narrows. |
7 |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_kaiser_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
beta: float = 7,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop kaiser rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop kaiser rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
beta : float, optional
Shape parameter, determines trade-off between main-lobe width and side lobe level, by default 7
As beta gets large, the window narrows.
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_kaiser_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_kaiser_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
beta=beta,
)
caluclate_parzen_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create flattop parzen rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop parzen rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_parzen_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop parzen rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop parzen rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_parzen_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_parzen_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_triang_feature(self, dataframe, first_fit=True, window=3, min_periods=1, symmetric=False, operation=None, operation_args=())
Create flattop triang rolling window feature
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over which flattop triang rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
symmetric |
bool |
When True , generates a symmetric window, for use in filter design. When False, generates a periodic window, for use in spectral analysis, by default False |
False |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.mean is used |
None |
operation_args |
tuple |
additional agrument values to be sent for operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_triang_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
symmetric: bool = False,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create flattop triang rolling window feature
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over which flattop triang rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
symmetric : bool, optional
When True , generates a symmetric window, for use in filter design. When False,
generates a periodic window, for use in spectral analysis, by default False
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.mean is used
operation_args : tuple, optional
additional agrument values to be sent for operation function
"""
operation = np.mean if operation == None else operation
_function_name = "caluclate_triang_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_triang_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=symmetric,
operation=operation,
operation_args=operation_args,
)
caluclate_weighted_moving_window_feature(self, dataframe, first_fit=True, window=3, min_periods=1, operation=None, operation_args=())
Create weighted moving window feature
A weighted average is an average that has multiplying factors to give different weights to data at different positions in the sample window. Mathematically, the weighted moving average is the convolution of the data with a fixed weighting function. In an n-day WMA the latest day has weight n, the second latest n-1, etc, down to one
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe |
Union[pandas.core.frame.DataFrame, pandas.core.series.Series] |
dataframe/series over weighted rolling window feature is to be constructed |
required |
first_fit |
bool |
Rolling features require past "window" number of values for calculation. Use True, when calculating for training data { in which case last "window" number of values will be saved } Use False, when calculating for testing/production data { in which case the, last "window" number of values, which are were saved during the last phase, will be utilized for calculation }, by default True |
True |
window |
int |
Size of the rolling window, by default 3 |
3 |
min_periods |
int |
Minimum number of observations in window required to have a value, by default 1 |
1 |
operation |
Callable |
operation to perform over the weighted rolling window values, when None is passed, np.sum is used |
None |
operation_args |
tuple |
additional agrument values to be sent for self defined operation function |
() |
Source code in nitrofe\time_based_features\weighted_window_features\weighted_window_features.py
def caluclate_weighted_moving_window_feature(
self,
dataframe: Union[pd.DataFrame, pd.Series],
first_fit: bool = True,
window: int = 3,
min_periods: int = 1,
operation: Callable = None,
operation_args: tuple = (),
):
"""
Create weighted moving window feature
A weighted average is an average that has multiplying factors to give different weights to data at different positions in the sample window.
Mathematically, the weighted moving average is the convolution of the data with a fixed weighting function.
In an n-day WMA the latest day has weight n, the second latest n-1, etc, down to one
Parameters
----------
dataframe : Union[pd.DataFrame,pd.Series]
dataframe/series over weighted rolling window feature is to be constructed
first_fit : bool, optional
Rolling features require past "window" number of values for calculation.
Use True, when calculating for training data { in which case last "window" number of values will be saved }
Use False, when calculating for testing/production data { in which case the, last "window" number of values, which
are were saved during the last phase, will be utilized for calculation }, by default True
window : int, optional
Size of the rolling window, by default 3
min_periods : int, optional
Minimum number of observations in window required to have a value, by default 1
operation : Callable, optional
operation to perform over the weighted rolling window values, when None is passed, np.sum is used
operation_args : tuple, optional
additional agrument values to be sent for self defined operation function
"""
operation = np.sum if operation == None else operation
_function_name = "caluclate_weighted_moving_window_feature"
return self._template_feature_calculation(
function_name=_function_name,
win_function=_weighted_moving_window,
first_fit=first_fit,
dataframe=dataframe,
window=window,
min_periods=min_periods,
symmetric=None,
operation=operation,
operation_args=operation_args,
)
References
-
Wikipedia, "Weighted Window function", https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average
-
Wikipedia, "Bartlett function", https://en.wikipedia.org/wiki/Window_function#Bartlett%E2%80%93Hann_window
-
Center for Computer Research in Music and Acoustics, "Bartlett (``Triangular'') Window", https://ccrma.stanford.edu/~jos/sasp/Bartlett_Triangular_Window.html
-
Wikipedia, "Blackman function", https://en.wikipedia.org/wiki/Window_function#Blackman_window
-
Wikipedia, "Window function", https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window
-
mathworks, "bohmanwin", https://www.mathworks.com/help/signal/ref/bohmanwin.html
-
Wikipedia, "Window function", https://en.wikipedia.org/wiki/Window_function#Power-of-sine/cosine_windows
-
Wikipedia, "Window function", https://en.wikipedia.org/wiki/Window_function#Exponential_or_Poisson_window
-
mathworks, "flattopwin", https://in.mathworks.com/help/signal/ref/flattopwin.html
-
Wikipedia, "Window function", https://en.wikipedia.org/wiki/Window_function#Gaussian_window