ts_benchmark.evaluation.strategy package
ts_benchmark.evaluation.strategy.constants module
Classes
- class FieldNames[source]
Bases:
object- ACTUAL_DATA = 'actual_data'
- FILE_NAME = 'file_name'
- FIT_TIME = 'fit_time'
- INFERENCE_DATA = 'inference_data'
- INFERENCE_TIME = 'inference_time'
- LOG_INFO = 'log_info'
- MODEL_NAME = 'model_name'
- MODEL_PARAMS = 'model_params'
- STRATEGY_ARGS = 'strategy_args'
ts_benchmark.evaluation.strategy.fixed_forecast module
Classes
|
Fixed forecast strategy class |
- class FixedForecast(strategy_config: Dict, evaluator: Evaluator)[source]
Bases:
ForecastingStrategyFixed forecast strategy class
This strategy defines a forecasting task with fixed prediction length.
The required strategy configs include:
horizon (int): The length to predict, i.e. the length of the test series;
train_ratio_in_tv (float): The ratio of the training series when performing train-validation split.
The accepted metrics include all regression metrics.
The return fields other than the specified metrics are (in order):
FieldNames.FILE_NAME: The name of the series;
FieldNames.FIT_TIME: The training time;
FieldNames.INFERENCE_TIME: The inference time;
FieldNames.ACTUAL_DATA: The true test data, encoded as a string.
FieldNames.INFERENCE_DATA: The predicted data, encoded as a string.
FieldNames.LOG_INFO: Any log returned by the evaluator.
- REQUIRED_CONFIGS = ['horizon', 'train_ratio_in_tv']
- property field_names: List[str]
Gets the field names of the result records
ts_benchmark.evaluation.strategy.forecasting module
Classes
|
The base class for forecasting strategies |
- class ForecastingStrategy(strategy_config: Dict, evaluator: Evaluator)[source]
Bases:
StrategyThe base class for forecasting strategies
- REQUIRED_CONFIGS = ['seed']
- execute(series_name: str, model_factory: ModelFactory) Any[source]
The primary interface to execute a forecasting strategy
In this method:
Random seeds are set;
Target series and corresponding meta-info are prepared;
Exceptions are handled;
- Parameters:
series_name – The name of a series data to evaluate.
model_factory – A model factory that creates a new model with each invocation.
- Returns:
The results generated by evaluating a model on a series.
ts_benchmark.evaluation.strategy.rolling_forecast module
Classes
|
Rolling forecast strategy class |
|
|
|
- class RollingForecast(strategy_config: Dict, evaluator: Evaluator)[source]
Bases:
ForecastingStrategyRolling forecast strategy class
This strategy defines a forecasting task that fits once on the training set and forecasts on the testing set in a rolling window style.
The required strategy configs include:
horizon (int): The length of each prediction;
tv_ratio (float): The ratio of the train-validation series when performing train-test split;
train_ratio_in_tv (float): The ratio of the training series when performing train-validation split;
stride (int): Rolling stride, i.e. the interval between two windows;
num_rollings (int): The maximum number of steps to forecast;
The accepted metrics include all regression metrics.
The return fields other than the specified metrics are (in order):
FieldNames.FILE_NAME: The name of the series;
FieldNames.FIT_TIME: The training time;
FieldNames.INFERENCE_TIME: The inference time;
FieldNames.ACTUAL_DATA: The true test data, encoded as a string.
FieldNames.INFERENCE_DATA: The predicted data, encoded as a string.
FieldNames.LOG_INFO: Any log returned by the evaluator.
- REQUIRED_CONFIGS = ['horizon', 'tv_ratio', 'train_ratio_in_tv', 'stride', 'num_rollings']
- property field_names: List[str]
Gets the field names of the result records
- class RollingForecastEvalBatchMaker(series: pandas.DataFrame, index_list: List[int])[source]
Bases:
object- has_more_batches() bool[source]
Check if there are more batches to process.
- Returns:
True if there are more batches, False otherwise.
- class RollingForecastPredictBatchMaker(batch_maker: RollingForecastEvalBatchMaker)[source]
Bases:
BatchMaker
ts_benchmark.evaluation.strategy.strategy module
Classes
Result collector |
|
|
The base class of strategies |
- class ResultCollector[source]
Bases:
objectResult collector
Result collectors helps to gather outputs returned by strategy classes, it is helpful define a custom result collector when the strategy class has irregular returns (e.g. returning multiple records in one evaluation).
- class Strategy(strategy_config: Dict, evaluator: Evaluator)[source]
Bases:
objectThe base class of strategies
A strategy defines the evaluation pipeline of the specific time-series analysis task.
Warning
Strategies are currently using pickle to store Python objects in the evaluation results, which is known to be unsafe during decoding. Although reading the evaluation log itself is safe, please DO NOT decode any pickled columns in the log file if the data source is untrusted.
- DEFAULT_CONFIG_KEY = '__default__'
- REQUIRED_CONFIGS = ['strategy_name']
- abstract execute(series_name: str, model_factory: ModelFactory) Any[source]
The primary interface to execute a strategy
- Parameters:
series_name – The name of a series data to evaluate.
model_factory – A model factory that creates a new model with each invocation.
- Returns:
The results generated by evaluating a model on a series.
- abstract property field_names: List[str]
Gets the field names of the result records
- get_collector() ResultCollector[source]
Creates a new compatible result collector
- get_config_str(required_configs_only: bool = False) str[source]
Gets the string representation of the strategy config
- Parameters:
required_configs_only – If True, includes only the keys specified by REQUIRED_CONFIGS in the string, otherwise, encode the strategy config as is.
- Returns:
A string representation of the strategy config.