mlens.utils.formatting module

ML-ENSEMBLE

author:Sebastian Flennerhag
copyright:2017
licence:MIT

Formatting of instance lists.

mlens.utils.formatting.check_instances(instances)[source]

Helper to ensure all instances are named.

Check if instances is formatted as expected, and if not convert formatting or throw traceback error if impossible to anticipate formatting.

Parameters:instances (iterable) – instance iterable to test.
Returns:formatted – formatted instances object. Will be formatted as a dict if preprocessing cases are detected, otherwise as a list. The dict will contain lists identical to those in the single preprocessing case. Each list is of the form [('name', instance] and no names overlap.
Return type:list or dict
Raises:LayerSpecificationError : – Raises error if formatting fails, which is most likely due to wrong ordering of tuple entries, or wrong argument in the wrong position.