public abstract class Classifications
extends java.lang.Object
Constructor and Description |
---|
Classifications() |
Modifier and Type | Method and Description |
---|---|
static <C> Classification<C> |
castToClassification(java.lang.Object object,
java.lang.Class<? extends C> categoriesClass)
Safe-casts the given object to classification.
|
static <C> Classification<C> |
convertToClassification(java.lang.Object object,
java.lang.Class<? extends C> categoriesClass)
Converts the given object to classification.
|
static <C> ClassificationWithConfidence<C> |
convertToClassificationWithConfidence(java.lang.Object object,
java.lang.Class<? extends C> categoriesClass,
float confidence,
float lowestConfidence,
float highestConfidence)
Converts the given object to classification with confidence.
|
static <C> java.util.Comparator<C> |
getCategoriesConfidenceComparator(ClassificationWithConfidence<C> classification,
boolean highestFirst)
Returns a
Comparator for sorting categories of the given Classification according to confidences. |
static java.lang.reflect.Method |
getClassifierClassifyMethod(Classifier<?,?> classifier)
Returns the classification method of the given classifier.
|
static <C> float |
getExtremeConfidence(ClassificationWithConfidence<C> classification,
boolean greaterThan,
float startFrom)
Returns the highest/lowest confidence from the classes in the given classification.
|
static <C> java.util.Collection<C> |
getSortedCategories(ClassificationWithConfidence<C> classification)
Returns all categories of the given classification sorted by confidences.
|
static <C> java.util.Collection<C> |
getSortedCategories(ClassificationWithConfidence<C> classification,
boolean highestFirst)
Returns all categories of the given classification sorted by confidences.
|
static <C> java.util.Collection<C> |
getSortedCategories(ClassificationWithConfidence<C> classification,
java.util.Comparator<? super C> comparator)
Returns all categories of the given classification sorted by the given comparator.
|
public static <C> Classification<C> castToClassification(java.lang.Object object, java.lang.Class<? extends C> categoriesClass) throws java.lang.ClassCastException
C
- the class of instances that represent the classification categoriesobject
- the object to cast to classificationcategoriesClass
- the class of instances that represent the classification categoriesjava.lang.ClassCastException
- if the given object does not implement the Classification
interface or the categories are represented by a different classpublic static <C> Classification<C> convertToClassification(java.lang.Object object, java.lang.Class<? extends C> categoriesClass)
categoriesClass
, a static array, or an Iterable
it is encapsulated into ClassificationBase
. Note that the objects from
the Iterable
and static arrays are type-checked to be compatible with C
and null items are silently ignored.C
- the class of instances that represent the classification categoriesobject
- the object to cast to classificationcategoriesClass
- the class of instances that represent the classification categoriesjava.lang.ClassCastException
- if the given object does not implement the Classification
interface or the categories are represented by a different classpublic static <C> ClassificationWithConfidence<C> convertToClassificationWithConfidence(java.lang.Object object, java.lang.Class<? extends C> categoriesClass, float confidence, float lowestConfidence, float highestConfidence)
categoriesClass
, a static array, or an Iterable
it is encapsulated into ClassificationWithConfidenceBase
and populated with
the respective objects and the given confidence
. Note that the objects from
the Iterable
and static arrays are type-checked to be compatible with C
and null items are silently ignored.C
- the class of instances that represent the classification categoriesobject
- the object to cast to classificationcategoriesClass
- the class of instances that represent the classification categoriesconfidence
- the confidence to set for the objects that do not have onelowestConfidence
- the lowest possible confidence of this classificationhighestConfidence
- the highest possible confidence of this classificationjava.lang.ClassCastException
- if the given object does not implement the ClassificationWithConfidence
interface or the categories are represented by a different classpublic static java.lang.reflect.Method getClassifierClassifyMethod(Classifier<?,?> classifier) throws java.lang.NullPointerException
classifier
- the classifier to get the classification method forjava.lang.NullPointerException
- if the given classifier is nullpublic static <C> java.util.Comparator<C> getCategoriesConfidenceComparator(ClassificationWithConfidence<C> classification, boolean highestFirst)
Comparator
for sorting categories of the given Classification
according to confidences.
The ordering is from the lowest to the highest confidence (or vice versa if ) as specified by the classification.C
- the class of instances that represent the classification categoriesclassification
- the classification the categories of which to sorthighestFirst
- flag whether to reverse the order to show the items with the highest confidence firstpublic static <C> java.util.Collection<C> getSortedCategories(ClassificationWithConfidence<C> classification, java.util.Comparator<? super C> comparator)
C
- the class of instances that represent the classification categoriesclassification
- the classification the categories of which to sortcomparator
- the comparator to use for sorting categoriespublic static <C> java.util.Collection<C> getSortedCategories(ClassificationWithConfidence<C> classification)
C
- the class of instances that represent the classification categoriesclassification
- the classification the categories of which to sortpublic static <C> java.util.Collection<C> getSortedCategories(ClassificationWithConfidence<C> classification, boolean highestFirst)
C
- the class of instances that represent the classification categoriesclassification
- the classification the categories of which to sorthighestFirst
- flag whether to reverse the order to show the items with the highest confidence firstpublic static <C> float getExtremeConfidence(ClassificationWithConfidence<C> classification, boolean greaterThan, float startFrom)
C
- the class of instances that represent the classification categoriesclassification
- the classification the extreme confidence to getgreaterThan
- the comparison directionstartFrom
- the smallest/highest confidence to initialize computation of the extreme from