dataeval.data.Operation¶
- class dataeval.data.Operation¶
Abstract base for a single step in a
Viewpipeline.A
Viewis built from an ordered list of operations, each applied in turn to the source dataset. An operation may do any combination of three things by mutating the view it is handed inapply():change cardinality / order — set or reorder
View.selection, the list of surviving source indices (filter, reorder, limit, resample).rewrite content — register a per-datum transform via
View.map(); a transform may target every datum or only a subset of source indices.rewrite metadata — override
apply_metadata(), folded once at build.
Operations run in the order given, and each reads the source through the transforms registered by earlier operations (see
View.read()), so a filter placed afterRelabelsees the relabeled targets.- requires¶
The MAITE datum shape this operation needs when it reads each datum’s target.
Viewaggregates therequiresof all operations and validates the source dataset once, upfront, raisingMaiteShapeErrorbefore any operation runs. Leave asNonewhen the operation ignores targets.- Type:¶
DatasetKind or None, default None
Examples
A custom operation that keeps only even-indexed items:
>>> from dataeval.data import View, Operation >>> >>> class KeepEven(Operation): ... def apply(self, view: View) -> None: ... view.selection = [i for i in view.selection if i % 2 == 0] >>> >>> view = View(dataset, [KeepEven()])