Package weka.core

Examples of weka.core.Instances.attribute()


    } else {
      m_useArtificialTimeIndex = false;
    }

    if (m_adjustForTrends) {
      int timeStampIndex = result.attribute(m_timeStampName).index();

      m_lastTimeValue = result.instance(result.numInstances() - 1).value(
          timeStampIndex);
      Instance last = result.instance(result.numInstances() - 1);
      Instance secondToLast = result.instance(result.numInstances() - 2);
View Full Code Here


    List<String> fieldsToForecast = AbstractForecaster.stringToList(forecaster
        .getFieldsToForecast());
    for (int i = 0; i < overlay.numInstances(); i++) {
      Instance current = overlay.instance(i);
      for (String target : fieldsToForecast) {
        current.setValue(overlay.attribute(target), Utils.missingValue());
      }
    }

    return overlay;
  }
View Full Code Here

    // Create the output buffer
    Instances outputFormat = new Instances(instanceInfo, 0);
    for(int i = 0; i < instanceInfo.numAttributes(); i++) {
      if (i != instanceInfo.classIndex()) {
        if (m_SelectedCols.isInRange(i)) {
          if (outputFormat.attribute(i).isNominal()
              || outputFormat.attribute(i).isNumeric()) {
            outputFormat.renameAttribute(i, outputFormat.attribute(i).name()
                                         + (m_InstanceRange < 0 ? '-' : '+')
                                         + Math.abs(m_InstanceRange));
          } else {
View Full Code Here

    Instances outputFormat = new Instances(instanceInfo, 0);
    for(int i = 0; i < instanceInfo.numAttributes(); i++) {
      if (i != instanceInfo.classIndex()) {
        if (m_SelectedCols.isInRange(i)) {
          if (outputFormat.attribute(i).isNominal()
              || outputFormat.attribute(i).isNumeric()) {
            outputFormat.renameAttribute(i, outputFormat.attribute(i).name()
                                         + (m_InstanceRange < 0 ? '-' : '+')
                                         + Math.abs(m_InstanceRange));
          } else {
            throw new UnsupportedAttributeTypeException("Only numeric and nominal attributes may be "
View Full Code Here

    for(int i = 0; i < instanceInfo.numAttributes(); i++) {
      if (i != instanceInfo.classIndex()) {
        if (m_SelectedCols.isInRange(i)) {
          if (outputFormat.attribute(i).isNominal()
              || outputFormat.attribute(i).isNumeric()) {
            outputFormat.renameAttribute(i, outputFormat.attribute(i).name()
                                         + (m_InstanceRange < 0 ? '-' : '+')
                                         + Math.abs(m_InstanceRange));
          } else {
            throw new UnsupportedAttributeTypeException("Only numeric and nominal attributes may be "
                                                        + " manipulated in time series.");
View Full Code Here

              // now check the other attributes against the training
              // structure
              boolean ok = true;
              for (int i = 0; i < testSet.numAttributes(); i++) {
                if (i != testSet.classIndex()) {
                  ok = testSet.attribute(i).equals(m_trainingSet.attribute(i));
                  if (!ok) {
                    break;
                  }
                }
              }
View Full Code Here

        outBuff.append("Relation:     " + inst.relationName() + '\n');
        outBuff.append("Instances:    " + inst.numInstances() + '\n');
        outBuff.append("Attributes:   " + inst.numAttributes() + '\n');
        if (inst.numAttributes() < 100) {
          for (int i = 0; i < inst.numAttributes(); i++) {
            outBuff.append("              " + inst.attribute(i).name()
                + '\n');
          }
        } else {
          outBuff.append("              [list of attributes omitted]\n");
        }
View Full Code Here

      if (rmAttributes.length > 0) {
        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);
      }
View Full Code Here

        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)
        data.setClass(data.attribute(attribute));
     
      // train M5P
      cl = new M5P();
      cl.setBuildRegressionTree(true);
      cl.setUnpruned(false);
View Full Code Here

      // count numeric and nominal attributes
      int numNumeric = 0, numNominal = 0;
      for (int i = 0; i < data.numAttributes(); i++) {
        if ( data.classIndex()==i )
          continue;
        if ( data.attribute(i).isNominal() )
          numNominal++;
        if ( data.attribute(i).isNumeric() )
          numNumeric++;
      }
      System.err.printf( "%s\t%d\t%d\t%d\t%d\t", curArff.getName(), data.numInstances(), numNumeric, numNominal, data.numClasses() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.