Single Month Feature Set
Module for the SingleMonthFeatureSet class and SingleMonthFeatureConfig class.
Author: Daniel Wertheimer
SingleMonthFeatureConfig
Bases: FeatureConfig
Configuration class for single-month feature calculation.
Attributes:
| Name | Type | Description |
|---|---|---|
lag_months |
list[int]
|
List of integers representing the number of months to lag. (default is [1, 3, 6]) |
count_columns |
list[str]
|
List of columns to perform count aggregation. |
sum_columns |
list[str]
|
List of columns to perform sum aggregation. |
mean_columns |
list[str]
|
List of columns to perform mean aggregation. |
count_if_one_columns |
list[str]
|
List of columns to perform count-if-one aggregation. |
calculate_percentage_change |
bool
|
Flag to determine if percentage change should be calculated. |
resolve_divide_by_zero |
bool
|
Flag to determine if divide by zero errors should be resolved. |
count_include_missing |
bool
|
Flag to determine if missing values should be included in the count. |
Source code in amee_utils/feature_generator/feature_set/single_month.py
get_function_dict()
Get a dictionary mapping aggregation strategies to column lists.
Returns:
| Type | Description |
|---|---|
dict[AggregationStrategy, list[str]]
|
Dictionary mapping aggregation strategies to columns. |
Source code in amee_utils/feature_generator/feature_set/single_month.py
SingleMonthFeatureSet
Bases: FeatureSet[SingleMonthFeatureConfig]
FeatureSet class for calculating single-month features.
Methods:
| Name | Description |
|---|---|
calculate |
Calculate the features based on the given configurations. |
Source code in amee_utils/feature_generator/feature_set/single_month.py
calculate(df, dataset_config, feature_config, calculation_date)
Calculate single-month features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Input DataFrame. |
required |
dataset_config
|
DatasetConfig
|
Configuration for the dataset. |
required |
feature_config
|
SingleMonthFeatureConfig
|
Configuration for the feature calculation. |
required |
calculation_date
|
datetime
|
Date for which the calculation is performed. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with the calculated features. |