tsfuse.computation

class tsfuse.computation.Graph(nodes=None)

Computation graph.

A computation graph is a directed acyclic graph (DAG) whose nodes areconnected by edges that represent the flow of the data. There are three types of nodes:

  • Inputs: placeholders for the input time series data.

  • Constants: values that do not depend on the input data.

  • Transformers: computation steps which create new data from existing data. The input of a transformer is given by its parent nodes. See tsfuse.transformers for an overview of all available transformers.

The outputs of a computation graph are the values computed by all transformers that either have no outgoing edges, or are marked as an output node.

Parameters

nodes (list(Node), optional) – Initialize the computation graph with a list of nodes. Nodes can also be added later using Grap add_node()

nodes

All nodes of the graph.

Type

list(Node)

inputs

Input nodes, given as a dictionary of {input_id: node} items.

Type

dict(str, Input)

constants

Constant nodes.

Type

list(Constant)

transformers

Transformer nodes.

Type

list(Transformer)

outputs

Output nodes.

Type

list(Node)

add_node(node, **kwargs)

Add a node to the computation graph.

Parameters

node (Node) – Node that will be added to the graph.

Returns

node

Return type

Node

transform(X, return_dataframe=True, chunk_size=None, n_jobs=None)

Compute all outputs of the graph.

Parameters
  • X (dict(int or str: Collection)) – Data collections used as inputs for the graph. Collection X[i] will be used for graph.inputs[i].

  • return_dataframe (bool, default True) – Return the graph’s output as a pandas DataFrame.

  • chunk_size (int, optional) – Split the input data collections into chunks c with c.shape[0] == chunk_size and process each block separately.

  • n_jobs (int, optional) – Number of chunks to process simultaneously, only relevant if a chunk size is specified.

to_dot()

Visualize the computation graph.

class tsfuse.computation.Node(parents=None, is_output=None)

Node of a computation graph.

Parameters
  • parents (list(Node), optional) – Parent nodes.

  • is_output (bool, optional) – True if the node must be an output node or False if the node should not be an output node. By default, the node is an output node if it is not used as a parent for another node.

parents

Parent nodes.

Type

list(Node)

children

Child nodes.

Type

list(Node)

is_input

True if the node is an input node.

Type

bool

is_output

True if the node is an output node.

Type

bool

add_child(child)

Add a child node.

Parameters

child (Node) – Child node.

class tsfuse.computation.Input(input_id)

Node that serves as the input of a computation graph.

Parameters

input_id (int or str) – Input identifier.

class tsfuse.computation.Constant(data)

Node that produces a constant value, given as Collection object.

Parameters

data (int, float, str or object) – Output data.

class tsfuse.computation.Transformer(*parents, **kwargs)

Transformer node.

check_preconditions(*collections)

Check that the preconditions are satisfied.

Parameters

*collectionsCollection objects used as input.

Returns

satisfied

Return type

bool