public class SequenceExample<T extends Output<T>> extends Object implements Iterable<Example<T>>, Serializable
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_WEIGHT |
Constructor and Description |
---|
SequenceExample()
Creates an empty sequence example.
|
SequenceExample(List<Example<T>> examples)
Creates a sequence example from the list of examples.
|
SequenceExample(List<Example<T>> examples,
float weight)
Creates a sequence example from the list of examples, setting the weight.
|
SequenceExample(List<T> outputs,
List<? extends List<? extends Feature>> features)
Creates a sequence example from the supplied outputs and list of list of features.
|
SequenceExample(List<T> outputs,
List<? extends List<? extends Feature>> features,
boolean attemptBinaryFeatures) |
SequenceExample(List<T> outputs,
List<? extends List<? extends Feature>> features,
float weight)
Creates a sequence example from the supplied weight, outputs and list of list of features.
|
SequenceExample(List<T> outputs,
List<? extends List<? extends Feature>> features,
float weight,
boolean attemptBinaryFeatures) |
SequenceExample(SequenceExample<T> other)
Creates a deep copy of the supplied sequence example.
|
Modifier and Type | Method and Description |
---|---|
void |
addExample(Example<T> e)
Adds an
Example to this sequence. |
void |
canonicalise(FeatureMap featureMap)
Reassigns feature name Strings in each Example inside this SequenceExample to point to
those in the
FeatureMap . |
SequenceExample<T> |
copy()
Returns a deep copy of this SequenceExample.
|
static <T extends Output<T>> |
createWithEmptyOutputs(List<? extends List<? extends Feature>> features,
OutputFactory<T> outputFactory)
Creates a SequenceExample using
OutputFactory.getUnknownOutput() as the output for each
sequence element. |
Iterator<Feature> |
featureIterator()
Creates an iterator over every feature in this sequence.
|
Example<T> |
get(int i)
Gets the example found at the specified index.
|
float |
getWeight()
Gets the weight of this sequence.
|
Iterator<Example<T>> |
iterator() |
void |
reduceByName(Merger merger)
Reduces the features in each example using the supplied
Merger . |
void |
removeFeatures(List<Feature> features)
Removes the features in the supplied list from each example contained in this sequence.
|
void |
setWeight(float weight)
Sets the weight of this sequence.
|
int |
size()
Return how many examples are in this sequence.
|
boolean |
validateExample()
Checks that each
Example in this sequence is valid. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final float DEFAULT_WEIGHT
public SequenceExample()
public SequenceExample(List<Example<T>> examples)
The examples are not copied by this method.
examples
- The examples to incorporate.public SequenceExample(List<Example<T>> examples, float weight)
The examples are encapsulated by this constructor, not copied.
examples
- The examples to incorporate.weight
- The weight of this sequence.public SequenceExample(List<T> outputs, List<? extends List<? extends Feature>> features)
The features are copied out by this constructor. The outputs and features lists
must be of the same length. Sets the weight to DEFAULT_WEIGHT
.
outputs
- The outputs for each sequence element.features
- The features for each sequence element.public SequenceExample(List<T> outputs, List<? extends List<? extends Feature>> features, float weight)
The features are copied out by this constructor. The outputs and features lists must be of the same length.
outputs
- The outputs for each sequence element.features
- The features for each sequence element.weight
- The weight for this sequence example.public SequenceExample(List<T> outputs, List<? extends List<? extends Feature>> features, boolean attemptBinaryFeatures)
public SequenceExample(List<T> outputs, List<? extends List<? extends Feature>> features, float weight, boolean attemptBinaryFeatures)
public SequenceExample(SequenceExample<T> other)
other
- The sequence example to copy.public int size()
public void removeFeatures(List<Feature> features)
features
- The features to remove.public Example<T> get(int i)
i
- The index to lookup.Example
for index i.public boolean validateExample()
Example
in this sequence is valid.Example
is valid, false otherwise.public void reduceByName(Merger merger)
Merger
.merger
- The merger to use in the reduction.public void setWeight(float weight)
weight
- The new weight.public float getWeight()
public void addExample(Example<T> e)
Example
to this sequence.e
- The example to add.public SequenceExample<T> copy()
public Iterator<Feature> featureIterator()
public void canonicalise(FeatureMap featureMap)
FeatureMap
. This significantly reduces memory allocation. It is called
when a SequenceExample is added to a MutableSequenceDataset
, and should not be
called outside of that context as it may interact unexpectedly with
HashedFeatureMap
.featureMap
- The feature map containing canonical feature names.public static <T extends Output<T>> SequenceExample<T> createWithEmptyOutputs(List<? extends List<? extends Feature>> features, OutputFactory<T> outputFactory)
OutputFactory.getUnknownOutput()
as the output for each
sequence element.
Note: this method is used to create SequenceExamples at prediction time where there is no
ground truth Output
.
T
- The type of the Output
.features
- The features for each sequence element.outputFactory
- The output factory to use.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.