Package weka.filters.unsupervised.attribute

Examples of weka.filters.unsupervised.attribute.Remove


    }
    m_targetHeader = new Instances(m_instances, 0);
    if (removeList.length() > 0) {
      removeList = removeList.substring(0, removeList.lastIndexOf(","));

      Remove r = new Remove();
      r.setAttributeIndices(removeList);
      r.setInputFormat(m_instances);
      m_targetHeader = Filter.useFilter(m_instances, r);
      m_targetHeader = new Instances(m_targetHeader, 0);
    }
    m_targetPanel.setInstances(m_targetHeader);
    if (m_targetHeader.numAttributes() == 1) {
View Full Code Here


    // If class is set then do class based evaluation as well
    if (hasClass) {
      if (testRaw.classAttribute().isNumeric())
  throw new Exception("ClusterEvaluation: Class must be nominal!");

      filter = new Remove();
      ((Remove) filter).setAttributeIndices("" + (testRaw.classIndex() + 1));
      ((Remove) filter).setInvertSelection(false);
      filter.setInputFormat(testRaw);
    }
   
View Full Code Here

  else {
    clusterer.buildClusterer(source.getDataSet());
  }
      }
      else {
  Remove removeClass = new Remove();
  removeClass.setAttributeIndices("" + theClass);
  removeClass.setInvertSelection(false);
  removeClass.setInputFormat(train);
  if (updateable) {
    Instances clusterTrain = Filter.useFilter(train, removeClass);
    clusterer.buildClusterer(clusterTrain);
          trainHeader = clusterTrain;
    while (source.hasMoreElements(train)) {
      inst = source.nextElement(train);
      removeClass.input(inst);
      removeClass.batchFinished();
      Instance clusterTrainInst = removeClass.output();
      ((UpdateableClusterer) clusterer).updateClusterer(clusterTrainInst);
    }
    ((UpdateableClusterer) clusterer).updateFinished();
  }
  else {
View Full Code Here

      : 0;
    int overall_length = RESULT_SIZE+addm;

    if (m_removeClassColumn && train.classIndex() != -1) {
      // remove the class column from the training and testing data
      Remove r = new Remove();
      r.setAttributeIndicesArray(new int [] {train.classIndex()});
      r.setInvertSelection(false);
      r.setInputFormat(train);
      train = Filter.useFilter(train, r);
     
      test = Filter.useFilter(test, r);
    }
    train.setClassIndex(-1);
View Full Code Here

  public double evaluateAttribute (int attribute)
    throws Exception {
    int[] featArray = new int[2]; // feat + class
    double errorRate;
    Evaluation o_Evaluation;
    Remove delTransform = new Remove();
    delTransform.setInvertSelection(true);
    // copy the instances
    Instances trainCopy = new Instances(m_trainInstances);
    featArray[0] = attribute;
    featArray[1] = trainCopy.classIndex();
    delTransform.setAttributeIndicesArray(featArray);
    delTransform.setInputFormat(trainCopy);
    trainCopy = Filter.useFilter(trainCopy, delTransform);
    o_Evaluation = new Evaluation(trainCopy);
    String [] oneROpts = { "-B", ""+getMinimumBucketSize()};
    Classifier oneR = Classifier.forName("weka.classifiers.rules.OneR", oneROpts);
    if (m_evalUsingTrainingData) {
View Full Code Here

      deleteCols.addElement(new Integer(m_classIndex));
    }

    // remove columns from the data if necessary
    if (deleteCols.size() > 0) {
      m_attributeFilter = new Remove();
      int [] todelete = new int [deleteCols.size()];
      for (int i=0;i<deleteCols.size();i++) {
        todelete[i] = ((Integer)(deleteCols.elementAt(i))).intValue();
      }
      m_attributeFilter.setAttributeIndicesArray(todelete);
View Full Code Here

   */
  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);
      }
  }
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

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.