public class OneVersusOne<T> extends java.lang.Object implements SoftClassifier<T>
K (K − 1) / 2 binary classifiers for a
K-way multiclass problem; each receives the samples of a pair of
classes from the original training set, and must learn to distinguish
these two classes. At prediction time, a voting scheme is applied:
all K (K − 1) / 2 classifiers are applied to an unseen
sample and the class that got the highest number of positive predictions
gets predicted by the combined classifier. Like One-vs-rest, one-vs-one
suffers from ambiguities in that some regions of its input space may
receive the same number of votes.| Constructor and Description |
|---|
OneVersusOne(Classifier<T>[][] classifiers,
PlattScaling[][] platts)
Constructor.
|
OneVersusOne(Classifier<T>[][] classifiers,
PlattScaling[][] platts,
smile.util.IntSet labels)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static DataFrameClassifier |
fit(smile.data.formula.Formula formula,
smile.data.DataFrame data,
java.util.function.BiFunction<smile.data.formula.Formula,smile.data.DataFrame,DataFrameClassifier> trainer)
Fits a multi-class model with binary data frame classifiers.
|
static <T> OneVersusOne<T> |
fit(T[] x,
int[] y,
java.util.function.BiFunction<T[],int[],Classifier<T>> trainer)
Fits a multi-class model with binary classifiers.
|
static <T> OneVersusOne<T> |
fit(T[] x,
int[] y,
int pos,
int neg,
java.util.function.BiFunction<T[],int[],Classifier<T>> trainer)
Fits a multi-class model with binary classifiers.
|
int |
predict(T x)
Prediction is based on voting.
|
int |
predict(T x,
double[] posteriori)
Prediction is based posteriori probability estimation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpredictapplyAsDouble, applyAsInt, predict, scorepublic OneVersusOne(Classifier<T>[][] classifiers, PlattScaling[][] platts)
classifiers - the binary classifier for each one-vs-one case.
Only the lower half is needed.public OneVersusOne(Classifier<T>[][] classifiers, PlattScaling[][] platts, smile.util.IntSet labels)
classifiers - the binary classifier for each one-vs-one case.
Only the lower half is needed.labels - the class labels.public static <T> OneVersusOne<T> fit(T[] x, int[] y, java.util.function.BiFunction<T[],int[],Classifier<T>> trainer)
x - the training samples.y - the training labels.trainer - the lambda to train binary classifiers.public static <T> OneVersusOne<T> fit(T[] x, int[] y, int pos, int neg, java.util.function.BiFunction<T[],int[],Classifier<T>> trainer)
x - the training samples.y - the training labels.pos - the class label for one case.neg - the class label for rest cases.trainer - the lambda to train binary classifiers.public static DataFrameClassifier fit(smile.data.formula.Formula formula, smile.data.DataFrame data, java.util.function.BiFunction<smile.data.formula.Formula,smile.data.DataFrame,DataFrameClassifier> trainer)
formula - a symbolic description of the model to be fitted.data - the data frame of the explanatory and response variables.trainer - the lambda to train binary classifiers.public int predict(T x)
predict in interface Classifier<T>x - the instance to be classified.public int predict(T x, double[] posteriori)
predict in interface SoftClassifier<T>x - an instance to be classified.posteriori - a posteriori probabilities on output.