Package weka.core

Examples of weka.core.Range


  public void setOptions(String[] options) throws Exception {
    String  tmpStr;
    String  classname;
    String[]  options2;
    Vector  objects;
    Range  range;

    super.setOptions(options);

    setRemoveUnused(Utils.getFlag("U", options));

    objects = new Vector();
    while ((tmpStr = Utils.getOption("F", options)).length() != 0) {
      options2    = Utils.splitOptions(tmpStr);
      classname      = options2[0];
      options2[0] = "";
      objects.add(Utils.forName(Filter.class, classname, options2));
    }

    // at least one filter
    if (objects.size() == 0)
      objects.add(new AllFilter());

    setFilters((Filter[]) objects.toArray(new Filter[objects.size()]));

    objects = new Vector();
    while ((tmpStr = Utils.getOption("R", options)).length() != 0) {
      if (tmpStr.startsWith("inv(") && tmpStr.endsWith(")")) {
  range = new Range(tmpStr.substring(4, tmpStr.length() - 1));
  range.setInvert(true);
      }
      else {
  range = new Range(tmpStr);
      }
      objects.add(range);
    }

    // at least one Range
    if (objects.size() == 0)
      objects.add(new Range("first-last"));

    setRanges((Range[]) objects.toArray(new Range[objects.size()]));

    // is number of filters the same as ranges?
    checkDimensions();
View Full Code Here


    for (int i = 0; i < getRanges().length; i++) {
      Instances newi = new Instances(instanceInfo, 0);
      if (instanceInfo.size() > 0){
  newi.add((Instance)instanceInfo.get(0).copy());
      }
      Range range = getRanges()[i];
      range.setUpper(instanceInfo.numAttributes() - 1);
      Instances subset = generateSubset(newi, range);
      getFilters()[i].setInputFormat(subset);
    }
  }
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

    for (int i = 0; i < m_Classifiers.length; i++) {
      text.append("Classifier ").append(i + 1);
      if (m_Classifiers[i] != null) {
        if ((m_ClassFilters != null) && (m_ClassFilters[i] != null)) {
    if (m_ClassFilters[i] instanceof RemoveWithValues) {
      Range range = new Range(((RemoveWithValues)m_ClassFilters[i])
            .getNominalIndices());
      range.setUpper(m_ClassAttribute.numValues());
      int[] pair = range.getSelection();
      text.append(", " + (pair[0]+1) + " vs " + (pair[1]+1));
    } else if (m_ClassFilters[i] instanceof MakeIndicator) {
      text.append(", using indicator values: ");
      text.append(((MakeIndicator)m_ClassFilters[i]).getValueRange());
    }
View Full Code Here

  }

  /** Default constructor */
  public RemoveWithValues() {

      m_Values = new Range("first-last");
      m_Values.setInvert(true);
  }
View Full Code Here

   
    if (rng == null || rng.length() == 0) {
      return null;
    }
   
    Range range = new Range(rng);
    range.setUpper(m_simpleConfig.getHorizonValue());
    int[] indices = range.getSelection();
   
    List<Integer> rangeList = new ArrayList<Integer>();
    for (int i : indices) {
      rangeList.add((i + 1));
    }
View Full Code Here

   * @return a Range object
   * @throws Exception if the supplied range is illegal with respect to the min
   *           and max lag values.
   */
  protected Range getLagRangeSelection(String lagRange) throws Exception {
    Range r = new Range(lagRange);
    try {
      r.setUpper(m_maxLag);
    } catch (IllegalArgumentException e) {
      throw new Exception("The lag selection range '" + lagRange + "' is"
          + "illegal with respect to the specified min and max" + "lags.");
    }

    // still need to check against the min
    int[] selectedIndexes = r.getSelection();
    int max = selectedIndexes[Utils.maxIndex(selectedIndexes)] + 1;
    int min = selectedIndexes[Utils.minIndex(selectedIndexes)] + 1;
    if (max < m_minLag || min > m_maxLag) {
      throw new Exception("The lag selection range '" + lagRange + "' is"
          + "illegal with respect to the specified min and max" + "lags.");
View Full Code Here

    }

    m_lagMakers = new ArrayList<Filter>();

    // do we have a fine tuning range for lags?
    Range r = null;
    int[] rangeIndexes = null;
    if (m_lagFineTune.length() > 0) {
      r = getLagRangeSelection(m_lagFineTune);
      rangeIndexes = r.getSelection();
    }

    for (int j = 0; j < m_fieldsToLag.size(); j++) {
      int classIndex = insts.attribute(m_fieldsToLag.get(j)).index();
      if (classIndex < 0) {
View Full Code Here

    m_pCrossover = 0.6;
    m_pMutation = 0.033;
    m_maxGenerations = 20;
    m_reportFrequency = m_maxGenerations;
    m_starting = null;
    m_startRange = new Range();
    m_seed = 1;
  }
View Full Code Here

    // to output) and the third a Boolean (whether or not to output a distribution instead
    // of just a classification)
    if (forPredictionsPrinting.length > 0) {
      // print the header first
      StringBuffer buff = (StringBuffer)forPredictionsPrinting[0];
      Range attsToOutput = (Range)forPredictionsPrinting[1];
      boolean printDist = ((Boolean)forPredictionsPrinting[2]).booleanValue();
      printClassificationsHeader(data, attsToOutput, printDist, buff);
    }

    // Do the folds
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.