m_k = (int) ((getInputFormat().numAttributes() - 1) * m_percent); attributes.add(new Attribute("K" + (i + 1))); if (getInputFormat().classIndex() > -1) { attributes.add((Attribute) getInputFormat().classAttribute().copy()); if (getInputFormat().classIndex() > -1) { newFormat.setClassIndex(attributes.size() - 1);
m_k = (int) ((getInputFormat().numAttributes() - 1) * m_percent); attributes.add(new Attribute("K" + (i + 1))); if (getInputFormat().classIndex() > -1) { attributes.add((Attribute) getInputFormat().classAttribute().copy()); if (getInputFormat().classIndex() > -1) { newFormat.setClassIndex(attributes.size() - 1);
/** * Signify that this batch of input to the filter is finished. * * @return true if there are instances pending output * @throws NullPointerException if no input structure has been defined, * @throws Exception if there was a problem finishing the batch. */ @Override public boolean batchFinished() throws Exception { if (getInputFormat() == null) { throw new NullPointerException("No input instance format defined"); } Instances insts = getInputFormat(); if (m_useReplaceMissing) { insts = Filter.useFilter(insts, m_replaceMissing); } insts = Filter.useFilter(insts, m_ntob); if (!m_OutputFormatDefined) { setOutputFormat(); } for (Instance instance : insts) { push(convertInstance(instance), false); // No need to copy } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }
/** * Signify that this batch of input to the filter is finished. * * @return true if there are instances pending output * @throws NullPointerException if no input structure has been defined, * @throws Exception if there was a problem finishing the batch. */ @Override public boolean batchFinished() throws Exception { if (getInputFormat() == null) { throw new NullPointerException("No input instance format defined"); } Instances insts = getInputFormat(); if (m_useReplaceMissing) { insts = Filter.useFilter(insts, m_replaceMissing); } insts = Filter.useFilter(insts, m_ntob); if (!m_OutputFormatDefined) { setOutputFormat(); } for (Instance instance : insts) { push(convertInstance(instance), false); // No need to copy } flushInput(); m_NewBatch = true; m_FirstBatchDone = true; return (numPendingOutput() != 0); }
/** * Input an instance for filtering. * * @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 */ @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 ((m_OutputFormatDefined) && ((!m_useReplaceMissing) || isFirstBatchDone())) { if (m_replaceMissing != null) { m_replaceMissing.input(instance); instance = m_replaceMissing.output(); } m_ntob.input(instance); instance = m_ntob.output(); push(convertInstance(instance), false); return true; } bufferInput(instance); return false; }
/** * Input an instance for filtering. * * @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 */ @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 ((m_OutputFormatDefined) && ((!m_useReplaceMissing) || isFirstBatchDone())) { if (m_replaceMissing != null) { m_replaceMissing.input(instance); instance = m_replaceMissing.output(); } m_ntob.input(instance); instance = m_ntob.output(); push(convertInstance(instance), false); return true; } bufferInput(instance); return false; }