jsat.classifiers
Class OneVSAll
- java.lang.Object
-
- jsat.classifiers.OneVSAll
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Classifier, Parameterized
public class OneVSAll extends java.lang.Object implements Classifier, Parameterized
This classifier turns any classifier, specifically binary classifiers, into multi-class classifiers. For a problem with k target classes, OneVsALl will create k different classifiers. Each one is a reducing of one class against all other classes. Then all k classifiers's results are summed to produce a final classifier
If the base learner is an instance ofBinaryScoreClassifier, then the winning class label will be the associated classifier that produced the highest score.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description OneVSAll(Classifier baseClassifier)Creates a new One VS All classifier.OneVSAll(Classifier baseClassifier, boolean concurrentTraining)Creates a new One VS All classifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description CategoricalResultsclassify(DataPoint data)Performs classification on the given data point.OneVSAllclone()voidsetConcurrentTraining(boolean concurrentTraining)Controls what method of parallel training to use when#train(jsat.classifiers.ClassificationDataSet, java.util.concurrent.ExecutorService)is called.booleansupportsWeightedData()Indicates whether the model knows how to train using weighted data points.voidtrain(ClassificationDataSet dataSet, boolean parallel)Trains the classifier and constructs a model for classification using the given data set.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.classifiers.Classifier
train
-
Methods inherited from interface jsat.parameters.Parameterized
getParameter, getParameters
-
-
-
-
Constructor Detail
-
OneVSAll
public OneVSAll(Classifier baseClassifier)
Creates a new One VS All classifier.- Parameters:
baseClassifier- the base classifier to replicate- See Also:
setConcurrentTraining(boolean)
-
OneVSAll
public OneVSAll(Classifier baseClassifier, boolean concurrentTraining)
Creates a new One VS All classifier.- Parameters:
baseClassifier- the base classifier to replicateconcurrentTraining- controls whether or not classifiers are trained simultaneously or using sequentially using theirClassifier#train(jsat.classifiers.ClassificationDataSet, java.util.concurrent.ExecutorService)method.- See Also:
setConcurrentTraining(boolean)
-
-
Method Detail
-
setConcurrentTraining
public void setConcurrentTraining(boolean concurrentTraining)
Controls what method of parallel training to use when#train(jsat.classifiers.ClassificationDataSet, java.util.concurrent.ExecutorService)is called. If set to true, each of the k classifiers will be trained in parallel, using their serial algorithms. If set to false, the k classifiers will be trained sequentially, calling theClassifier#train(jsat.classifiers.ClassificationDataSet, java.util.concurrent.ExecutorService)for each classifier.
This should be set to true for classifiers that do not support parallel training.
Setting this to true also uses k times the memory, since each classifier is being created and trained at the same time.- Parameters:
concurrentTraining- whether or not to train the classifiers in parallel
-
classify
public CategoricalResults classify(DataPoint data)
Description copied from interface:ClassifierPerforms classification on the given data point.- Specified by:
classifyin interfaceClassifier- Parameters:
data- the data point to classify- Returns:
- the results of the classification.
-
train
public void train(ClassificationDataSet dataSet, boolean parallel)
Description copied from interface:ClassifierTrains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.- Specified by:
trainin interfaceClassifier- Parameters:
dataSet- the data set to train onparallel-trueif multiple threads should be used to train the model.falseif it should be done in a single threaded manner.
-
clone
public OneVSAll clone()
- Specified by:
clonein interfaceClassifier- Overrides:
clonein classjava.lang.Object
-
supportsWeightedData
public boolean supportsWeightedData()
Description copied from interface:ClassifierIndicates whether the model knows how to train using weighted data points. If it does, the model will train assuming the weights. The values returned by this method may change depending on the parameters set for the model.- Specified by:
supportsWeightedDatain interfaceClassifier- Returns:
- true if the model supports weighted data, false otherwise
-
-
DataMelt 3.0 © DataMelt by jWork.ORG