deephaven.learn

Deephaven’s learn module provides utilities for efficient data transfer between Deephaven tables and Python objects, as well as a framework for using popular machine-learning / deep-learning libraries with Deephaven tables.

class Input(col_names, gather_func)[source]

Bases: object

Input specifies how to gather data from a Deephaven table into an object.

Initializes an Input object with the given arguments.

Parameters:
  • col_names (str | list[str]) – column name or list of column names from which to gather input.

  • gather_func (Callable) – function that determines how input gets transformed into an object.

class Output(col_name, scatter_func, col_type)[source]

Bases: object

Output specifies how to scatter data from an object into a table column.

Initializes an Output object with the given arguments.

Parameters:
  • col_name (str) – name of the new column that will store results.

  • scatter_func (Callable) – function that determines how data is taken from an object and placed into a Deephaven table column.

  • col_type (str | None) – the type name of the new output column, as a string such as “double”. Each value is cast to this type. Pass None for no explicit type cast. This argument has no default.

learn(table, model_func=None, inputs=None, outputs=None, batch_size=None)[source]

Learn gathers data from multiple rows of the input table, performs a calculation, and scatters values from the calculation into an output table. This is a common computing paradigm for artificial intelligence, machine learning, and deep learning.

Parameters:
  • table (Table) – the Deephaven table to perform computations on.

  • model_func (Callable | None) – function that performs computations on the table.

  • inputs (list[Input] | None) – list of Input objects that determine how data gets extracted from the table, defaults to None, meaning no inputs.

  • outputs (list[Output] | None) – list of Output objects that determine how data gets scattered back into the results table, defaults to None, meaning the result table gets no new columns. model_func still runs on every batch. An empty list means the same as None.

  • batch_size (int | None) – maximum number of rows for which model_func is evaluated at once.

Return type:

Table

Returns:

a Table with added columns containing the results of evaluating model_func.

Raises:

DHError –