Class Perceptron

    • Field Detail

      • constantLearningRatioDecayOption

        public FlagOption constantLearningRatioDecayOption
      • learningRatioOption

        public FloatOption learningRatioOption
      • learningRateDecayOption

        public FloatOption learningRateDecayOption
      • fadingFactorOption

        public FloatOption fadingFactorOption
      • randomSeedOption

        public IntOption randomSeedOption
      • fadingFactor

        protected double fadingFactor
      • learningRatio

        protected double learningRatio
      • learningRateDecay

        protected double learningRateDecay
      • weightAttribute

        protected double[] weightAttribute
      • perceptronattributeStatistics

        public DoubleVector perceptronattributeStatistics
      • squaredperceptronattributeStatistics

        public DoubleVector squaredperceptronattributeStatistics
      • perceptronInstancesSeen

        protected double perceptronInstancesSeen
      • perceptronYSeen

        protected double perceptronYSeen
      • accumulatedError

        protected double accumulatedError
      • initialisePerceptron

        protected boolean initialisePerceptron
      • perceptronsumY

        protected double perceptronsumY
      • squaredperceptronsumY

        protected double squaredperceptronsumY
      • numericAttributesIndex

        protected int[] numericAttributesIndex
    • Constructor Detail

      • Perceptron

        public Perceptron()
    • Method Detail

      • setWeights

        public void setWeights​(double[] w)
      • getWeights

        public double[] getWeights()
      • getInstancesSeen

        public double getInstancesSeen()
      • setInstancesSeen

        public void setInstancesSeen​(int pInstancesSeen)
      • reset

        public void reset()
      • resetError

        public void resetError()
      • trainOnInstanceImpl

        public void trainOnInstanceImpl​(Instance inst)
        Update the model using the provided instance
        Specified by:
        trainOnInstanceImpl in class AbstractClassifier
        Parameters:
        inst - the instance to be used for training
      • normalizedPrediction

        public double normalizedPrediction​(Instance inst)
      • prediction

        public double prediction​(double[] instanceValues)
      • normalizedInstance

        public double[] normalizedInstance​(Instance inst)
      • computeSD

        public double computeSD​(double squaredVal,
                                double val,
                                double size)
      • updateWeights

        public void updateWeights​(Instance inst,
                                  double learningRatio)
      • normalizeWeights

        public void normalizeWeights()
      • isRandomizable

        public boolean isRandomizable()
        Description copied from interface: Learner
        Gets whether this learner needs a random seed. Examples of methods that needs a random seed are bagging and boosting.
        Specified by:
        isRandomizable in interface Learner<Example<Instance>>
        Returns:
        true if the learner needs a random seed.
      • getVotesForInstance

        public double[] getVotesForInstance​(Instance inst)
        Description copied from interface: Classifier
        Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero.
        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
      • getModelMeasurementsImpl

        protected Measurement[] getModelMeasurementsImpl()
        Description copied from class: AbstractClassifier
        Gets the current measurements of this classifier.

        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:
        getModelMeasurementsImpl in class AbstractClassifier
        Returns:
        an array of measurements to be used in evaluation tasks
      • 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
      • setLearningRatio

        public void setLearningRatio​(double learningRatio)