Package weka.core

Examples of weka.core.Range


      int help2 = second;
      second = first;
      first = help2;
    }

    m_Range = new Range(Range.indicesToRangeList(firstInds));
    m_Range.setUpper(data.numClasses() - 1);

    Range secondRange = new Range(Range.indicesToRangeList(secondInds));
    secondRange.setUpper(data.numClasses() - 1);
      
    // Change the class labels and build the classifier
    MakeIndicator filter = new MakeIndicator();
    filter.setAttributeIndex("" + (data.classIndex() + 1));
    filter.setValueIndices(m_Range.getRanges());
    filter.setNumeric(false);
    filter.setInputFormat(data);
    m_FilteredClassifier = new FilteredClassifier();
    if (data.numInstances() > 0) {
      m_FilteredClassifier.setClassifier(Classifier.makeCopies(classifier, 1)[0]);
    } else {
      m_FilteredClassifier.setClassifier(new weka.classifiers.rules.ZeroR());
    }
    m_FilteredClassifier.setFilter(filter);

    // Save reference to hash table at current node
    m_classifiers=table;
 
    if (!m_classifiers.containsKey( getString(firstInds) + "|" + getString(secondInds))) {
      m_FilteredClassifier.buildClassifier(data);
      m_classifiers.put(getString(firstInds) + "|" + getString(secondInds), m_FilteredClassifier);
    } else {
      m_FilteredClassifier=(FilteredClassifier)m_classifiers.get(getString(firstInds) + "|" +
                 getString(secondInds))
    }
       
    // Create two successors if necessary
    m_FirstSuccessor = new DataNearBalancedND();
    if (first == 1) {
      m_FirstSuccessor.m_Range = m_Range;
    } else {
      RemoveWithValues rwv = new RemoveWithValues();
      rwv.setInvertSelection(true);
      rwv.setNominalIndices(m_Range.getRanges());
      rwv.setAttributeIndex("" + (data.classIndex() + 1));
      rwv.setInputFormat(data);
      Instances firstSubset = Filter.useFilter(data, rwv);
      m_FirstSuccessor.generateClassifierForNode(firstSubset, m_Range,
                                                 rand, classifier, m_classifiers,
                                                 instsNumAllClasses);
    }
    m_SecondSuccessor = new DataNearBalancedND();
    if (second == 1) {
      m_SecondSuccessor.m_Range = secondRange;
    } else {
      RemoveWithValues rwv = new RemoveWithValues();
      rwv.setInvertSelection(true);
      rwv.setNominalIndices(secondRange.getRanges());
      rwv.setAttributeIndex("" + (data.classIndex() + 1));
      rwv.setInputFormat(data);
      Instances secondSubset = Filter.useFilter(data, rwv);
      m_SecondSuccessor = new DataNearBalancedND();
     
View Full Code Here


    double[] instsNum = new double[data.numClasses()];
    for (int i = 0; i < data.numInstances(); i++) {
      instsNum[(int)data.instance(i).classValue()] += data.instance(i).weight();
    }
     
    Range newRange = new Range(list.toString());
    newRange.setUpper(data.numClasses() - 1);
 
    generateClassifierForNode(data, newRange, random, m_Classifier, m_classifiers, instsNum);
  }
View Full Code Here

      int help2 = second;
      second = first;
      first = help2;
    }

    m_Range = new Range(Range.indicesToRangeList(firstInds));
    m_Range.setUpper(data.numClasses() - 1);

    Range secondRange = new Range(Range.indicesToRangeList(secondInds));
    secondRange.setUpper(data.numClasses() - 1);
      
    // Change the class labels and build the classifier
    MakeIndicator filter = new MakeIndicator();
    filter.setAttributeIndex("" + (data.classIndex() + 1));
    filter.setValueIndices(m_Range.getRanges());
    filter.setNumeric(false);
    filter.setInputFormat(data);
    m_FilteredClassifier = new FilteredClassifier();
    if (data.numInstances() > 0) {
      m_FilteredClassifier.setClassifier(Classifier.makeCopies(classifier, 1)[0]);
    } else {
      m_FilteredClassifier.setClassifier(new weka.classifiers.rules.ZeroR());
    }
    m_FilteredClassifier.setFilter(filter);

    // Save reference to hash table at current node
    m_classifiers=table;
 
    if (!m_classifiers.containsKey( getString(firstInds) + "|" + getString(secondInds))) {
      m_FilteredClassifier.buildClassifier(data);
      m_classifiers.put(getString(firstInds) + "|" + getString(secondInds), m_FilteredClassifier);
    } else {
      m_FilteredClassifier=(FilteredClassifier)m_classifiers.get(getString(firstInds) + "|" +
                 getString(secondInds))
    }
       
    // Create two successors if necessary
    m_FirstSuccessor = new ClassBalancedND();
    if (first == 1) {
      m_FirstSuccessor.m_Range = m_Range;
    } else {
      RemoveWithValues rwv = new RemoveWithValues();
      rwv.setInvertSelection(true);
      rwv.setNominalIndices(m_Range.getRanges());
      rwv.setAttributeIndex("" + (data.classIndex() + 1));
      rwv.setInputFormat(data);
      Instances firstSubset = Filter.useFilter(data, rwv);
      m_FirstSuccessor.generateClassifierForNode(firstSubset, m_Range,
                                                 rand, classifier, m_classifiers);
    }
    m_SecondSuccessor = new ClassBalancedND();
    if (second == 1) {
      m_SecondSuccessor.m_Range = secondRange;
    } else {
      RemoveWithValues rwv = new RemoveWithValues();
      rwv.setInvertSelection(true);
      rwv.setNominalIndices(secondRange.getRanges());
      rwv.setAttributeIndex("" + (data.classIndex() + 1));
      rwv.setInputFormat(data);
      Instances secondSubset = Filter.useFilter(data, rwv);
      m_SecondSuccessor = new ClassBalancedND();
     
View Full Code Here

        }
        list.append(i + 1);
      }
    }
     
    Range newRange = new Range(list.toString());
    newRange.setUpper(data.numClasses() - 1);
 
    generateClassifierForNode(data, newRange, random, m_Classifier, m_classifiers);
  }
View Full Code Here

  /**
   * Resets stuff to default values
   */
  protected void resetOptions () {
    m_starting = null;
    m_startRange = new Range();
    m_attributeList = null;
    m_attributeMerit = null;
    m_threshold = -Double.MAX_VALUE;
  }
View Full Code Here

   *
   * @return the range of boolean attributes
   */
  public Range getBooleanCols() {
    if (m_booleanCols == null)
      m_booleanCols = new Range();

    return m_booleanCols;
  }
View Full Code Here

   *
   * @return the range of nominal attributes
   */
  public Range getNominalCols() {
    if (m_nominalCols == null)
      m_nominalCols = new Range();

    return m_nominalCols;
  }
View Full Code Here

   * Constructor
   */
  public GreedyStepwise () {
    m_threshold = -Double.MAX_VALUE;
    m_doneRanking = false;
    m_startRange = new Range();
    m_starting = null;
    resetOptions();
  }
View Full Code Here

   */
  protected boolean checkCoverage() {
    int         i;
    int         n;
    int[]       count;
    Range       r;
    String      attrIndex;
    SubspaceClusterDefinition  cl;
   
    // check whether all the attributes are covered
    count = new int[getNumAttributes()];
    for (i = 0; i < getNumAttributes(); i++) {
      for (n = 0; n < getClusters().length; n++) {
        cl = (SubspaceClusterDefinition) getClusters()[n];
        r  = new Range(cl.getAttrIndexRange());
        r.setUpper(getNumAttributes());
        if (r.isInRange(i))
          count[i]++;
      }
    }

    // list all indices that are not covered
View Full Code Here

      for(int i = 0; i < m_ClassFilters.length; i++) {
  if (m_Classifiers[i] != null) {
    Instance tempInst = (Instance)inst.copy();
    tempInst.setDataset(m_TwoClassDataset);
    double [] current = m_Classifiers[i].distributionForInstance(tempInst)
    Range range = new Range(((RemoveWithValues)m_ClassFilters[i])
          .getNominalIndices());
    range.setUpper(m_ClassAttribute.numValues());
    int[] pair = range.getSelection();
          if (m_pairwiseCoupling && inst.numClasses() > 2) {
            r[pair[0]][pair[1]] = current[0];
            n[pair[0]][pair[1]] = m_SumOfWeights[i];
          } else {
            if (current[0] > current[1]) {
View Full Code Here

TOP

Related Classes of weka.core.Range

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.