pyhealth.processors.IgnoreProcessor#
Processor to ignore a feature.
- class pyhealth.processors.IgnoreProcessor[source]#
Bases:
FeatureProcessorA special feature processor that marks a feature to be ignored during processing.
This processor is useful when you want to remove a specific feature from the dataset after the task function processing, but without modifying the task function itself.
Example
>>> from pyhealth.processors import IgnoreProcessor >>> # Assume we have a task that outputs "feature1" and "feature2" >>> # We want to remove "feature2" from the final dataset >>> dataset.set_task(task, input_processors={ ... "feature1": SequenceProcessor(code_to_index), ... "feature2": IgnoreProcessor() ... }) >>> # Now samples in dataset will only contain "feature1"
- process(value)[source]#
This method is intentionally not implemented.
- Parameters:
value (
Any) – Any raw field value.- Raises:
NotImplementedError – Always raised to indicate this processor ignores the field.
- Return type:
- dim()#
Number of dimensions (Tensor.dim()) for each output tensor, in the same order as the output tuple.
- fit(samples, field)#
Fit the processor to the samples.
- is_token()#
Returns whether the output (in particular, the value tensor) of the processor represents discrete token indices (True) or continuous values (False). This is used to determine whether to apply token-based transformations (e.g. nn.Embedding) or value-based augmentations (e.g. nn.Linear).
- Return type:
- Returns:
True if the output of the processor represents discrete token indices, False otherwise.
- load(path)#
Optional: Load processor state from disk.
- save(path)#
Optional: Save processor state to disk.
- schema()#
Returns the schema of the processed feature. For a processor that emits a single tensor, this should just return [“value”]. For a processor that emits a tuple of tensors, this should return a tuple of the same length as the tuple, with the semantic name of each tensor, such as [“time”, “value”], [“value”, “mask”], etc.
- Typical semantic names include:
“value”: the main processed tensor output of the processor
“time”: the time tensor output of the processor (mostly for StageNet)
“mask”: the mask tensor output of the processor (if applicable)
- spatial()#
Whether each dimension (axis) of the value tensor is spatial (i.e. corresponds to a spatial axis like time, height, width, etc.) or not. This is used to determine how to apply augmentations and other transformations that should only be applied to spatial dimensions.
E.g. for CNN or RNN features, this would help determine which dimensions to apply spatial augmentations to, and which dimensions to treat as channels or features.