pyFTS.models.seasonal package

Submodules

pyFTS.models.seasonal.SeasonalIndexer module

class pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer(index_fields, index_seasons, data_field, **kwargs)[source]

Bases: pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer

Use the Pandas.DataFrame index position to index the seasonality

get_data(data)[source]
get_data_by_season(data, indexes)[source]
get_index_by_season(indexes)[source]
get_season_by_index(index)[source]
get_season_of_data(data)[source]
set_data(data, value)[source]
class pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer(date_field, index_fields, index_seasons, data_field, **kwargs)[source]

Bases: pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer

Use a Pandas.DataFrame date field to index the seasonality

get_data(data)[source]
get_data_by_season(data, indexes)[source]
get_index(data)[source]
get_index_by_season(indexes)[source]
get_season_by_index(index)[source]
get_season_of_data(data)[source]
set_data(data, value)[source]
class pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer(seasons, units, ignore=None, **kwargs)[source]

Bases: pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer

Use the data array/list position to index the seasonality

get_data(data)[source]
get_index_by_season(indexes)[source]
get_season_by_index(index)[source]
get_season_of_data(data)[source]
class pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer(num_seasons, **kwargs)[source]

Bases: object

Seasonal Indexer. Responsible to find the seasonal index of a data point inside its data set

get_data(data)[source]
get_data_by_season(data, indexes)[source]
get_index(data)[source]
get_index_by_season(indexes)[source]
get_season_by_index(inde)[source]
get_season_of_data(data)[source]

pyFTS.models.seasonal.cmsfts module

class pyFTS.models.seasonal.cmsfts.ContextualMultiSeasonalFTS(**kwargs)[source]

Bases: pyFTS.models.seasonal.sfts.SeasonalFTS

Contextual Multi-Seasonal Fuzzy Time Series

alpha_cut: float

A float with the minimal membership to be considered on fuzzyfication process

auto_update: bool

A boolean value indicating that model is incremental

benchmark_only: bool

A boolean value indicating a façade for external (non-FTS) model used on benchmarks or ensembles.

detail: str

A string with the model detailed information

dump: bool
flrgs: dict

The list of Fuzzy Logical Relationship Groups - FLRG

forecast(data, **kwargs)[source]

Point forecast one step ahead

Parameters
  • data – time series data with the minimal length equal to the max_lag of the model

  • kwargs – model specific parameters

Returns

a list with the forecasted values

forecast_ahead(data, steps, **kwargs)[source]

Point forecast from 1 to H steps ahead, where H is given by the steps parameter

Parameters
  • data – time series data with the minimal length equal to the max_lag of the model

  • steps – the number of steps ahead to forecast (default: 1)

  • start_at – in the multi step forecasting, the index of the data where to start forecasting (default: 0)

Returns

a list with the forecasted values

generate_flrg(flrs)[source]
get_midpoints(flrg, data)[source]
has_interval_forecasting: bool

A boolean value indicating if the model supports interval forecasting, default: False

has_point_forecasting: bool

A boolean value indicating if the model supports point forecasting, default: True

has_probability_forecasting: bool

A boolean value indicating if the model support probabilistic forecasting, default: False

has_seasonality: bool

A boolean value indicating if the model supports seasonal indexers, default: False

is_clustered: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), but works like a monovariate method, default: False

is_high_order: bool

A boolean value indicating if the model support orders greater than 1, default: False

is_multivariate: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), default: False

is_time_variant: bool

A boolean value indicating if this model is time variant

is_wrapper: bool

Indicates that this model is a wrapper for other(s) method(s)

lags: list[int]

The list of lag indexes for high order models

log: pd.DataFrame
max_lag: int

A integer indicating the largest lag used by the model. This value also indicates the minimum number of past lags needed to forecast a single step ahead

min_order: int

In high order models, this integer value indicates the minimal order supported for the model, default: 1

name: str

A string with the model name

order: int

A integer with the model order (number of past lags are used on forecasting)

original_max: float

A float with the upper limit of the Universe of Discourse, the maximal value found on training data

original_min: float

A float with the lower limit of the Universe of Discourse, the minimal value found on training data

partitioner: partitioner.Partitioner

A pyFTS.partitioners.Partitioner object with the Universe of Discourse partitioner used on the model. This is a mandatory dependecy.

shortname: str

A string with a short name or alias for the model

standard_horizon: int

Standard forecasting horizon (Default: 1)

train(data, **kwargs)[source]

Method specific parameter fitting

Parameters
  • data – training time series data

  • kwargs – Method specific parameters

transformations: list[transformation.Transformation]

A list with the data transformations (common.Transformations) applied on model pre and post processing, default: []

transformations_param: list

A list with the specific parameters for each data transformation

uod_clip: bool

Flag indicating if the test data will be clipped inside the training Universe of Discourse

class pyFTS.models.seasonal.cmsfts.ContextualSeasonalFLRG(seasonality)[source]

Bases: pyFTS.models.seasonal.sfts.SeasonalFLRG

Contextual Seasonal Fuzzy Logical Relationship Group

append_rhs(flr, **kwargs)[source]

pyFTS.models.seasonal.common module

class pyFTS.models.seasonal.common.DateTime(value)[source]

Bases: enum.Enum

Data and Time granularity for time granularity and seasonality identification

day_of_month = 30
day_of_week = 7
day_of_year = 364
half = 2
hour = 24
hour_of_day = 24
hour_of_month = 744
hour_of_week = 168
hour_of_year = 8736
minute = 60
minute_of_day = 1440
minute_of_hour = 60
minute_of_month = 44640
minute_of_week = 10080
minute_of_year = 524160
month = 12
quarter = 4
second = 60
second_of_day = 86400
second_of_hour = 3600
second_of_minute = 60.00001
sixth = 6
third = 3
year = 1
class pyFTS.models.seasonal.common.FuzzySet(datepart, name, mf, parameters, centroid, alpha=1.0, **kwargs)[source]

Bases: pyFTS.common.FuzzySet.FuzzySet

Temporal/Seasonal Fuzzy Set

alpha: float

The alpha cut value

centroid: float

The fuzzy set center of mass (or midpoint)

name: str

The fuzzy set name

parameters: list

The parameters of the membership function

transform(x)[source]

Preprocess the data point for non native types

Parameters

x

Returns

return a native type value for the structured type

type: str

The fuzzy set type (common, composite, nonstationary, etc)

pyFTS.models.seasonal.common.strip_datepart(date, date_part, mask='')[source]

pyFTS.models.seasonal.msfts module

class pyFTS.models.seasonal.msfts.MultiSeasonalFTS(name, indexer, **kwargs)[source]

Bases: pyFTS.models.seasonal.sfts.SeasonalFTS

Multi-Seasonal Fuzzy Time Series

alpha_cut: float

A float with the minimal membership to be considered on fuzzyfication process

auto_update: bool

A boolean value indicating that model is incremental

benchmark_only: bool

A boolean value indicating a façade for external (non-FTS) model used on benchmarks or ensembles.

detail: str

A string with the model detailed information

dump: bool
flrgs: dict

The list of Fuzzy Logical Relationship Groups - FLRG

forecast(data, **kwargs)[source]

Point forecast one step ahead

Parameters
  • data – time series data with the minimal length equal to the max_lag of the model

  • kwargs – model specific parameters

Returns

a list with the forecasted values

forecast_ahead(data, steps, **kwargs)[source]

Point forecast from 1 to H steps ahead, where H is given by the steps parameter

Parameters
  • data – time series data with the minimal length equal to the max_lag of the model

  • steps – the number of steps ahead to forecast (default: 1)

  • start_at – in the multi step forecasting, the index of the data where to start forecasting (default: 0)

Returns

a list with the forecasted values

generate_flrg(flrs)[source]
has_interval_forecasting: bool

A boolean value indicating if the model supports interval forecasting, default: False

has_point_forecasting: bool

A boolean value indicating if the model supports point forecasting, default: True

has_probability_forecasting: bool

A boolean value indicating if the model support probabilistic forecasting, default: False

has_seasonality: bool

A boolean value indicating if the model supports seasonal indexers, default: False

is_clustered: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), but works like a monovariate method, default: False

is_high_order: bool

A boolean value indicating if the model support orders greater than 1, default: False

is_multivariate: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), default: False

is_time_variant: bool

A boolean value indicating if this model is time variant

is_wrapper: bool

Indicates that this model is a wrapper for other(s) method(s)

lags: list[int]

The list of lag indexes for high order models

log: pd.DataFrame
max_lag: int

A integer indicating the largest lag used by the model. This value also indicates the minimum number of past lags needed to forecast a single step ahead

min_order: int

In high order models, this integer value indicates the minimal order supported for the model, default: 1

name: str

A string with the model name

order: int

A integer with the model order (number of past lags are used on forecasting)

original_max: float

A float with the upper limit of the Universe of Discourse, the maximal value found on training data

original_min: float

A float with the lower limit of the Universe of Discourse, the minimal value found on training data

partitioner: partitioner.Partitioner

A pyFTS.partitioners.Partitioner object with the Universe of Discourse partitioner used on the model. This is a mandatory dependecy.

shortname: str

A string with a short name or alias for the model

standard_horizon: int

Standard forecasting horizon (Default: 1)

train(data, **kwargs)[source]

Method specific parameter fitting

Parameters
  • data – training time series data

  • kwargs – Method specific parameters

transformations: list[transformation.Transformation]

A list with the data transformations (common.Transformations) applied on model pre and post processing, default: []

transformations_param: list

A list with the specific parameters for each data transformation

uod_clip: bool

Flag indicating if the test data will be clipped inside the training Universe of Discourse

pyFTS.models.seasonal.partitioner module

class pyFTS.models.seasonal.partitioner.TimeGridPartitioner(**kwargs)[source]

Bases: pyFTS.partitioners.partitioner.Partitioner

Even Length DateTime Grid Partitioner

build(data)[source]

Perform the partitioning of the Universe of Discourse

Parameters

data – training data

Returns

build_index()[source]
extractor(x)[source]

Extract a single primitive type from an structured instance

mask

A string with datetime formating mask

plot(ax)[source]

Plot the :param ax: :return:

search(data, **kwargs)[source]

Perform a search for the nearest fuzzy sets of the point ‘data’. This function were designed to work with several overlapped fuzzy sets.

Parameters
  • data – the value to search for the nearest fuzzy sets

  • type – the return type: ‘index’ for the fuzzy set indexes or ‘name’ for fuzzy set names.

  • results – the number of nearest fuzzy sets to return

Returns

a list with the nearest fuzzy sets

season

Seasonality, a pyFTS.models.seasonal.common.DateTime object

pyFTS.models.seasonal.sfts module

Simple First Order Seasonal Fuzzy Time Series implementation of Song (1999) based of Conventional FTS by Chen (1996)

  1. Song, “Seasonal forecasting in fuzzy time series,” Fuzzy sets Syst., vol. 107, pp. 235–236, 1999.

S.-M. Chen, “Forecasting enrollments based on fuzzy time series,” Fuzzy Sets Syst., vol. 81, no. 3, pp. 311–319, 1996.

class pyFTS.models.seasonal.sfts.SeasonalFLRG(seasonality)[source]

Bases: pyFTS.common.flrg.FLRG

First Order Seasonal Fuzzy Logical Relationship Group

append_rhs(c, **kwargs)[source]
get_key()[source]

Returns a unique identifier for this FLRG

class pyFTS.models.seasonal.sfts.SeasonalFTS(**kwargs)[source]

Bases: pyFTS.common.fts.FTS

First Order Seasonal Fuzzy Time Series

alpha_cut: float

A float with the minimal membership to be considered on fuzzyfication process

auto_update: bool

A boolean value indicating that model is incremental

benchmark_only: bool

A boolean value indicating a façade for external (non-FTS) model used on benchmarks or ensembles.

detail: str

A string with the model detailed information

dump: bool
flrgs: dict

The list of Fuzzy Logical Relationship Groups - FLRG

forecast(data, **kwargs)[source]

Point forecast one step ahead

Parameters
  • data – time series data with the minimal length equal to the max_lag of the model

  • kwargs – model specific parameters

Returns

a list with the forecasted values

generate_flrg(flrs)[source]
get_midpoints(flrg)[source]
has_interval_forecasting: bool

A boolean value indicating if the model supports interval forecasting, default: False

has_point_forecasting: bool

A boolean value indicating if the model supports point forecasting, default: True

has_probability_forecasting: bool

A boolean value indicating if the model support probabilistic forecasting, default: False

has_seasonality: bool

A boolean value indicating if the model supports seasonal indexers, default: False

is_clustered: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), but works like a monovariate method, default: False

is_high_order: bool

A boolean value indicating if the model support orders greater than 1, default: False

is_multivariate: bool

A boolean value indicating if the model support multivariate time series (Pandas DataFrame), default: False

is_time_variant: bool

A boolean value indicating if this model is time variant

is_wrapper: bool

Indicates that this model is a wrapper for other(s) method(s)

lags: list[int]

The list of lag indexes for high order models

log: pd.DataFrame
max_lag: int

A integer indicating the largest lag used by the model. This value also indicates the minimum number of past lags needed to forecast a single step ahead

min_order: int

In high order models, this integer value indicates the minimal order supported for the model, default: 1

name: str

A string with the model name

order: int

A integer with the model order (number of past lags are used on forecasting)

original_max: float

A float with the upper limit of the Universe of Discourse, the maximal value found on training data

original_min: float

A float with the lower limit of the Universe of Discourse, the minimal value found on training data

partitioner: partitioner.Partitioner

A pyFTS.partitioners.Partitioner object with the Universe of Discourse partitioner used on the model. This is a mandatory dependecy.

shortname: str

A string with a short name or alias for the model

standard_horizon: int

Standard forecasting horizon (Default: 1)

train(data, **kwargs)[source]

Method specific parameter fitting

Parameters
  • data – training time series data

  • kwargs – Method specific parameters

transformations: list[transformation.Transformation]

A list with the data transformations (common.Transformations) applied on model pre and post processing, default: []

transformations_param: list

A list with the specific parameters for each data transformation

uod_clip: bool

Flag indicating if the test data will be clipped inside the training Universe of Discourse

Module contents