Class Voter<A extends Classifier>

  • 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
    • Method Detail

      • train

        public void train​(de.jungblut.math.DoubleVector[] features,
                          de.jungblut.math.DoubleVector[] outcome)
        Description copied from interface: Classifier
        Trains this classifier with the given features and the outcome.
        Specified by:
        train in interface Classifier
        Overrides:
        train in class AbstractClassifier
        outcome - 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: Predictor
        Classifies 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()
        Returns:
        sets this instance to verbose and returns it.
      • 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 ClassifierVoter<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 ClassifierVoter<K> fromTrainedModels​(java.util.List<K> classifier)
        Creates a voter from the given trained models for prediction purposes.
        Parameters:
        classifier -
        Returns: