Class Instances

    • Field Detail

      • ARFF_RELATION

        public static final String ARFF_RELATION
        The keyword used to denote the start of an arff header
        See Also:
        Constant Field Values
      • ARFF_DATA

        public static final String ARFF_DATA
        The keyword used to denote the start of the arff data section
        See Also:
        Constant Field Values
      • instanceInformation

        protected InstanceInformation instanceInformation
        The instance information.
      • instances

        protected List<Instance> instances
        The instances.
      • hsAttributesIndices

        protected HashMap<String,​Integer> hsAttributesIndices
        A Hash that stores the indices of features.
      • indicesRelevants

        protected int[] indicesRelevants
        Indices of relevant features.
      • indicesIrrelevants

        protected int[] indicesIrrelevants
        Indices of irrelevant features.
    • Constructor Detail

      • Instances

        public Instances​(Instances chunk)
        Instantiates a new instances.
        Parameters:
        chunk - the chunk
      • Instances

        public Instances()
        Instantiates a new instances.
      • Instances

        public Instances​(Reader reader,
                         int size,
                         int classAttribute)
        Instantiates a new instances.
        Parameters:
        reader - the reader
        size - the size
        classAttribute - the class attribute
      • Instances

        public Instances​(Reader reader,
                         Range range)
        Instantiates a new instances.
        Parameters:
        reader - the reader
        range -
      • Instances

        public Instances​(Instances chunk,
                         int capacity)
        Instantiates a new instances.
        Parameters:
        chunk - the chunk
        capacity - the capacity
      • Instances

        public Instances​(String st,
                         Attribute[] v,
                         int capacity)
        Instantiates a new instances.
        Parameters:
        st - the st
        v - the v
        capacity - the capacity
      • Instances

        public Instances​(String st,
                         List<Attribute> v,
                         int capacity)
        Instantiates a new instances.
        Parameters:
        st - the st
        v - the v
        capacity - the capacity
      • Instances

        public Instances​(Instances chunk,
                         int first,
                         int toCopy)
        Instantiates a new instances.
        Parameters:
        chunk - the chunk
        first - the first instance
        toCopy - the j
      • Instances

        public Instances​(StringReader st,
                         int capacity)
        Instantiates a new instances.
        Parameters:
        st - the st
        capacity - the capacity
    • Method Detail

      • setRelationName

        public void setRelationName​(String string)
        Sets the relation name.
        Parameters:
        string - the new relation name
      • getRelationName

        public String getRelationName()
        Gets the relation name.
        Returns:
        the relation name
      • classIndex

        public int classIndex()
        Class index.
        Returns:
        the int
      • setClassIndex

        public void setClassIndex​(int classIndex)
        Sets the class index.
        Parameters:
        classIndex - the new class index
      • classAttribute

        public Attribute classAttribute()
        Class attribute.
        Returns:
        the attribute
      • numAttributes

        public int numAttributes()
        Num attributes.
        Returns:
        the int
      • attribute

        public Attribute attribute​(int w)
        Attribute.
        Parameters:
        w - the w
        Returns:
        the attribute
      • numClasses

        public int numClasses()
        Num classes.
        Returns:
        the int
      • deleteAttributeAt

        public void deleteAttributeAt​(Integer integer)
        Delete attribute at.
        Parameters:
        integer - the integer
      • insertAttributeAt

        public void insertAttributeAt​(Attribute attribute,
                                      int position)
        Insert attribute at.
        Parameters:
        attribute - the attribute
        position - the position
      • instance

        public Instance instance​(int num)
        Instance.
        Parameters:
        num - the num
        Returns:
        the instance
      • numInstances

        public int numInstances()
        Num instances.
        Returns:
        the int
      • add

        public void add​(Instance inst)
        Adds the.
        Parameters:
        inst - the inst
      • randomize

        public void randomize​(Random random)
        Randomize.
        Parameters:
        random - the random
      • stratify

        public void stratify​(int numFolds)
        Stratify.
        Parameters:
        numFolds - the num folds
      • stratStep

        protected void stratStep​(int numFolds)
      • trainCV

        public Instances trainCV​(int numFolds,
                                 int numFold,
                                 Random random)
        Train cv.
        Parameters:
        numFolds - the num folds
        numFold -
        random - the random
        Returns:
        the instances
      • trainCV

        public Instances trainCV​(int numFolds,
                                 int numFold)
      • copyInstances

        protected void copyInstances​(int from,
                                     Instances dest,
                                     int num)
      • testCV

        public Instances testCV​(int numFolds,
                                int numFold)
        Test cv.
        Parameters:
        numFolds - the num folds
        numFold - the num fold
        Returns:
        the instances
      • meanOrMode

        public double meanOrMode​(int j)
        Mean or mode.
        Parameters:
        j - the j
        Returns:
        the double
      • readInstance

        public boolean readInstance​(Reader fileReader)
        Read instance.
        Parameters:
        fileReader - the file reader
        Returns:
        true, if successful
      • delete

        public void delete()
        Delete.
      • delete

        public void delete​(int index)
        Delete.
      • swap

        public void swap​(int i,
                         int j)
        Swap.
        Parameters:
        i - the i
        j - the j
      • size

        public int size()
      • set

        public void set​(int i,
                        Instance inst)
      • setRangeOutputIndices

        public void setRangeOutputIndices​(Range range)
      • setAttributes

        public void setAttributes​(Attribute[] v)
      • setAttributes

        public void setAttributes​(Attribute[] v,
                                  int[] indexValues)
      • toString

        public String toString()
        Returns the dataset as a string in ARFF format. Strings are quoted if they contain whitespace characters, or if they are a question mark.
        Overrides:
        toString in class Object
        Returns:
        the dataset in ARFF format as a string
      • stringWithoutHeader

        protected String stringWithoutHeader()
        Returns the instances in the dataset as a string in ARFF format. Strings are quoted if they contain whitespace characters, or if they are a question mark.
        Returns:
        the dataset in ARFF format as a string
      • indexOf

        protected int indexOf​(Attribute att)
        Returns the index of an Attribute.
        Parameters:
        att - , the attribute.
      • getIndicesRelevants

        public int[] getIndicesRelevants()
        Returns the indices of the relevant features indicesRelevants.
        Returns:
        indicesRelevants
      • getIndicesIrrelevants

        public int[] getIndicesIrrelevants()
        Returns the indices of the irrelevant features indicesIrrelevants.
        Returns:
        indicesIrrelevants
      • setIndicesRelevants

        public void setIndicesRelevants​(int[] indicesRelevants)
        Sets the indices of relevant features. This method also sets the irrelevant ones since it is the set complement.
        Parameters:
        indicesRelevants -