/** * Main method for running this filter. * * @param args arguments for the filter: use -h for help */ public static void main(String[] args) { runFilter(new RemoveDuplicates(), args); } }
/** * Input an instance for filtering. Filter requires all * training instances be read before producing output (calling the method * batchFinished() makes the data available). If this instance is part of * a new batch, m_NewBatch is set to false. * * @param instance the input instance * @return true if the filtered instance may now be * collected with output(). * @throws IllegalStateException if no input structure has been defined * @throws Exception if something goes wrong * @see #batchFinished() */ @Override public boolean input(Instance instance) throws Exception { if (getInputFormat() == null) throw new IllegalStateException("No input instance format defined"); if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { push(instance); return true; } else { bufferInput(instance); return false; } }
/** Creates a default Resample */ @Override public Filter getFilter() { RemoveDuplicates f = new RemoveDuplicates(); return f; }
/** * Processes the given data (may change the provided dataset) and returns * the modified version. This method is called in batchFinished(). * * @param instances the data to process * @return the modified data * @throws Exception in case the processing goes wrong * @see #batchFinished() */ @Override protected Instances process(Instances instances) throws Exception { if (!isFirstBatchDone()) { HashSet<DecisionTableHashKey> hs = new HashSet<DecisionTableHashKey>(); Instances newInstances = new Instances(instances, instances.numInstances()); for (Instance inst : instances) { DecisionTableHashKey key = new DecisionTableHashKey(inst, instances.numAttributes(), true); if (hs.add(key)) { newInstances.add(inst); } } newInstances.compactify(); return newInstances; } return new Instances(instances); }
/** Creates a default Resample */ @Override public Filter getFilter() { RemoveDuplicates f = new RemoveDuplicates(); return f; }
/** * Processes the given data (may change the provided dataset) and returns * the modified version. This method is called in batchFinished(). * * @param instances the data to process * @return the modified data * @throws Exception in case the processing goes wrong * @see #batchFinished() */ @Override protected Instances process(Instances instances) throws Exception { if (!isFirstBatchDone()) { HashSet<DecisionTableHashKey> hs = new HashSet<DecisionTableHashKey>(); Instances newInstances = new Instances(instances, instances.numInstances()); for (Instance inst : instances) { DecisionTableHashKey key = new DecisionTableHashKey(inst, instances.numAttributes(), true); if (hs.add(key)) { newInstances.add(inst); } } newInstances.compactify(); return newInstances; } return new Instances(instances); }
/** * Input an instance for filtering. Filter requires all * training instances be read before producing output (calling the method * batchFinished() makes the data available). If this instance is part of * a new batch, m_NewBatch is set to false. * * @param instance the input instance * @return true if the filtered instance may now be * collected with output(). * @throws IllegalStateException if no input structure has been defined * @throws Exception if something goes wrong * @see #batchFinished() */ @Override public boolean input(Instance instance) throws Exception { if (getInputFormat() == null) throw new IllegalStateException("No input instance format defined"); if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (isFirstBatchDone()) { push(instance); return true; } else { bufferInput(instance); return false; } }
/** * Main method for running this filter. * * @param args arguments for the filter: use -h for help */ public static void main(String[] args) { runFilter(new RemoveDuplicates(), args); } }