Package adams.ml.data

Class DefaultDataset

    • Field Detail

      • m_ClassAttributes

        protected HashSet<String> m_ClassAttributes
        the keys of the columns that act as class attribute.
    • Constructor Detail

      • DefaultDataset

        public DefaultDataset()
        Default constructor.
      • DefaultDataset

        public DefaultDataset​(SpreadSheet sheet)
        Initializes the dataset with the data from the spreadsheet.
        Parameters:
        sheet - the data to use
    • Method Detail

      • indexOfColumn

        public int indexOfColumn​(String name)
        Returns the index of the column using the specified name.
        Specified by:
        indexOfColumn in interface Dataset
        Parameters:
        name - the name of the column to locate
        Returns:
        the index, -1 if failed to locate
      • removeClassAttributes

        public void removeClassAttributes()
        Removes all set class attributes.
        Specified by:
        removeClassAttributes in interface Dataset
      • isClassAttribute

        public boolean isClassAttribute​(String colKey)
        Returns whether the specified column is a class attribute.
        Specified by:
        isClassAttribute in interface Dataset
        Parameters:
        colKey - they key of the column to query
        Returns:
        true if column a class attribute
      • isClassAttribute

        public boolean isClassAttribute​(int colIndex)
        Returns whether the specified column is a class attribute.
        Specified by:
        isClassAttribute in interface Dataset
        Parameters:
        colIndex - they index of the column to query
        Returns:
        true if column a class attribute
      • isClassAttributeByName

        public boolean isClassAttributeByName​(String name)
        Returns whether the specified column is a class attribute.
        Specified by:
        isClassAttributeByName in interface Dataset
        Parameters:
        name - they name of the column to query
        Returns:
        true if column a class attribute
      • setClassAttribute

        public boolean setClassAttribute​(String colKey,
                                         boolean isClass)
        Sets the class attribute status for a column.
        Specified by:
        setClassAttribute in interface Dataset
        Parameters:
        colKey - the column to set the class attribute status for
        isClass - if true then the column will be flagged as class attribute, otherwise the flag will get removed
        Returns:
        true if successfully updated
      • setClassAttribute

        public boolean setClassAttribute​(int colIndex,
                                         boolean isClass)
        Sets the class attribute status for a column.
        Specified by:
        setClassAttribute in interface Dataset
        Parameters:
        colIndex - the column to set the class attribute status for
        isClass - if true then the column will be flagged as class attribute, otherwise the flag will get removed
        Returns:
        true if successfully updated
      • setClassAttributeByName

        public boolean setClassAttributeByName​(String name,
                                               boolean isClass)
        Sets the class attribute status for a column.
        Specified by:
        setClassAttributeByName in interface Dataset
        Parameters:
        name - the name of the column to set the class attribute status for
        isClass - if true then the column will be flagged as class attribute, otherwise the flag will get removed
        Returns:
        true if successfully updated
      • getClassAttributeKeys

        public String[] getClassAttributeKeys()
        Returns all the class attributes that are currently set.
        Specified by:
        getClassAttributeKeys in interface Dataset
        Returns:
        the column keys of class attributes (not ordered)
      • getClassAttributeNames

        public String[] getClassAttributeNames()
        Returns all the class attributes that are currently set.
        Specified by:
        getClassAttributeNames in interface Dataset
        Returns:
        the column names of class attributes (not ordered)
      • getClassAttributeIndices

        public int[] getClassAttributeIndices()
        Returns all the class attributes that are currently set.
        Specified by:
        getClassAttributeIndices in interface Dataset
        Returns:
        the indices of class attributes (sorted asc)
      • getInputs

        public SpreadSheet getInputs()
        Returns a spreadsheet containing only the input columns, not class columns.
        Specified by:
        getInputs in interface Dataset
        Returns:
        the input features, null if data conists only of class columns
      • getOutputs

        public SpreadSheet getOutputs()
        Returns a spreadsheet containing only output columns, i.e., the class columns.
        Specified by:
        getOutputs in interface Dataset
        Returns:
        the output features, null if data has no class columns
      • toView

        public DatasetView toView​(int[] rows,
                                  int[] columns)
        Creates a view of the spreadsheet with the specified rows/columns.
        Specified by:
        toView in interface SpreadSheet
        Overrides:
        toView in class DefaultSpreadSheet
        Parameters:
        columns - the columns to use, null for all
        rows - the rows to use, null for all
        Returns:
        the view