Class AccuracyWeightedEnsemble

    • Field Detail

      • weightComparator

        protected static Comparator<double[]> weightComparator
        Simple weight comparator.
      • learnerOption

        public ClassOption learnerOption
        Type of classifier to use as a component classifier.
      • memberCountOption

        public FloatOption memberCountOption
        Number of component classifiers.
      • storedCountOption

        public FloatOption storedCountOption
        Number of classifiers remembered and available for ensemble construction.
      • chunkSizeOption

        public IntOption chunkSizeOption
        Chunk size.
      • numFoldsOption

        public IntOption numFoldsOption
        Number of folds in candidate classifier cross-validation.
      • classDistributions

        protected long[] classDistributions
      • storedLearners

        protected Classifier[] storedLearners
      • ensembleWeights

        protected double[] ensembleWeights
      • storedWeights

        protected double[][] storedWeights
        The weights of stored classifiers. storedWeights[x][0] = weight storedWeights[x][1] = classifier
      • processedInstances

        protected int processedInstances
      • chunkSize

        protected int chunkSize
      • numFolds

        protected int numFolds
      • maxMemberCount

        protected int maxMemberCount
      • maxStoredCount

        protected int maxStoredCount
      • candidateClassifier

        protected Classifier candidateClassifier
      • currentChunk

        protected Instances currentChunk
    • Constructor Detail

      • AccuracyWeightedEnsemble

        public AccuracyWeightedEnsemble()
    • Method Detail

      • prepareForUseImpl

        public void prepareForUseImpl​(TaskMonitor monitor,
                                      ObjectRepository repository)
        Description copied from class: AbstractOptionHandler
        This method describes the implementation of how to prepare this object for use. All classes that extends this class have to implement prepareForUseImpl and not prepareForUse since prepareForUse calls prepareForUseImpl.
        Overrides:
        prepareForUseImpl in class AbstractClassifier
        Parameters:
        monitor - the TaskMonitor to use
        repository - the ObjectRepository to use
      • resetLearningImpl

        public void resetLearningImpl()
        Description copied from class: AbstractClassifier
        Resets this classifier. It must be similar to starting a new classifier from scratch.

        The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.
        Specified by:
        resetLearningImpl in class AbstractClassifier
      • trainOnInstanceImpl

        public void trainOnInstanceImpl​(Instance inst)
        Description copied from class: AbstractClassifier
        Trains this classifier incrementally using the given instance.

        The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.
        Specified by:
        trainOnInstanceImpl in class AbstractClassifier
        Parameters:
        inst - the instance to be used for training
      • processChunk

        protected void processChunk()
        Processes a chunk.
      • computeCandidateWeight

        protected double computeCandidateWeight​(Classifier candidate,
                                                Instances chunk,
                                                int numFolds)
        Computes the weight of a candidate classifier.
        Parameters:
        candidate - Candidate classifier.
        chunk - Data chunk of examples.
        numFolds - Number of folds in candidate classifier cross-validation.
        Returns:
        Candidate classifier weight.
      • computeWeight

        protected double computeWeight​(Classifier learner,
                                       Instances chunk)
        Computes the weight of a given classifie.
        Parameters:
        learner - Classifier to calculate weight for.
        chunk - Data chunk of examples.
        Returns:
        The given classifier's weight.
      • computeMseR

        protected double computeMseR()
        Computes the MSEr threshold.
        Returns:
        The MSEr threshold.
      • getVotesForInstance

        public double[] getVotesForInstance​(Instance inst)
        Predicts a class for an example.
        Specified by:
        getVotesForInstance in interface Classifier
        Specified by:
        getVotesForInstance in class AbstractClassifier
        Parameters:
        inst - the instance to be classified
        Returns:
        an array containing the estimated membership probabilities of the test instance in each class
      • getModelDescription

        public void getModelDescription​(StringBuilder out,
                                        int indent)
        Description copied from class: AbstractClassifier
        Returns a string representation of the model.
        Specified by:
        getModelDescription in class AbstractClassifier
        Parameters:
        out - the stringbuilder to add the description
        indent - the number of characters to indent
      • isRandomizable

        public boolean isRandomizable()
        Determines whether the classifier is randomizable.
        Specified by:
        isRandomizable in interface Learner<Example<Instance>>
        Returns:
        true if the learner needs a random seed.
      • addToStored

        protected Classifier addToStored​(Classifier newClassifier,
                                         double newClassifiersWeight)
        Adds a classifier to the storage.
        Parameters:
        newClassifier - The classifier to add.
        newClassifiersWeight - The new classifiers weight.
      • removePoorestModelBytes

        protected int removePoorestModelBytes()
        Removes the poorest classifier from the model, thus decreasing the models size.
        Returns:
        the size of the removed classifier.
      • discardModel

        protected void discardModel​(int index)
        Removes the classifier at a given index from the model, thus decreasing the models size.
        Parameters:
        index -