/** * Sets which attributes are to be transformed to binary. (only numeric * attributes among the selection will be transformed). * * @param value an array containing indexes of attributes to binarize. Since * the array will typically come from a program, attributes are * indexed from 0. * @throws IllegalArgumentException if an invalid set of ranges is supplied */ public void setAttributeIndicesArray(int[] value) { setAttributeIndices(Range.indicesToRangeList(value)); }
/** * Sets which attributes are to be transformed to binary. (only numeric * attributes among the selection will be transformed). * * @param value an array containing indexes of attributes to binarize. Since * the array will typically come from a program, attributes are * indexed from 0. * @throws IllegalArgumentException if an invalid set of ranges is supplied */ public void setAttributeIndicesArray(int[] value) { setAttributeIndices(Range.indicesToRangeList(value)); }
setAttributeIndices(tmpStr); } else { setAttributeIndices(m_DefaultCols);
setAttributeIndices(tmpStr); } else { setAttributeIndices(m_DefaultCols);
/** * Make sure that the filter binarizes the index we specify. */ public void testSpecificIndex() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Set the attribute index to point to NumericAtt1, so we expect that only this // attribute will be binarized. ((NumericToBinary)m_Filter).setAttributeIndices( String.valueOf(att1+1) ); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be numeric", result.attribute(att2).isNumeric()); }
/** * Make sure that the filter binarizes the index we specify. */ public void testSpecificIndex() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Set the attribute index to point to NumericAtt1, so we expect that only this // attribute will be binarized. ((NumericToBinary)m_Filter).setAttributeIndices( String.valueOf(att1+1) ); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be numeric", result.attribute(att2).isNumeric()); }
/** * Make sure the filter binarizes the index we specify + invert */ public void testInvertSelection() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Set the attribute index to point to NumericAtt1, but invert the selection, so that // it will try to apply the filter to *every other* attribute. Of course, because this // only applies to numeric attributes, the filter should only change NumericAtt2 ((NumericToBinary)m_Filter).setAttributeIndices( String.valueOf(att2+1) ); ((NumericToBinary)m_Filter).setInvertSelection(true); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be numeric", result.attribute(att2).isNumeric()); }
/** * Make sure the filter binarizes the index we specify + invert */ public void testInvertSelection() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Set the attribute index to point to NumericAtt1, but invert the selection, so that // it will try to apply the filter to *every other* attribute. Of course, because this // only applies to numeric attributes, the filter should only change NumericAtt2 ((NumericToBinary)m_Filter).setAttributeIndices( String.valueOf(att2+1) ); ((NumericToBinary)m_Filter).setInvertSelection(true); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be numeric", result.attribute(att2).isNumeric()); }
/** * Make sure the filter binarizes the appropriate attributes in the range * we specify */ public void testRange() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Use the string expression "first-last" for the attribute index. This should // change both numeric attributes. ((NumericToBinary)m_Filter).setAttributeIndices("first-last"); ((NumericToBinary)m_Filter).setInvertSelection(false); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be nominal", result.attribute(att2).isNominal()); }
/** * Make sure the filter binarizes the appropriate attributes in the range * we specify */ public void testRange() { int att1 = m_Instances.attribute("NumericAtt1").index(); int att2 = m_Instances.attribute("NumericAtt2").index(); // Use the string expression "first-last" for the attribute index. This should // change both numeric attributes. ((NumericToBinary)m_Filter).setAttributeIndices("first-last"); ((NumericToBinary)m_Filter).setInvertSelection(false); Instances result = useFilter(); assertTrue("NumericAtt1 should be nominal", result.attribute(att1).isNominal()); assertTrue("NumericAtt2 should be nominal", result.attribute(att2).isNominal()); }