public final class Label extends Object implements Classifiable<Label>
The labels themselves are Strings. A Label also contains an optional score which measures the confidence in that label, though it is not required to be a probability.
Label equality and hashCode is defined solely on the String label, it does not take into account the score.
Modifier and Type | Field and Description |
---|---|
protected String |
label
The name of the label.
|
protected double |
score
The score of the label.
|
static String |
UNKNOWN
The name of the unknown label (i.e., an unlabelled output).
|
Constructor and Description |
---|
Label(String label)
Builds a label with the sentinel score of Double.NaN.
|
Label(String label,
double score)
Builds a label with the supplied string and score.
|
Modifier and Type | Method and Description |
---|---|
Label |
copy()
Deep copy of the output up to it's immutable state.
|
boolean |
equals(Object o) |
boolean |
fullEquals(Label o)
Compares other to this output.
|
String |
getLabel()
Gets the name of this label.
|
double |
getScore()
Get a real valued score for this label.
|
String |
getSerializableForm(boolean includeConfidence)
Returns "labelName" or "labelName,score=labelScore".
|
int |
hashCode() |
String |
toString() |
public static final String UNKNOWN
protected final String label
protected final double score
public Label(String label, double score)
label
- The label name.score
- The label instance score.public Label(String label)
label
- The name of this label.public double getScore()
If the score is not set then it returns Double.NaN.
public String getLabel()
public boolean fullEquals(Label o)
Output
fullEquals
in interface Output<Label>
o
- Another output instance.public Label copy()
Output
public String getSerializableForm(boolean includeConfidence)
getSerializableForm
in interface Output<Label>
includeConfidence
- Include whatever confidence score the label contains, if known.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.