Package weka.gui

Class AttributeSelectionPanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class AttributeSelectionPanel
    extends JPanel
    Creates a panel that displays the attributes contained in a set of instances, letting the user toggle whether each attribute is selected or not (eg: so that unselected attributes can be removed before classification).
    Besides the All, None and Invert button one can also choose attributes which names match a regular expression (Pattern button). E.g. for removing all attributes that contain an ID and therefore unwanted information, one can match all names that contain "id" in the name:
     (.*_id_.*|.*_id$|^id$)
     
    This does not match e.g. "humidity", which could be an attribute we would like to keep.
    Version:
    $Revision$
    Author:
    Len Trigg (trigg@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • AttributeSelectionPanel

        public AttributeSelectionPanel()
        Creates the attribute selection panel with no initial instances.
      • AttributeSelectionPanel

        public AttributeSelectionPanel​(boolean include,
                                       boolean remove,
                                       boolean invert,
                                       boolean pattern)
        Creates the attribute selection panel with no initial instances.
        Parameters:
        include - true if the include button is to be shown
        remove - true if the remove button is to be shown
        invert - true if the invert button is to be shown
        patter - true if the pattern button is to be shown
    • Method Detail

      • getPreferredScrollableViewportSize

        public Dimension getPreferredScrollableViewportSize()
      • setPreferredScrollableViewportSize

        public void setPreferredScrollableViewportSize​(Dimension d)
      • setInstances

        public void setInstances​(Instances newInstances)
        Sets the instances who's attribute names will be displayed.
        Parameters:
        newInstances - the new set of instances
      • getSelectedAttributes

        public int[] getSelectedAttributes()
        Gets an array containing the indices of all selected attributes.
        Returns:
        the array of selected indices.
      • setSelectedAttributes

        public void setSelectedAttributes​(boolean[] selected)
                                   throws Exception
        Set the selected attributes in the widget. Note that setInstances() must have been called first.
        Parameters:
        selected - an array of boolean indicating which attributes are to have their check boxes selected.
        Throws:
        Exception - if the supplied array of booleans does not have the same number of elements as there are attributes.
      • getTableModel

        public TableModel getTableModel()
        Get the table model in use (or null if no instances have been set yet).
        Returns:
        the table model in use or null if no instances have been seen yet.
      • getSelectionModel

        public ListSelectionModel getSelectionModel()
        Gets the selection model used by the table.
        Returns:
        a value of type 'ListSelectionModel'
      • main

        public static void main​(String[] args)
        Tests the attribute selection panel from the command line.
        Parameters:
        args - must contain the name of an arff file to load.