/** * Set which attributes are to be copied (or kept if invert is true) * * @param attributes an array containing indexes of attributes to select. * Since the array will typically come from a program, attributes are * indexed from 0.<br> * Note: use this method before you call * <code>setInputFormat(Instances)</code>, since the output format is * determined in that method. * @throws Exception if an invalid set of ranges is supplied */ public void setAttributeIndicesArray(int[] attributes) throws Exception { setAttributeIndices(Range.indicesToRangeList(attributes)); }
/** * Set which attributes are to be copied (or kept if invert is true) * * @param attributes an array containing indexes of attributes to select. * Since the array will typically come from a program, attributes are * indexed from 0.<br> * Note: use this method before you call * <code>setInputFormat(Instances)</code>, since the output format is * determined in that method. * @throws Exception if an invalid set of ranges is supplied */ public void setAttributeIndicesArray(int[] attributes) throws Exception { setAttributeIndices(Range.indicesToRangeList(attributes)); }
/** * ReorderLabels - swap values of y[1] to y[L] according to s[]. * @param s new indices order (supposing that it contains the first s.length indices) */ public static void reorderLabels(Instances D, int s[]) throws Exception { int L = s.length; Reorder f = new Reorder(); String range = ""; for(int j = 0; j < L; j++) { range += String.valueOf(s[0]) + ","; } range = range + (L+1) + "-last"; f.setAttributeIndices(range); f.setInputFormat(D); D = Filter.useFilter(D, f); //return D; }
/** * ReorderLabels - swap values of y[1] to y[L] according to s[]. * @param s new indices order (supposing that it contains the first s.length indices) */ public static void reorderLabels(Instances D, int s[]) throws Exception { int L = s.length; Reorder f = new Reorder(); String range = ""; for(int j = 0; j < L; j++) { range += String.valueOf(s[0]) + ","; } range = range + (L+1) + "-last"; f.setAttributeIndices(range); f.setInputFormat(D); D = Filter.useFilter(D, f); //return D; }
/** Creates a specialized Reorder */ public Filter getFilter(String rangelist) { try { Reorder af = new Reorder(); af.setAttributeIndices(rangelist); return af; } catch (Exception ex) { ex.printStackTrace(); fail("Exception setting attribute range: " + rangelist + "\n" + ex.getMessage()); } return null; }
/** Creates a specialized Reorder */ public Filter getFilter(String rangelist) { try { Reorder af = new Reorder(); af.setAttributeIndices(rangelist); return af; } catch (Exception ex) { ex.printStackTrace(); fail("Exception setting attribute range: " + rangelist + "\n" + ex.getMessage()); } return null; }
/** * Parses a given list of options. * <p/> * * <!-- options-start --> Valid options are: * <p/> * * <pre> * -R <index1,index2-index4,...> * Specifies the order of the attributes (default first-last). * </pre> * * <!-- options-end --> * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { String orderList = Utils.getOption('R', options); if (orderList.length() != 0) { setAttributeIndices(orderList); } if (getInputFormat() != null) { setInputFormat(getInputFormat()); } Utils.checkForRemainingOptions(options); }
order.append("" + (i+1)); m_Reorder.setAttributeIndices(order.toString()); m_Reorder.setInputFormat(inputFormat);
/** * Parses a given list of options. * <p/> * * <!-- options-start --> Valid options are: * <p/> * * <pre> * -R <index1,index2-index4,...> * Specifies the order of the attributes (default first-last). * </pre> * * <!-- options-end --> * * @param options the list of options as an array of strings * @throws Exception if an option is not supported */ @Override public void setOptions(String[] options) throws Exception { String orderList = Utils.getOption('R', options); if (orderList.length() != 0) { setAttributeIndices(orderList); } if (getInputFormat() != null) { setInputFormat(getInputFormat()); } Utils.checkForRemainingOptions(options); }
order.append("" + (i+1)); m_Reorder.setAttributeIndices(order.toString()); m_Reorder.setInputFormat(inputFormat);
order.append("" + (i+1)); m_Reorder.setAttributeIndices(order.toString()); m_Reorder.setInputFormat(inputFormat);
reorder.setAttributeIndices(order); reorder.setInputFormat(m_Data); m_Data = Filter.useFilter(m_Data, reorder);
reorder.setAttributeIndices(order); reorder.setInputFormat(m_Data); m_Data = Filter.useFilter(m_Data, reorder);
reorder.setAttributeIndices(order); reorder.setInputFormat(m_Data); m_Data = Filter.useFilter(m_Data, reorder);
reorder.setAttributeIndices(order); reorder.setInputFormat(m_Data); m_Data = Filter.useFilter(m_Data, reorder);
protected Instances reorderAtts(Instances data) throws Exception { Reorder r = new Reorder(); String range = "last"; for (int i = data.numAttributes() - 1; i > 0; i--) { range += "," + i; } r.setAttributeIndices(range); r.setInputFormat(data); data = Filter.useFilter(data, r); return data; }
protected Instances reorderAtts(Instances data) throws Exception { Reorder r = new Reorder(); String range = "last"; for (int i = data.numAttributes() - 1; i > 0; i--) { range += "," + i; } r.setAttributeIndices(range); r.setInputFormat(data); data = Filter.useFilter(data, r); return data; }