pyFTS.models.multivariate package

Module contents

Multivariate Fuzzy Time Series methods

Submodules

pyFTS.models.multivariate.FLR module

class pyFTS.models.multivariate.FLR.FLR[source]

Bases: object

Multivariate Fuzzy Logical Relationship

set_lhs(var, set)[source]
set_rhs(set)[source]

pyFTS.models.multivariate.common module

class pyFTS.models.multivariate.common.MultivariateFuzzySet(**kwargs)[source]

Bases: pyFTS.common.Composite.FuzzySet

Multivariate Composite Fuzzy Set

alpha: float

The alpha cut value

append_set(variable, set)[source]

Appends a new fuzzy set from a new variable

Parameters
  • variable – an multivariate.variable instance

  • set – an common.FuzzySet instance

centroid: float

The fuzzy set center of mass (or midpoint)

membership(x)[source]

Calculate the membership value of a given input

Parameters

x – input value

Returns

membership value of x at this fuzzy set

name: str

The fuzzy set name

parameters: list

The parameters of the membership function

set_target_variable(variable)[source]
type: str

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

pyFTS.models.multivariate.common.fuzzyfy_instance(data_point, var, tuples=True)[source]
pyFTS.models.multivariate.common.fuzzyfy_instance_clustered(data_point, cluster, **kwargs)[source]

pyFTS.models.multivariate.variable module

class pyFTS.models.multivariate.variable.Variable(name, **kwargs)[source]

Bases: object

A variable of a fuzzy time series multivariate model. Each variable contains its own transformations and partitioners.

alias

A string with the alias of the variable

alpha_cut

Minimal membership value to be considered on fuzzyfication process

apply_inverse_transformations(data, **kwargs)[source]
apply_transformations(data, **kwargs)[source]
build(**kwargs)[source]
Parameters

kwargs

Returns

data_label

A string with the column name on DataFrame

data_type

The type of the data column on Pandas Dataframe

mask

The mask for format the data column on Pandas Dataframe

name

A string with the name of the variable

partitioner

UoD partitioner for the variable data

transformation

Pre processing transformation for the variable

pyFTS.models.multivariate.flrg module

class pyFTS.models.multivariate.flrg.FLRG(**kwargs)[source]

Bases: pyFTS.common.flrg.FLRG

Multivariate Fuzzy Logical Rule Group

append_rhs(fset, **kwargs)[source]
get_lower(sets)[source]

Returns the lower bound value for the RHS fuzzy sets

Parameters

sets – fuzzy sets

Returns

lower bound value

get_membership(data, variables)[source]

Returns the membership value of the FLRG for the input data

Parameters
  • data – input data

  • sets – fuzzy sets

Returns

the membership value

get_upper(sets)[source]

Returns the upper bound value for the RHS fuzzy sets

Parameters

sets – fuzzy sets

Returns

upper bound value

set_lhs(var, fset)[source]

pyFTS.models.multivariate.partitioner module

class pyFTS.models.multivariate.partitioner.MultivariatePartitioner(**kwargs)[source]

Bases: pyFTS.partitioners.partitioner.Partitioner

Base class for partitioners which use the MultivariateFuzzySet

append(fset)[source]
build(data)[source]

Perform the partitioning of the Universe of Discourse

Parameters

data – training data

Returns

build_index()[source]
change_target_variable(variable)[source]
format_data(data)[source]
fuzzyfy(data, **kwargs)[source]

Fuzzyfy the input data according to this partitioner fuzzy sets.

Parameters
  • data – input value to be fuzzyfied

  • alpha_cut – the minimal membership value to be considered on fuzzyfication (only for mode=’sets’)

  • method – the fuzzyfication method (fuzzy: all fuzzy memberships, maximum: only the maximum membership)

  • mode – the fuzzyfication mode (sets: return the fuzzy sets names, vector: return a vector with the membership

values for all fuzzy sets, both: return a list with tuples (fuzzy set, membership value) )

:returns a list with the fuzzyfied values, depending on the mode

prune()[source]
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.

Returns

a list with the nearest fuzzy sets

pyFTS.models.multivariate.grid module

class pyFTS.models.multivariate.grid.GridCluster(**kwargs)[source]

Bases: pyFTS.models.multivariate.partitioner.MultivariatePartitioner

A cartesian product of all fuzzy sets of all variables

build(data)[source]

Perform the partitioning of the Universe of Discourse

Parameters

data – training data

Returns

defuzzyfy(values, mode='both')[source]
class pyFTS.models.multivariate.grid.IncrementalGridCluster(**kwargs)[source]

Bases: pyFTS.models.multivariate.partitioner.MultivariatePartitioner

Create combinations of fuzzy sets of the variables on demand, incrementally increasing the multivariate fuzzy set base.

fuzzyfy(data, **kwargs)[source]

Fuzzyfy the input data according to this partitioner fuzzy sets.

Parameters
  • data – input value to be fuzzyfied

  • alpha_cut – the minimal membership value to be considered on fuzzyfication (only for mode=’sets’)

  • method – the fuzzyfication method (fuzzy: all fuzzy memberships, maximum: only the maximum membership)

  • mode – the fuzzyfication mode (sets: return the fuzzy sets names, vector: return a vector with the membership

values for all fuzzy sets, both: return a list with tuples (fuzzy set, membership value) )

:returns a list with the fuzzyfied values, depending on the mode

prune()[source]

pyFTS.models.multivariate.mvfts module

class pyFTS.models.multivariate.mvfts.MVFTS(**kwargs)[source]

Bases: pyFTS.common.fts.FTS

Multivariate extension of Chen’s ConventionalFTS method

alpha_cut: float

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

append_transformation(transformation, **kwargs)[source]
append_variable(var)[source]

Append a new endogenous variable to the model

Parameters

var – variable object

Returns

apply_transformations(data, params=None, updateUoD=False, **kwargs)[source]

Apply the data transformations for data preprocessing

Parameters
  • data – input data

  • params – transformation parameters

  • updateUoD

  • kwargs

Returns

preprocessed data

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.

clone_parameters(model)[source]

Import the parameters values from other model

Parameters

model – a model to clone the parameters

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

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

Interval 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

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

Returns

a list with the forecasted intervals

forecast_interval(data, **kwargs)[source]

Interval 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 prediction intervals

format_data(data)[source]
generate_flrg(flrs)[source]
generate_flrs(data)[source]
generate_lhs_flrs(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

pyFTS.models.multivariate.mvfts.product_dict(**kwargs)[source]

Code by Seth Johnson :param kwargs: :return:

pyFTS.models.multivariate.wmvfts module

class pyFTS.models.multivariate.wmvfts.WeightedFLRG(**kwargs)[source]

Bases: pyFTS.models.multivariate.flrg.FLRG

Weighted Multivariate Fuzzy Logical Rule Group

append_rhs(fset, **kwargs)[source]
get_lower(sets)[source]

Returns the lower bound value for the RHS fuzzy sets

Parameters

sets – fuzzy sets

Returns

lower bound value

get_midpoint(sets)[source]

Returns the midpoint value for the RHS fuzzy sets

Parameters

sets – fuzzy sets

Returns

the midpoint value

get_upper(sets)[source]

Returns the upper bound value for the RHS fuzzy sets

Parameters

sets – fuzzy sets

Returns

upper bound value

weights()[source]
class pyFTS.models.multivariate.wmvfts.WeightedMVFTS(**kwargs)[source]

Bases: pyFTS.models.multivariate.mvfts.MVFTS

Weighted Multivariate FTS

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

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)

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.multivariate.cmvfts module

class pyFTS.models.multivariate.cmvfts.ClusteredMVFTS(**kwargs)[source]

Bases: pyFTS.models.multivariate.mvfts.MVFTS

Meta model for high order, clustered multivariate FTS

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.

check_data(data)[source]
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_distribution(data, steps, **kwargs)[source]

Probabilistic 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

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

Returns

a list with the forecasted Probability Distributions

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

Multivariate forecast n step ahead

Parameters
  • data – Pandas dataframe with one column for each variable and with the minimal length equal to the max_lag of the model

  • steps – the number of steps ahead to forecast

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

Returns

a Pandas Dataframe object representing the forecasted values for each variable

forecast_distribution(data, **kwargs)[source]

Probabilistic 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 probabilistic.ProbabilityDistribution objects representing the forecasted Probability Distributions

forecast_interval(data, **kwargs)[source]

Interval 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 prediction intervals

forecast_multivariate(data, **kwargs)[source]

Multivariate forecast one step ahead

Parameters
  • data – Pandas dataframe with one column for each variable and with the minimal length equal to the max_lag of the model

  • kwargs – model specific parameters

Returns

a Pandas Dataframe object representing the forecasted values for each variable

fts_method

The FTS method to be called when a new model is build

fts_params

The FTS method specific parameters

fuzzyfy(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

model

The most recent trained model

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.multivariate.granular module

class pyFTS.models.multivariate.granular.GranularWMVFTS(**kwargs)[source]

Bases: pyFTS.models.multivariate.cmvfts.ClusteredMVFTS

Granular multivariate weighted high order FTS

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

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

model

The most recent trained model

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