~ubuntu-branches/ubuntu/vivid/weka/vivid

« back to all changes in this revision

Viewing changes to src/main/java/weka/filters/unsupervised/instance/RemoveWithValues.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2011-11-24 12:35:17 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20111124123517-kn23dn5u8pi4liq0
Tags: 3.6.6-1
* Team upload.
* New upstream version (Closes: #649734)
* Update rules and build-deps for default-jdk and default-jre.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
 *  When selecting on nominal attributes, removes header
79
79
 *  references to excluded values.</pre>
80
80
 * 
 
81
 * <pre> -F
 
82
 *  Do not apply the filter to instances that arrive after the first
 
83
 *  (training) batch. The default is to apply the filter (i.e.
 
84
 *  the filter may not return an instance if it matches the remove criteria)</pre>
 
85
 * 
81
86
 <!-- options-end -->
82
87
 *
83
88
 * @author Eibe Frank (eibe@cs.waikato.ac.nz)
84
 
 * @version $Revision: 5548 $
 
89
 * @version $Revision: 7602 $
85
90
 */
86
91
public class RemoveWithValues 
87
92
  extends Filter
107
112
 
108
113
  /** If m_ModifyHeader, stores a mapping from old to new indexes */
109
114
  protected int [] m_NominalMapping;
 
115
  
 
116
  /** Whether to filter instances after the first batch has been processed */
 
117
  protected boolean m_dontFilterAfterFirstBatch = false;
110
118
 
111
119
  /**
112
120
   * Returns a string describing this classifier
159
167
              "\tWhen selecting on nominal attributes, removes header\n"
160
168
              + "\treferences to excluded values.",
161
169
              "H", 0, "-H"));
 
170
    newVector.addElement(new Option(
 
171
        "\tDo not apply the filter to instances that arrive after the first\n" +
 
172
        "\t(training) batch. The default is to apply the filter (i.e.\n" +
 
173
        "\tthe filter may not return an instance if it matches the remove criteria)",
 
174
        "F", 0, "-F"));
162
175
 
163
176
    return newVector.elements();
164
177
  }
196
209
   *  When selecting on nominal attributes, removes header
197
210
   *  references to excluded values.</pre>
198
211
   * 
 
212
   * <pre> -F
 
213
   *  Do not apply the filter to instances that arrive after the first
 
214
   *  (training) batch. The default is to apply the filter (i.e.
 
215
   *  the filter may not return an instance if it matches the remove criteria)</pre>
 
216
   * 
199
217
   <!-- options-end -->
200
218
   *
201
219
   * @param options the list of options as an array of strings
226
244
    setInvertSelection(Utils.getFlag('V', options));
227
245
    setMatchMissingValues(Utils.getFlag('M', options));
228
246
    setModifyHeader(Utils.getFlag('H', options));
 
247
    setDontFilterAfterFirstBatch(Utils.getFlag('F', options));
229
248
    // Re-initialize output format according to new options
230
249
    
231
250
    if (getInputFormat() != null) {
240
259
   */
241
260
  public String [] getOptions() {
242
261
 
243
 
    String [] options = new String [9];
 
262
    String [] options = new String [10];
244
263
    int current = 0;
245
264
 
246
265
    options[current++] = "-S"; options[current++] = "" + getSplitPoint();
258
277
    if (getModifyHeader()) {
259
278
      options[current++] = "-H";
260
279
    }
 
280
    if (getDontFilterAfterFirstBatch()) {
 
281
      options[current++] = "-F";
 
282
    }
261
283
    while (current < options.length) {
262
284
      options[current++] = "";
263
285
    }
355
377
      resetQueue();
356
378
      m_NewBatch = false;
357
379
    }
 
380
    
 
381
    if (isFirstBatchDone() && m_dontFilterAfterFirstBatch) {
 
382
      push((Instance)instance.copy());
 
383
      return true;
 
384
    }
 
385
    
358
386
    if (instance.isMissing(m_AttIndex.getIndex())) {
359
387
      if (!getMatchMissingValues()) {
360
388
        push((Instance)instance.copy());
600
628
    
601
629
    m_Values.setRanges(rangeList);
602
630
  }
 
631
  
 
632
  /**
 
633
   * Set whether to apply the filter to instances that arrive once
 
634
   * the first (training) batch has been seen. The default is to
 
635
   * not apply the filter and just return each instance input. This
 
636
   * is so that, when used in the FilteredClassifier, a test instance
 
637
   * does not get "consumed" by the filter and a prediction is always
 
638
   * generated.
 
639
   * 
 
640
   * @param b true if the filter should *not* be applied to instances that
 
641
   * arrive after the first (training) batch has been processed.
 
642
   */
 
643
  public void setDontFilterAfterFirstBatch(boolean b) {
 
644
    m_dontFilterAfterFirstBatch = b;
 
645
  }
 
646
  
 
647
  /**
 
648
   * Get whether to apply the filter to instances that arrive once
 
649
   * the first (training) batch has been seen. The default is to
 
650
   * not apply the filter and just return each instance input. This
 
651
   * is so that, when used in the FilteredClassifier, a test instance
 
652
   * does not get "consumed" by the filter and a prediction is always
 
653
   * generated.
 
654
   * 
 
655
   * @return true if the filter should *not* be applied to instances that
 
656
   * arrive after the first (training) batch has been processed.
 
657
   */
 
658
  public boolean getDontFilterAfterFirstBatch() {
 
659
    return m_dontFilterAfterFirstBatch;
 
660
  }
 
661
  
 
662
  /**
 
663
   * Returns the tip text for this property.
 
664
   * 
 
665
   * @return            tip text for this property suitable for
 
666
   *                    displaying in the explorer/experimenter gui
 
667
   */
 
668
  public String dontFilterAfterFirstBatchTipText() {
 
669
    return "Whether to apply the filtering process to instances that " +
 
670
                "are input after the first (training) batch. The default " +
 
671
                "is false so instances in subsequent batches can potentially " +
 
672
                "get 'consumed' by the filter.";
 
673
  }
603
674
 
604
675
  /**
605
676
   * Set which values of a nominal attribute are to be used for
628
699
   * @return            the revision
629
700
   */
630
701
  public String getRevision() {
631
 
    return RevisionUtils.extract("$Revision: 5548 $");
 
702
    return RevisionUtils.extract("$Revision: 7602 $");
632
703
  }
633
704
 
634
705
  /**
641
712
    runFilter(new RemoveWithValues(), argv);
642
713
  }
643
714
}
 
715