Class WekaChooseAttributes

  • All Implemented Interfaces:
    AdditionalInformationHandler, CleanUpHandler, Destroyable, GlobalInfoSupporter, LoggingLevelHandler, LoggingSupporter, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<Actor>, SizeOfHandler, Stoppable, StoppableWithFeedback, VariablesInspectionHandler, VariableChangeListener, Actor, AutomatableInteraction, AutomatableInteractiveActor, ErrorHandler, InputConsumer, InteractiveActor, InteractiveActorWithCustomParentComponent, OutputProducer, StopModeSupporter, Serializable, Comparable

    public class WekaChooseAttributes
    extends AbstractInteractiveTransformer
    implements AutomatableInteractiveActor
    Lets the user select attributes interactively to use down the track.
    Internally, a weka.filters.unsupervised.attribute.Remove WEKA filter is constructed from the selection, to remove the attributes that the user didn't select.

    Input/output:
    - accepts:
       weka.core.Instances
    - generates:
       weka.core.Instances


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: WekaChooseAttributes
     
    -annotation <adams.core.base.BaseAnnotation> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
        default: false
     
    -silent <boolean> (property: silent)
        If enabled, then no errors are output in the console.
        default: false
     
    -stop-if-canceled <boolean> (property: stopFlowIfCanceled)
        If enabled, the flow gets stopped in case the user cancels the dialog.
        default: false
     
    -custom-stop-message <java.lang.String> (property: customStopMessage)
        The custom stop message to use in case a user cancelation stops the flow 
        (default is the full name of the actor)
        default: 
     
    -message <java.lang.String> (property: message)
        The message to display to the user (variables get expanded).
        default: Choose attributes to use
     
    -pre-selection <adams.core.base.BaseRegExp> (property: preSelection)
        The regular expression to use for pre-selecting attributes.
        default: .*
     
    -non-interactive <boolean> (property: nonInteractive)
        If enabled, attributes that match the 'pre-selection' pattern get selected 
        automatically.
        default: false
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Detail

      • m_Message

        protected String m_Message
        the message to display to the user.
      • m_PreSelection

        protected BaseRegExp m_PreSelection
        the regular expression for pre-selecting attributes by name.
      • m_NonInteractive

        protected boolean m_NonInteractive
        whether to automate the actor.
      • m_Remove

        protected weka.filters.unsupervised.attribute.Remove m_Remove
        the Remove filter in use.
    • Constructor Detail

      • WekaChooseAttributes

        public WekaChooseAttributes()
    • Method Detail

      • setMessage

        public void setMessage​(String value)
        Sets the message to display to the user (variables get expanded).
        Parameters:
        value - the message
      • getMessage

        public String getMessage()
        Returns the message to display to the user (variables get expanded).
        Returns:
        the message
      • messageTipText

        public String messageTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setPreSelection

        public void setPreSelection​(BaseRegExp value)
        Sets the regular expression to pre-select attributes for the dialog.
        Parameters:
        value - the expression
      • isPreSelection

        public BaseRegExp isPreSelection()
        Returns the regular expression to pre-select attributes for the dialog.
        Returns:
        the expression
      • preSelectionTipText

        public String preSelectionTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Specified by:
        accepts in interface InputConsumer
        Returns:
        the Class of objects that can be processed
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Specified by:
        generates in interface OutputProducer
        Returns:
        the Class of the generated tokens
      • selectAttributes

        protected List<Integer> selectAttributes​(weka.core.Instances inst,
                                                 List<Integer> preSelected)
        Prompts the user to select attributes.
        Parameters:
        inst - the data to present
        preSelected - the indices of the attributes to use by default
        Returns:
        the list of selected attributes to keep, null if cancelled
      • getPreSelectedIndices

        protected List<Integer> getPreSelectedIndices​(weka.core.Instances inst)
        Returns the pre-selected indices.
        Parameters:
        inst - the dataset to work on
        Returns:
        the indices
      • filter

        protected weka.core.Instances filter​(weka.core.Instances inst,
                                             List<Integer> selected)
                                      throws Exception
        Filters the data.
        Parameters:
        inst - the data to filter
        selected - the selected attributes
        Returns:
        the new dataset
        Throws:
        Exception - in case filtering fails
      • generateOutput

        protected boolean generateOutput​(weka.core.Instances inst,
                                         List<Integer> selected)
        Creates the output token with the subset of data.
        Parameters:
        inst - the instances to process
        selected - the indices to select
        Returns:
        true if successfully generated