ML Community Day is November 9! Join us for updates from TensorFlow, JAX, and more Learn more

Category

public final class Category

Category is a util class, contains a label, its display name, a float value as score, and the index of the label in the corresponding label file. Typically it's used as result of classification tasks.

Public Constructors

Category(String label, float score)
Constructs a Category object with an empty displayName and the default index (-1).

Public Methods

static Category
create(String label, String displayName, float score, int index)
Constructs a Category object.
static Category
create(String label, String displayName, float score)
Constructs a Category object with the default index (-1).
boolean
String
getDisplayName()
Gets the reference of category's displayName, a name in locale of the label.
int
getIndex()
Gets the index of the category.
String
getLabel()
Gets the reference of category's label.
float
getScore()
Gets the score of the category.
int
String

Inherited Methods

Public Constructors

public Category (String label, float score)

Constructs a Category object with an empty displayName and the default index (-1).

Parameters
label
score

Public Methods

public static Category create (String label, String displayName, float score, int index)

Constructs a Category object.

Parameters
label the label of this category object
displayName the display name of the label, which may be translated for different locales. For exmaple, a label, "apple", may be translated into Spanish for display purpose, so that the displayName is "manzana".
score the probability score of this label category
index the index of the label in the corresponding label file

public static Category create (String label, String displayName, float score)

Constructs a Category object with the default index (-1).

Parameters
label
displayName
score

public boolean equals (Object o)

Parameters
o

public String getDisplayName ()

Gets the reference of category's displayName, a name in locale of the label.

The display name can be an empty string if this Category object is constructed without displayName, such as when using Category(String, float).

public int getIndex ()

Gets the index of the category. The index value might be -1, which means it has not been set up properly and is invalid.

public String getLabel ()

Gets the reference of category's label.

public float getScore ()

Gets the score of the category.

public int hashCode ()

public String toString ()