/** * Main method for testing this class. * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { runFilter(new AddCluster(), argv); } }
/** * Input an instance for filtering. Ordinarily the instance is processed and * made available for output immediately. Some filters require all instances * be read before producing output. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been defined. */ @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 (outputFormatPeek() != null) { convertInstance(instance); return true; } bufferInput(instance); return false; }
/** * tests the data whether the filter can actually handle it. * * @param instanceInfo the data to test * @throws Exception if the test fails */ @Override protected void testInputFormat(Instances instanceInfo) throws Exception { getCapabilities(instanceInfo).testWithFail(removeIgnored(instanceInfo)); }
if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); Instances toFilter = getInputFormat(); if (!isFirstBatchDone()) { Instances toFilterIgnoringAttributes = removeIgnored(toFilter); File file = getSerializedClustererFile(); if (!file.isDirectory()) { filtered.numAttributes()); setOutputFormat(filtered); convertInstance(toFilter.instance(i)); flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0);
/** Creates a default AddCluster, with SimpleKMeans as cluster * @see #getClusterer */ public Filter getFilter() { AddCluster f = new AddCluster(); f.setClusterer(getClusterer()); return f; }
+ "' points to a directory not a file!"); setSerializedClustererFile(file); serializedModel = true; } else { setSerializedClustererFile(null); setClusterer(AbstractClusterer.forName(tmpStr, tmpOptions)); setIgnoredAttributeIndices(Utils.getOption('I', options));
/** * Gets the current settings of the filter. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> result; File file; result = new Vector<String>(); file = getSerializedClustererFile(); if ((file != null) && (!file.isDirectory())) { result.add("-serialized"); result.add(file.getAbsolutePath()); } else { result.add("-W"); result.add(getClustererSpec()); } if (!getIgnoredAttributeIndices().equals("")) { result.add("-I"); result.add(getIgnoredAttributeIndices()); } return result.toArray(new String[result.size()]); }
copyValues(processed, false, instance.dataset(), outputFormatPeek()); push(processed); // No need to copy instance
/** * Gets the clusterer specification string, which contains the class name of * the clusterer and any options to the clusterer. * * @return the clusterer string. */ protected String getClustererSpec() { Clusterer c = getClusterer(); if (c instanceof OptionHandler) { return c.getClass().getName() + " " + Utils.joinOptions(((OptionHandler) c).getOptions()); } return c.getClass().getName(); }
if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); Instances toFilter = getInputFormat(); if (!isFirstBatchDone()) { Instances toFilterIgnoringAttributes = removeIgnored(toFilter); File file = getSerializedClustererFile(); if (!file.isDirectory()) { filtered.numAttributes()); setOutputFormat(filtered); convertInstance(toFilter.instance(i)); flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0);
/** Creates a default AddCluster, with SimpleKMeans as cluster * @see #getClusterer */ public Filter getFilter() { AddCluster f = new AddCluster(); f.setClusterer(getClusterer()); return f; }
+ "' points to a directory not a file!"); setSerializedClustererFile(file); serializedModel = true; } else { setSerializedClustererFile(null); setClusterer(AbstractClusterer.forName(tmpStr, tmpOptions)); setIgnoredAttributeIndices(Utils.getOption('I', options));
/** * Gets the current settings of the filter. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> result; File file; result = new Vector<String>(); file = getSerializedClustererFile(); if ((file != null) && (!file.isDirectory())) { result.add("-serialized"); result.add(file.getAbsolutePath()); } else { result.add("-W"); result.add(getClustererSpec()); } if (!getIgnoredAttributeIndices().equals("")) { result.add("-I"); result.add(getIgnoredAttributeIndices()); } return result.toArray(new String[result.size()]); }
copyValues(processed, false, instance.dataset(), outputFormatPeek()); push(processed); // No need to copy instance
/** * Gets the clusterer specification string, which contains the class name of * the clusterer and any options to the clusterer. * * @return the clusterer string. */ protected String getClustererSpec() { Clusterer c = getClusterer(); if (c instanceof OptionHandler) { return c.getClass().getName() + " " + Utils.joinOptions(((OptionHandler) c).getOptions()); } return c.getClass().getName(); }
/** * Input an instance for filtering. Ordinarily the instance is processed and * made available for output immediately. Some filters require all instances * be read before producing output. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). * @throws IllegalStateException if no input format has been defined. */ @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 (outputFormatPeek() != null) { convertInstance(instance); return true; } bufferInput(instance); return false; }
/** * Main method for testing this class. * * @param argv should contain arguments to the filter: use -h for help */ public static void main(String[] argv) { runFilter(new AddCluster(), argv); } }
/** * tests the data whether the filter can actually handle it. * * @param instanceInfo the data to test * @throws Exception if the test fails */ @Override protected void testInputFormat(Instances instanceInfo) throws Exception { getCapabilities(instanceInfo).testWithFail(removeIgnored(instanceInfo)); }