/** * Sets the range of attributes to use in the calculation of the distance. The * indices start from 1, 'first' and 'last' are valid as well. E.g.: * first-3,5,6-last * * @param value the new attribute index range */ public void setAttributeIndices(String value) { m_Remove.setAttributeIndices(value); }
/** * Sets the range of attributes to use in the calculation of the distance. The * indices start from 1, 'first' and 'last' are valid as well. E.g.: * first-3,5,6-last * * @param value the new attribute index range */ public void setAttributeIndices(String value) { m_Remove.setAttributeIndices(value); }
/** * Default constructor: need to set up Remove filter. */ public FilteredDistance() { m_Remove.setInvertSelection(true); m_Remove.setAttributeIndices("first-last"); }
/** * Set which attributes are to be deleted (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. */ public void setAttributeIndicesArray(int[] attributes) { setAttributeIndices(Range.indicesToRangeList(attributes)); }
/** * Set which attributes are to be deleted (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. */ public void setAttributeIndicesArray(int[] attributes) { setAttributeIndices(Range.indicesToRangeList(attributes)); }
/** * Default constructor: need to set up Remove filter. */ public FilteredDistance() { m_Remove.setInvertSelection(true); m_Remove.setAttributeIndices("first-last"); }
/** * Remove Indices - Remove ALL labels (assume they are the first L attributes) from D. * @param D Dataset * @param L number of labels * @return New dataset with labels removed. */ public static Instances removeLabels(Instances D, int L) throws Exception { Remove remove = new Remove(); remove.setAttributeIndices("1-"+L); remove.setInputFormat(D); return Filter.useFilter(D, remove); }
/** Creates a specialized Remove */ public Filter getFilter(String rangelist) { Remove af = new Remove(); af.setAttributeIndices(rangelist); return af; }
/** Creates a specialized Remove */ public Filter getFilter(String rangelist) { Remove af = new Remove(); af.setAttributeIndices(rangelist); return af; }
/** * Remove Indices - Remove ALL labels (assume they are the first L attributes) from D. * @param D Dataset * @param L number of labels * @return New dataset with labels removed. */ public static Instances removeLabels(Instances D, int L) throws Exception { Remove remove = new Remove(); remove.setAttributeIndices("1-"+L); remove.setInputFormat(D); return Filter.useFilter(D, remove); }
// generate data for clusterer (w/o class) Remove filter = new Remove(); filter.setAttributeIndices("" + (data.classIndex() + 1)); try { filter.setInputFormat(data); } catch (Exception e) { e.printStackTrace(); } Instances dataClusterer = Filter.useFilter(data, filter); // train clusterer EM clusterer = new EM(); // set further options for EM, if necessary... // clusterer.setNumClusters(maxNumofClusters); //-1 for n number of clusters clusterer.buildClusterer(dataClusterer);
/** * Detaches the index attribute from the beginning of each instance * * @param original * @return the modified instances * @throws Exception */ protected Instances detachIndexes(Instances original) throws Exception { Remove remove = new Remove(); remove.setAttributeIndices("first"); remove.setInputFormat(original); Instances result = Filter.useFilter(original, remove); return result; }
private Instances removeClass(Instances inst) { Remove af = new Remove(); Instances retI = null; try { if (inst.classIndex() < 0) { retI = inst; } else { af.setAttributeIndices("" + (inst.classIndex() + 1)); af.setInvertSelection(false); af.setInputFormat(inst); retI = Filter.useFilter(inst, af); } } catch (Exception e) { e.printStackTrace(); } return retI; }
private Instances removeClass(Instances inst) { Remove af = new Remove(); Instances retI = null; try { if (inst.classIndex() < 0) { retI = inst; } else { af.setAttributeIndices("" + (inst.classIndex() + 1)); af.setInvertSelection(false); af.setInputFormat(inst); retI = Filter.useFilter(inst, af); } } catch (Exception e) { e.printStackTrace(); } return retI; }
/** * Returns a new set of instances either only with the labels (labels = true) or * only the features (labels = false) * * @param inst The input instances. * @param labels Return labels (true) or features (false) */ protected Instances extractPart(Instances inst, boolean labels) throws Exception{ //TODO Maybe alreade exists somewhere in Meka? Remove remove = new Remove(); remove.setAttributeIndices("first-"+(inst.classIndex())); remove.setInvertSelection(labels); remove.setInputFormat(inst); return Filter.useFilter(inst, remove); }
/** * Returns a new set of instances either only with the labels (labels = true) or * only the features (labels = false) * * @param inst The input instances. * @param labels Return labels (true) or features (false) */ protected Instances extractPart(Instances inst, boolean labels) throws Exception{ //TODO Maybe alreade exists somewhere in Meka? Remove remove = new Remove(); remove.setAttributeIndices("first-"+(inst.classIndex())); remove.setInvertSelection(labels); remove.setInputFormat(inst); return Filter.useFilter(inst, remove); }
protected void setUp() throws Exception { m_Filter = getFilter(); m_Instances = new Instances(new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("weka/filters/data/FilterTest.arff")))); Remove r = new Remove(); r.setAttributeIndices("1, 2, 4, 5"); r.setInputFormat(m_Instances); m_Instances = Filter.useFilter(m_Instances, r); m_OptionTester = getOptionTester(); m_GOETester = getGOETester(); m_FilteredClassifier = null; }
protected void setUp() throws Exception { m_Filter = getFilter(); m_Instances = new Instances(new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("weka/filters/data/FilterTest.arff")))); Remove r = new Remove(); r.setAttributeIndices("1, 2, 4, 5"); r.setInputFormat(m_Instances); m_Instances = Filter.useFilter(m_Instances, r); m_OptionTester = getOptionTester(); m_GOETester = getGOETester(); m_FilteredClassifier = null; }
/** * Builds the clusters */ private void buildClusterer() throws Exception { if (m_trainingSet.classIndex() < 0) { m_Clusterer.buildClusterer(m_trainingSet); } else { // class based evaluation if class attribute is set Remove removeClass = new Remove(); removeClass.setAttributeIndices("" + (m_trainingSet.classIndex() + 1)); removeClass.setInvertSelection(false); removeClass.setInputFormat(m_trainingSet); Instances clusterTrain = Filter.useFilter(m_trainingSet, removeClass); m_Clusterer.buildClusterer(clusterTrain); } }
/** * Builds the clusters */ private void buildClusterer() throws Exception { if (m_trainingSet.classIndex() < 0) { m_Clusterer.buildClusterer(m_trainingSet); } else { // class based evaluation if class attribute is set Remove removeClass = new Remove(); removeClass.setAttributeIndices("" + (m_trainingSet.classIndex() + 1)); removeClass.setInvertSelection(false); removeClass.setInputFormat(m_trainingSet); Instances clusterTrain = Filter.useFilter(m_trainingSet, removeClass); m_Clusterer.buildClusterer(clusterTrain); } }