Welcome to OpenFlow’s documentation!

openflow

openflow package

Submodules

openflow.datasource module

class openflow.datasource.DataSource(preprocess=None)

Bases: object

Extracts raw data then restitute it as an arranged DataFrame.

Parameters:preprocess (lambda) – Preprocess DataFrame before transformation
add_output(name, function)

Adds an output to the DataSource. The order in which the outputs are appended is important if previous outputs are reused.

Parameters:
  • name (str) – Name of the output
  • function (lambda) – Function to apply to DataFrame

Examples

>>> add_output('double', lambda df: 2 * df['number'])
get_dataframe(force_computation=False)

Preprocesses then transforms the return of run().

Parameters:force_computation (bool, optional) – Defaults to False. If set to True, forces the computation of DataFrame at each call.
Returns:Preprocessed and transformed DataFrame.
Return type:pandas.DataFrame
set_data(data)

Set data at runtime. Will be passed to run() function.

Parameters:data (obj) – Data to be passed to run().
transform(df)

Transforms a DataFrame in place. Computes all outputs of the DataFrame.

Parameters:df (pandas.DataFrame) – DataFrame to transform.

openflow.openflow module

class openflow.openflow.OpenFlow(model, defaults=None)

Bases: object

add_input(name, outputs)

Adds an input.

Parameters:
  • name (str) – The name of the input.
  • columns (list(str)) – The outputs to extract from the DataSource.
benchmark(ds, limit=None, x_output='x', y_output='y')
get_input(name, ds)

Retrieves the content of an input given a DataSource. The input acts like a filter over the outputs of the DataSource.

Parameters:
  • name (str) – The name of the input.
  • ds (openflow.DataSource) – The DataSource that will feed the data.
Returns:

The content of the input.

Return type:

pandas.DataFrame

train(ds, limit=None, x_output='x', y_output='y')

Module contents

Indices and tables