/** * Input an instance for filtering. Filter requires all training 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 set. */ public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (m_ModesAndMeans == null) { bufferInput(instance); return false; } else { convertInstance(instance); return true; } }
/** * Input an instance for filtering. Filter requires all training 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 set. */ public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (m_ModesAndMeans == null) { bufferInput(instance); return false; } else { convertInstance(instance); return true; } }
if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); double sumOfWeights = getInputFormat().sumOfWeights(); double[][] counts = new double[getInputFormat().numAttributes()][]; for (int i = 0; i < getInputFormat().numAttributes(); i++) { if (getInputFormat().attribute(i).isNominal()) { counts[i] = new double[getInputFormat().attribute(i).numValues()]; if (counts[i].length > 0) counts[i][0] = sumOfWeights; double[] sums = new double[getInputFormat().numAttributes()]; for (int i = 0; i < sums.length; i++) { sums[i] = sumOfWeights; double[] results = new double[getInputFormat().numAttributes()]; for (int j = 0; j < getInputFormat().numInstances(); j++) { Instance inst = getInputFormat().instance(j); for (int i = 0; i < inst.numValues(); i++) { if (!inst.isMissingSparse(i)) { m_ModesAndMeans = new double[getInputFormat().numAttributes()]; for (int i = 0; i < getInputFormat().numAttributes(); i++) { if (getInputFormat().attribute(i).isNominal()) { if (counts[i].length == 0) m_ModesAndMeans[i] = Utils.missingValue(); else m_ModesAndMeans[i] = (double) Utils.maxIndex(counts[i]); } else if (getInputFormat().attribute(i).isNumeric()) {
if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); double sumOfWeights = getInputFormat().sumOfWeights(); double[][] counts = new double[getInputFormat().numAttributes()][]; for (int i = 0; i < getInputFormat().numAttributes(); i++) { if (getInputFormat().attribute(i).isNominal()) { counts[i] = new double[getInputFormat().attribute(i).numValues()]; if (counts[i].length > 0) counts[i][0] = sumOfWeights; double[] sums = new double[getInputFormat().numAttributes()]; for (int i = 0; i < sums.length; i++) { sums[i] = sumOfWeights; double[] results = new double[getInputFormat().numAttributes()]; for (int j = 0; j < getInputFormat().numInstances(); j++) { Instance inst = getInputFormat().instance(j); for (int i = 0; i < inst.numValues(); i++) { if (!inst.isMissingSparse(i)) { m_ModesAndMeans = new double[getInputFormat().numAttributes()]; for (int i = 0; i < getInputFormat().numAttributes(); i++) { if (getInputFormat().attribute(i).isNominal()) { if (counts[i].length == 0) m_ModesAndMeans[i] = Utils.missingValue(); else m_ModesAndMeans[i] = (double) Utils.maxIndex(counts[i]); } else if (getInputFormat().attribute(i).isNumeric()) {
for (int j = 0; j < instance.numValues(); j++) { if (instance.isMissingSparse(j) && (getInputFormat().classIndex() != instance.index(j)) && (instance.attributeSparse(j).isNominal() || instance .attributeSparse(j).isNumeric())) { double[] vals = new double[getInputFormat().numAttributes()]; for (int j = 0; j < instance.numAttributes(); j++) { if (instance.isMissing(j) && (getInputFormat().classIndex() != j) && (getInputFormat().attribute(j).isNominal() || getInputFormat() .attribute(j).isNumeric())) { vals[j] = m_ModesAndMeans[j];
for (int j = 0; j < instance.numValues(); j++) { if (instance.isMissingSparse(j) && (getInputFormat().classIndex() != instance.index(j)) && (instance.attributeSparse(j).isNominal() || instance .attributeSparse(j).isNumeric())) { double[] vals = new double[getInputFormat().numAttributes()]; for (int j = 0; j < instance.numAttributes(); j++) { if (instance.isMissing(j) && (getInputFormat().classIndex() != j) && (getInputFormat().attribute(j).isNominal() || getInputFormat() .attribute(j).isNumeric())) { vals[j] = m_ModesAndMeans[j];