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.

    - accepts:
    - generates:

    -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.
    -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)
    -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 
        default: false
    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).
        value - the message
      • getMessage

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

        public String messageTipText()
        Returns the tip text for this property.
        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.
        value - the expression
      • isPreSelection

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

        public String preSelectionTipText()
        Returns the tip text for this property.
        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
        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
        the Class of the generated tokens
      • selectAttributes

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

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

        protected weka.core.Instances filter​(weka.core.Instances inst,
                                             List<Integer> selected)
                                      throws Exception
        Filters the data.
        inst - the data to filter
        selected - the selected attributes
        the new dataset
        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.
        inst - the instances to process
        selected - the indices to select
        true if successfully generated