public class Classifications
extends java.lang.Object
implements ai.djl.util.JsonSerializable
Classifications
is the container that stores the classification results for
classification on a single input.Modifier and Type | Class and Description |
---|---|
static class |
Classifications.Classification
A
Classification stores the classification result for a single class on a single
input. |
static class |
Classifications.ClassificationsSerializer
A customized Gson serializer to serialize the
Classifications object. |
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.lang.String> |
classNames |
protected java.util.List<java.lang.Double> |
probabilities |
Constructor and Description |
---|
Classifications(java.util.List<java.lang.String> classNames,
java.util.List<java.lang.Double> probabilities)
Constructs a
Classifications using a parallel list of classNames and probabilities. |
Classifications(java.util.List<java.lang.String> classNames,
NDArray probabilities)
Constructs a
Classifications using list of classNames parallel to an NDArray of
probabilities. |
Modifier and Type | Method and Description |
---|---|
<T extends Classifications.Classification> |
best()
Returns the most likely class for the classification.
|
<T extends Classifications.Classification> |
get(java.lang.String className)
Returns the result for a particular class name.
|
java.lang.String |
getAsString()
Returns the
String presentation of the object. |
<T extends Classifications.Classification> |
item(int index)
Returns the item at a given index based on the order used to construct the
Classifications . |
<T extends Classifications.Classification> |
items()
Returns a classification item for each potential class for the input.
|
java.nio.ByteBuffer |
toByteBuffer()
Returns the
ByteBuffer presentation of the object. |
java.lang.String |
toJson() |
<T extends Classifications.Classification> |
topK(int k)
Returns a list of the top
k best classes. |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAsBytes, getAsObject, wrap, wrap, wrapAsJson
protected java.util.List<java.lang.String> classNames
protected java.util.List<java.lang.Double> probabilities
public Classifications(java.util.List<java.lang.String> classNames, java.util.List<java.lang.Double> probabilities)
Classifications
using a parallel list of classNames and probabilities.classNames
- the names of the classesprobabilities
- the probabilities for each class for the inputpublic Classifications(java.util.List<java.lang.String> classNames, NDArray probabilities)
Classifications
using list of classNames parallel to an NDArray of
probabilities.classNames
- the names of the classesprobabilities
- the probabilities for each class for the inputpublic <T extends Classifications.Classification> java.util.List<T> items()
T
- the type of classification item for the taskpublic <T extends Classifications.Classification> T item(int index)
Classifications
.T
- the type of classification item for the taskindex
- the index of the item to returnclassifications.items().get(index)
public <T extends Classifications.Classification> java.util.List<T> topK(int k)
k
best classes.T
- the type of the classification item for the taskk
- the number of classes to returnpublic <T extends Classifications.Classification> T best()
T
- the type of the classification item for the taskpublic <T extends Classifications.Classification> T get(java.lang.String className)
T
- the type of the classification item for the taskclassName
- the class name to get results forpublic java.lang.String toJson()
toJson
in interface ai.djl.util.JsonSerializable
public java.lang.String getAsString()
String
presentation of the object.getAsString
in interface BytesSupplier
String
presentation of the objectpublic java.nio.ByteBuffer toByteBuffer()
ByteBuffer
presentation of the object.toByteBuffer
in interface BytesSupplier
ByteBuffer
presentation of the objectpublic java.lang.String toString()
toString
in class java.lang.Object