Class TransformerMap
java.lang.Object
org.tribuo.transform.TransformerMap
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<TransformerMap.TransformerMapProvenance>
,Serializable
public final class TransformerMap
extends Object
implements com.oracle.labs.mlrg.olcut.provenance.Provenancable<TransformerMap.TransformerMapProvenance>, Serializable
A collection of
Transformer
s which can be applied to a Dataset
or Example
. A TransformerMap is created by applying a TransformationMap
to a Dataset. It contains Transformers which are specific to the Dataset which created
it, for example the range of a feature used in binning is fixed to the value from
that Dataset.
Transformations only operate on observed values. To operate on implicit zeros then
first call MutableDataset.densify()
on the datasets.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionTransformerMap
(Map<String, List<Transformer>> map, DatasetProvenance datasetProvenance, com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance transformationMapProvenance) Constructs a transformer map which encapsulates a set of transformers that can be applied to features. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
applyTransformerList
(double value, List<Transformer> transformerList) Applies aList
ofTransformer
s to the supplied double value, returning the transformed value.entrySet()
Get the feature names and associated list of transformers.toString()
<T extends Output<T>>
MutableDataset<T> transformDataset
(Dataset<T> dataset) Copies the supplied dataset and applies the transformers to each example in it.<T extends Output<T>>
MutableDataset<T> transformDataset
(Dataset<T> dataset, boolean densify) Copies the supplied dataset and applies the transformers to each example in it.transformExample
(Example<T> example) Copies the supplied example and applies the transformers to it.transformExample
(Example<T> example, List<String> featureNames) Copies the supplied example and applies the transformers to it.
-
Constructor Details
-
TransformerMap
public TransformerMap(Map<String, List<Transformer>> map, DatasetProvenance datasetProvenance, com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance transformationMapProvenance) Constructs a transformer map which encapsulates a set of transformers that can be applied to features.- Parameters:
map
- The transformers, one per transformed feature.datasetProvenance
- The provenance of the dataset the transformers were fit against.transformationMapProvenance
- The provenance of the transformation map that was fit.
-
-
Method Details
-
applyTransformerList
Applies aList
ofTransformer
s to the supplied double value, returning the transformed value.- Parameters:
value
- The value to transform.transformerList
- The transformers to apply.- Returns:
- The transformed value.
-
transformExample
Copies the supplied example and applies the transformers to it.- Type Parameters:
T
- The type of Output.- Parameters:
example
- The example to transform.- Returns:
- A copy of the example with the transformers applied to it's features.
-
transformExample
public <T extends Output<T>> Example<T> transformExample(Example<T> example, List<String> featureNames) Copies the supplied example and applies the transformers to it.- Type Parameters:
T
- The type of Output.- Parameters:
example
- The example to transform.featureNames
- The feature names to densify.- Returns:
- A copy of the example with the transformers applied to it's features.
-
transformDataset
Copies the supplied dataset and applies the transformers to each example in it.Does not densify the dataset first.
- Type Parameters:
T
- The type of Output.- Parameters:
dataset
- The dataset to transform.- Returns:
- A deep copy of the dataset (and it's examples) with the transformers applied to it's features.
-
transformDataset
public <T extends Output<T>> MutableDataset<T> transformDataset(Dataset<T> dataset, boolean densify) Copies the supplied dataset and applies the transformers to each example in it.- Type Parameters:
T
- The type of Output.- Parameters:
dataset
- The dataset to transform.densify
- Densify the dataset before transforming it.- Returns:
- A deep copy of the dataset (and it's examples) with the transformers applied to it's features.
-
toString
-
entrySet
-
getProvenance
- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<TransformerMap.TransformerMapProvenance>
-