Interface Classifier<T>
- Type Parameters:
T- the type of model input object.
- All Superinterfaces:
Serializable, ToDoubleFunction<T>, ToIntFunction<T>
- All Known Subinterfaces:
DataFrameClassifier
- All Known Implementing Classes:
AbstractClassifier, AdaBoost, BinarySparseLinearSVM, DecisionTree, DiscreteNaiveBayes, FLD, GradientTreeBoost, KNN, LDA, LinearSVM, LogisticRegression, LogisticRegression.Binomial, LogisticRegression.Multinomial, Maxent, Maxent.Binomial, Maxent.Multinomial, MLP, NaiveBayes, OneVersusOne, OneVersusRest, QDA, RandomForest, RBFNetwork, RDA, SparseLinearSVM, SparseLogisticRegression, SparseLogisticRegression.Binomial, SparseLogisticRegression.Multinomial, SVM
A classifier assigns an input object into one of a given number of categories.
The input object is formally termed an instance, and the categories are
termed classes. The instance is usually described by a vector of features,
which together constitute a description of all known characteristics of the
instance.
Classification normally refers to a supervised procedure, i.e. a procedure that produces an inferred function to predict the output value of new instances based on a training set of pairs consisting of an input object and a desired output value. The inferred function is called a classifier if the output is discrete or a regression function if the output is continuous.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceClassifier.Trainer<T, M extends Classifier<T>>The classifier trainer. -
Method Summary
Modifier and TypeMethodDescriptiondefault doubleapplyAsDouble(T x) default intapplyAsInt(T x) int[]classes()Returns the class labels.static <T> Classifier<T> ensemble(Classifier<T>... models) Return an ensemble of multiple base models to obtain better predictive performance.intReturns the number of classes.default booleanonline()Returns true if this is an online learner.default int[]Predicts the class labels of a list of instances.default int[]Predicts the class labels of a list of instances.default int[]Predicts the class labels of a dataset.default int[]Predicts the class labels of a dataset.intPredicts the class label of an instance.default int[]Predicts the class labels of an array of instances.default int[]Predicts the class labels of an array of instances.default intPredicts the class label of an instance and also calculate a posteriori probabilities.default doubleThe raw prediction score.default booleansoft()Returns true if this is a soft classifier that can estimate the posteriori probabilities of classification.default voidUpdates the model with a mini-batch of new samples.default voidUpdates the model with a mini-batch of new samples.default voidOnline update the classifier with a new training instance.
-
Method Details
-
numClasses
int numClasses()Returns the number of classes.- Returns:
- the number of classes.
-
classes
int[] classes()Returns the class labels.- Returns:
- the class labels.
-
predict
Predicts the class label of an instance.- Parameters:
x- the instance to be classified.- Returns:
- the predicted class label.
-
score
The raw prediction score.- Parameters:
x- the instance to be classified.- Returns:
- the raw prediction score.
-
applyAsInt
- Specified by:
applyAsIntin interfaceToIntFunction<T>
-
applyAsDouble
- Specified by:
applyAsDoublein interfaceToDoubleFunction<T>
-
predict
Predicts the class labels of an array of instances.- Parameters:
x- the instances to be classified.- Returns:
- the predicted class labels.
-
predict
-
predict
-
soft
default boolean soft()Returns true if this is a soft classifier that can estimate the posteriori probabilities of classification.- Returns:
- true if soft classifier.
-
predict
Predicts the class label of an instance and also calculate a posteriori probabilities. Classifiers may NOT support this method since not all classification algorithms are able to calculate such a posteriori probabilities.- Parameters:
x- an instance to be classified.posteriori- a posteriori probabilities on output.- Returns:
- the predicted class label
-
predict
Predicts the class labels of an array of instances.- Parameters:
x- the instances to be classified.posteriori- a posteriori probabilities on output.- Returns:
- the predicted class labels.
-
predict
-
predict
-
online
default boolean online()Returns true if this is an online learner.- Returns:
- true if online learner.
-
update
Online update the classifier with a new training instance. In general, this method may be NOT multi-thread safe.- Parameters:
x- the training instance.y- the training label.
-
update
Updates the model with a mini-batch of new samples.- Parameters:
x- the training instances.y- the training labels.
-
update
-
ensemble
Return an ensemble of multiple base models to obtain better predictive performance.- Type Parameters:
T- the type of model input object.- Parameters:
models- the base models.- Returns:
- the ensemble model.
-