Package de.jungblut.classification.meta
Class Voter<A extends Classifier>
- java.lang.Object
-
- de.jungblut.classification.AbstractPredictor
-
- de.jungblut.classification.AbstractClassifier
-
- de.jungblut.classification.meta.Voter<A>
-
- All Implemented Interfaces:
Classifier,Predictor
public final class Voter<A extends Classifier> extends AbstractClassifier
Implementation of vote ensembling. This features multithreading, different combination and selection techniques.- Author:
- thomas.jungblut
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVoter.CombiningTypestatic classVoter.SelectionType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K extends Classifier>
Voter<K>create(int numClassifiers, Voter.CombiningType type, ClassifierFactory<K> classifierFactory)Creates a new voting classificator.static <K extends Classifier>
Voter<K>fromTrainedModels(java.util.List<K> classifier)Creates a voter from the given trained models for prediction purposes.Classifier[]getClassifier()Voter<A>numThreads(int threads)de.jungblut.math.DoubleVectorpredict(de.jungblut.math.DoubleVector features)Classifies the given features.Voter<A>selectionType(Voter.SelectionType type)Voter<A>setCombiningType(Voter.CombiningType type)voidtrain(de.jungblut.math.DoubleVector[] features, de.jungblut.math.DoubleVector[] outcome)Trains this classifier with the given features and the outcome.Voter<A>verbose()Voter<A>verbose(boolean verb)-
Methods inherited from class de.jungblut.classification.AbstractClassifier
train
-
Methods inherited from class de.jungblut.classification.AbstractPredictor
extractPredictedClass, extractPredictedClass, predictedClass, predictedClass, predictProbability
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.jungblut.classification.Predictor
asClassifier, extractPredictedClass, extractPredictedClass, predictedClass, predictedClass, predictProbability
-
-
-
-
Method Detail
-
train
public void train(de.jungblut.math.DoubleVector[] features, de.jungblut.math.DoubleVector[] outcome)Description copied from interface:ClassifierTrains this classifier with the given features and the outcome.- Specified by:
trainin interfaceClassifier- Overrides:
trainin classAbstractClassifieroutcome- the outcome must have classes labeled as doubles. E.G. in the binary case you have a single element and decide between 0d and 1d. In higher dimensional cases you have each of these single elements mapped to a dimension.
-
predict
public de.jungblut.math.DoubleVector predict(de.jungblut.math.DoubleVector features)
Description copied from interface:PredictorClassifies the given features.- Returns:
- the vector that contains an indicator at the index of the class. Usually zero or 1, in some cases it is a probability or activation value.
-
getClassifier
public Classifier[] getClassifier()
-
verbose
public Voter<A> verbose(boolean verb)
- Returns:
- sets this instance to verbose and returns it.
-
selectionType
public Voter<A> selectionType(Voter.SelectionType type)
- Returns:
- sets the selection type and returns this instance.
-
numThreads
public Voter<A> numThreads(int threads)
- Returns:
- sets the number of threads and returns this instance.
-
setCombiningType
public Voter<A> setCombiningType(Voter.CombiningType type)
- Returns:
- sets the used combination type in this instance and returns it.
-
create
public static <K extends Classifier> Voter<K> create(int numClassifiers, Voter.CombiningType type, ClassifierFactory<K> classifierFactory)
Creates a new voting classificator. The training is single threaded, no shuffling or bagging takes place.- Parameters:
numClassifiers- the number of base classifiers to use.type- the combining type to use.classifierFactory- the classifier factory to create base classifiers.- Returns:
- a new Voter.
-
fromTrainedModels
public static <K extends Classifier> Voter<K> fromTrainedModels(java.util.List<K> classifier)
Creates a voter from the given trained models for prediction purposes.- Parameters:
classifier-- Returns:
-
-