lir.transform.select_instances module
- class lir.transform.select_instances.SelectInstances(select_element_fn: Callable[[int], bool])[source]
Bases:
TransformerSelect elements in a dataset from their indices.
- Parameters:
select_element_fn (Callable[[int], bool]) – A function that takes a line number and returns True if it should be included, or False if it should be discarded.
Examples
This filter can be used in a YAML configuration:
data: provider: [...] strategy: [...] filter: method: select_instances # drop instances unless their indices matches any of the following patterns indices: - 2 # select element 2 -- the third record - 0-99 # select element 0-99 (inclusive) -- the first 100 records - 0-99,800-899 # select element 0-99 and 800-899 - /5 # select every fifth element: 0, 5, 10, ...
- apply(instances: DataType) DataType[source]
Apply the selection to a dataset.
- Parameters:
instances (InstanceData) – The dataset to select instances from.
- Returns:
A dataset with only the selected instances.
- Return type: