/** * 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 ClusterMembership(), 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)); }
public boolean batchFinished() throws Exception { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); if (outputFormatPeek() == null) { Instances toFilter = getInputFormat(); Instances[] toFilterIgnoringAttributes; toFilterIgnoringAttributes[i] = removeIgnored(toFilterIgnoringAttributes[i]); filtered.setClassIndex(filtered.numAttributes() - 1); setOutputFormat(filtered); convertInstance(toFilter.instance(i)); flushInput(); return (numPendingOutput() != 0);
double[] instanceVals = new double[outputFormatPeek().numAttributes()]; double[] tempvals; if (instance.classIndex() >= 0) { tempvals = new double[outputFormatPeek().numAttributes() - 1]; } else { tempvals = new double[outputFormatPeek().numAttributes()]; if (m_removeAttributes != null) { m_removeAttributes.input(instance); probs = logs2densities(j, m_removeAttributes.output()); } else { probs = logs2densities(j, instance); push(new DenseInstance(instance.weight(), instanceVals));
/** Creates a default ClusterMembership */ public Filter getFilter() { ClusterMembership f = new ClusterMembership(); return f; }
/** * Gets the current settings of the filter. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> options = new Vector<String>(); if (!getIgnoredAttributeIndices().equals("")) { options.add("-I"); options.add(getIgnoredAttributeIndices()); } if (m_clusterer != null) { options.add("-W"); options.add(getDensityBasedClusterer().getClass().getName()); } if ((m_clusterer != null) && (m_clusterer instanceof OptionHandler)) { String[] clustererOptions = ((OptionHandler) m_clusterer).getOptions(); if (clustererOptions.length > 0) { options.add("--"); Collections.addAll(options, clustererOptions); } } return options.toArray(new String[0]); }
public boolean batchFinished() throws Exception { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); if (outputFormatPeek() == null) { Instances toFilter = getInputFormat(); Instances[] toFilterIgnoringAttributes; toFilterIgnoringAttributes[i] = removeIgnored(toFilterIgnoringAttributes[i]); filtered.setClassIndex(filtered.numAttributes() - 1); setOutputFormat(filtered); convertInstance(toFilter.instance(i)); flushInput(); return (numPendingOutput() != 0);
double[] instanceVals = new double[outputFormatPeek().numAttributes()]; double[] tempvals; if (instance.classIndex() >= 0) { tempvals = new double[outputFormatPeek().numAttributes() - 1]; } else { tempvals = new double[outputFormatPeek().numAttributes()]; if (m_removeAttributes != null) { m_removeAttributes.input(instance); probs = logs2densities(j, m_removeAttributes.output()); } else { probs = logs2densities(j, instance); push(new DenseInstance(instance.weight(), instanceVals));
/** Creates a default ClusterMembership */ public Filter getFilter() { ClusterMembership f = new ClusterMembership(); return f; }
/** * Gets the current settings of the filter. * * @return an array of strings suitable for passing to setOptions */ @Override public String[] getOptions() { Vector<String> options = new Vector<String>(); if (!getIgnoredAttributeIndices().equals("")) { options.add("-I"); options.add(getIgnoredAttributeIndices()); } if (m_clusterer != null) { options.add("-W"); options.add(getDensityBasedClusterer().getClass().getName()); } if ((m_clusterer != null) && (m_clusterer instanceof OptionHandler)) { String[] clustererOptions = ((OptionHandler) m_clusterer).getOptions(); if (clustererOptions.length > 0) { options.add("--"); Collections.addAll(options, clustererOptions); } } return options.toArray(new String[0]); }
/** * 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 ClusterMembership(), 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)); }