Package weka.filters.unsupervised.attribute

Examples of weka.filters.unsupervised.attribute.Remove


    double evalMetric = 0;
    double[] repError = new double[5];
    int numAttributes = 0;
    int i, j;
    Random Rnd = new Random(m_seed);
    Remove delTransform = new Remove();
    delTransform.setInvertSelection(true);
    // copy the instances
    Instances trainCopy = new Instances(m_trainInstances);

    // count attributes set in the BitSet
    for (i = 0; i < m_numAttribs; i++) {
      if (subset.get(i)) {
        numAttributes++;
      }
    }

    // set up an array of attribute indexes for the filter (+1 for the class)
    int[] featArray = new int[numAttributes + 1];

    for (i = 0, j = 0; i < m_numAttribs; i++) {
      if (subset.get(i)) {
        featArray[j++] = i;
      }
    }

    featArray[j] = m_classIndex;
    delTransform.setAttributeIndicesArray(featArray);
    delTransform.setInputFormat(trainCopy);
    trainCopy = Filter.useFilter(trainCopy, delTransform);

    // max of 5 repetitions of cross validation
    for (i = 0; i < 5; i++) {
      m_Evaluation = new Evaluation(trainCopy);
View Full Code Here


    m_RemoveButton.setEnabled(false);
    m_RemoveButton.setToolTipText("Remove selected attributes.");
    m_RemoveButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    try {
      Remove r = new Remove();
      int [] selected = m_AttPanel.getSelectedAttributes();
      if (selected.length == 0) {
        return;
      }
      if (selected.length == m_Instances.numAttributes()) {
        // Pop up an error optionpane
        JOptionPane.showMessageDialog(PreprocessPanel.this,
              "Can't remove all attributes from data!\n",
              "Remove Attributes",
              JOptionPane.ERROR_MESSAGE);
        m_Log.logMessage("Can't remove all attributes from data!");
        m_Log.statusMessage("Problem removing attributes");
        return;
      }
      r.setAttributeIndicesArray(selected);
      applyFilter(r);
      m_RemoveButton.setEnabled(false);
    } catch (Exception ex) {
      if (m_Log instanceof TaskLogger) {
        ((TaskLogger)m_Log).taskFinished();
View Full Code Here

         +m_upperBoundMinSupport);
      }
    }

    if (deleteString.toString().length() > 0) {
      Remove af = new Remove();
      af.setAttributeIndices(deleteString.toString());
      af.setInvertSelection(false);
      af.setInputFormat(instances);
      Instances newInst = Filter.useFilter(instances, af);

      return newInst;
    }
    return instances;
View Full Code Here

      m_RunThread.start();
    }
  }

  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();
    }
View Full Code Here

      if (m_ignoreKeyList.isSelectedIndex(classIndex)) {
  m_ignoreKeyList.removeSelectionInterval(classIndex, classIndex);
      }
    }
    int [] selected = m_ignoreKeyList.getSelectedIndices();
    Remove af = new Remove();
    Instances retI = null;

    try {
      af.setAttributeIndicesArray(selected);
      af.setInvertSelection(false);
      af.setInputFormat(inst);
      retI = Filter.useFilter(inst, af);
    } catch (Exception e) {
      e.printStackTrace();
    }
   
View Full Code Here

    return retI;
  }

  private Instances removeIgnoreCols(Instances inst, int[] toIgnore) {

    Remove af = new Remove();
    Instances retI = null;

    try {
      af.setAttributeIndicesArray(toIgnore);
      af.setInvertSelection(false);
      af.setInputFormat(inst);
      retI = Filter.useFilter(inst, af);
    } catch (Exception e) {
      e.printStackTrace();
    }
   
View Full Code Here

        }
      }

      if (otherTargets.length() > 0) {
        otherTargets = otherTargets.substring(0, otherTargets.lastIndexOf(','));
        m_otherTargetRemover = new Remove();
        m_otherTargetRemover.setAttributeIndices(otherTargets);
        m_otherTargetRemover.setInputFormat(train);
        train = Filter.useFilter(train, m_otherTargetRemover);
      }
View Full Code Here

    }

    if (removeLongLagIndexes.length() > 0) {
      removeLongLagIndexes = removeLongLagIndexes.substring(0,
          removeLongLagIndexes.lastIndexOf(','));
      Remove r = new Remove();
      r.setAttributeIndices(removeLongLagIndexes);
      r.setInputFormat(insts);
      insts = Filter.useFilter(insts, r);
      m_averagedLagMakers.add(r);
    }

    return insts;
View Full Code Here

      removeList += "" + (i + 1) + ",";
    }

    if (removeList.length() > 0) {
      removeList = removeList.substring(0, removeList.lastIndexOf(','));
      m_extraneousAttributeRemover = new Remove();
      m_extraneousAttributeRemover.setAttributeIndices(removeList);
      m_extraneousAttributeRemover.setInputFormat(insts);
      insts = Filter.useFilter(insts, m_extraneousAttributeRemover);
    }
View Full Code Here

        String[] optionsDel = new String[2];
      optionsDel[0] = "-R";                                  
      optionsDel[1] = "";
      for (int i = 0; i < rmAttributes.length; i++)
        optionsDel[1] += (1+data.attribute(rmAttributes[i]).index()) + ",";    
      Remove remove = new Remove();                        
      remove.setOptions(optionsDel);
        remove.setInputFormat(data);
        data = Filter.useFilter(data, remove);
      }
      // setting class attribute if the data format does not provide this information
      // E.g., the XRFF format saves the class attribute information as well
      if (data.classIndex() == -1)
View Full Code Here

TOP

Related Classes of weka.filters.unsupervised.attribute.Remove

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.