Class Corr

  • All Implemented Interfaces:
    Serializable, Cloneable, weka.classifiers.Classifier, weka.core.BatchPredictor, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.CommandlineRunnable, weka.core.OptionHandler, weka.core.RevisionHandler, weka.core.WeightedInstancesHandler

    public class Corr
    extends weka.classifiers.SingleClassifierEnhancer
    implements weka.core.WeightedInstancesHandler
    Assume NO MISSING VALUES, all attributes must be NUMERIC (or 0/1 maybe ...). Simple attribute selection for regression: select k most correlated attrs ...

    Valid options are:

     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -W
      Full name of base classifier.
      (default: weka.classifiers.functions.LinearRegression)
     Options specific to classifier weka.classifiers.rules.ZeroR:
     
     -D
      If set, classifier is run in debug mode and
      may output additional info to the console
     -K <int>
      The number of attrs. (default: 0 = numEx/2)
    Version:
    $Revision$
    Author:
    ???
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int m_classIndex  
      protected double[] m_coeffs  
      protected int m_k  
      protected weka.filters.unsupervised.attribute.Remove m_remove  
      protected int[] m_subset  
      • Fields inherited from class weka.classifiers.SingleClassifierEnhancer

        m_Classifier
      • Fields inherited from class weka.classifiers.AbstractClassifier

        BATCH_SIZE_DEFAULT, m_BatchSize, m_Debug, m_DoNotCheckCapabilities, m_numDecimalPlaces, NUM_DECIMAL_PLACES_DEFAULT
    • Constructor Summary

      Constructors 
      Constructor Description
      Corr()  
    • Field Detail

      • m_remove

        protected weka.filters.unsupervised.attribute.Remove m_remove
      • m_classIndex

        protected int m_classIndex
      • m_k

        protected int m_k
      • m_subset

        protected int[] m_subset
      • m_coeffs

        protected double[] m_coeffs
    • Constructor Detail

      • Corr

        public Corr()
    • Method Detail

      • defaultClassifierString

        protected String defaultClassifierString()
        String describing default classifier.
        Overrides:
        defaultClassifierString in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        the default classifier
      • globalInfo

        public String globalInfo()
        Returns a string describing classifier.
        Returns:
        a description suitable for displaying in the explorer/experimenter gui
      • listOptions

        public Enumeration listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses a given list of options. Valid options are:

         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
         -W
          Full name of base classifier.
          (default: weka.classifiers.functions.LinearRegression)
         Options specific to classifier weka.classifiers.rules.ZeroR:
         
         -D
          If set, classifier is run in debug mode and
          may output additional info to the console
         -K <int>
          The number of attrs. (default: 0 = numEx/2)
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.classifiers.SingleClassifierEnhancer
        Parameters:
        options - the list of options as an array of strings
        Throws:
        Exception - if an option is not supported
      • getOptions

        public String[] getOptions()
        Gets the current settings of the Classifier.
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.classifiers.SingleClassifierEnhancer
        Returns:
        an array of strings suitable for passing to setOptions
      • getNumattrs

        public int getNumattrs()
      • setNumattrs

        public void setNumattrs​(int k)
      • numattrsTipText

        public String numattrsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • sampleCorrs

        public double[] sampleCorrs​(weka.core.Instances data)
      • sumXY

        public double[] sumXY​(weka.core.Instances data)
      • sampleDevs

        public double[] sampleDevs​(weka.core.Instances data,
                                   double[] mean)
      • msq

        public double[] msq​(weka.core.Instances data)
      • means

        public double[] means​(weka.core.Instances data)
      • keepIndices

        public String keepIndices​(weka.core.Instances data)
      • keepIndicesBasedOnCorrelation

        public String keepIndicesBasedOnCorrelation​(weka.core.Instances data)
      • getSubset

        public weka.core.Instances getSubset​(weka.core.Instances data)
                                      throws Exception
        Throws:
        Exception
      • buildClassifier

        public void buildClassifier​(weka.core.Instances data)
                             throws Exception
        Builds the classifier.
        Specified by:
        buildClassifier in interface weka.classifiers.Classifier
        Parameters:
        data - the training data
        Throws:
        Exception - if something goes wrong
      • classifyInstance

        public double classifyInstance​(weka.core.Instance instance)
                                throws Exception
        Returns the prediction.
        Specified by:
        classifyInstance in interface weka.classifiers.Classifier
        Overrides:
        classifyInstance in class weka.classifiers.AbstractClassifier
        Parameters:
        instance - the instance to classify
        Returns:
        the prediction
        Throws:
        Exception - if prediction fails
      • getCoeffs

        public double[] getCoeffs()
      • getSubset

        public int[] getSubset()
      • toString

        public String toString()
        Returns description of classifier.
        Overrides:
        toString in class Object
        Returns:
        the model
      • getRevision

        public String getRevision()
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Overrides:
        getRevision in class weka.classifiers.AbstractClassifier
      • main

        public static void main​(String[] argv)
                         throws Exception
        Main method for testing this class.
        Parameters:
        argv - the options
        Throws:
        Exception