Package weka.core

Examples of weka.core.Attribute.index()


    }

    // now check for missing date values (if necessary)
    if (timeStampAtt != null) {

      int attIndex = timeStampAtt.index(); // result.attribute(timeStampName).index();

      double firstNonMissing = result.instance(0).value(attIndex);
      double previousNonMissing = firstNonMissing;
      int firstNonMissingIndex = -1;
      boolean leadingMissingDates = weka.core.Utils
View Full Code Here


          boolean[] newSelected = new boolean[insts.numAttributes()];
          for (int i = 0; i < selected.length; i++) {
            Attribute toFind = oldList.attribute(selected[i]);
            Attribute toSet = insts.attribute(toFind.name());
            if (toSet != null) {
              newSelected[toSet.index()] = true;
            }
          }
          try {
            m_dateDerivedPeriodicSelector.setSelectedAttributes(newSelected);
          } catch (Exception e1) {
View Full Code Here

        logError("couldn't find time stamp: " + m_timeStampName
            + "in the input data", null);
        stop();
        return;
      }
      timeStampIndex = timeStampAtt.index();
    }

    statusMessage("Generating forecast...");
    logMessage("Generating forecast.");
    for (int i = 0; i < numSteps; i++) {
View Full Code Here

    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

    FastVector vecBool = new FastVector(2);vecBool.addElement(Boolean.TRUE.toString());vecBool.addElement(Boolean.FALSE.toString());
    Attribute attrA = new Attribute("a", vecA), attrB= new Attribute("b",vecA), attrC=new Attribute("c",vecA),attrClass=new Attribute("class",vecBool);
   
    FastVector attributes = new FastVector(attributeNumber);attributes.addElement(attrA);attributes.addElement(attrB);attributes.addElement(attrC);attributes.addElement(attrClass);
    Instances trainingData = new Instances("trainingdata",attributes,10);// this assigns indices to attributes, without these indices I cannot create instances.
    trainingData.setClassIndex(attrClass.index());
    Instance inst = new Instance(attributeNumber);
    inst.setValue(attrA,0);inst.setValue(attrB, 1);inst.setValue(attrC, 1);inst.setValue(attrClass, 0);
    Assert.assertEquals(4,trainingData.numAttributes());
    Assert.assertEquals(0,trainingData.numInstances());
    trainingData.add(inst);
View Full Code Here

            Attribute wordAttr = instances.attribute(word.getKey());
            int valueIndex = wordAttr.indexOfValue(word.getValue());
            if (valueIndex == -1) {
              throw new IOException("oops! " + word);
            }
            wekaInstance.setValue(wordAttr.index(), valueIndex);
          }
        }
        instances.add(wekaInstance);
      }
    }
View Full Code Here

      Arrays.fill(zeroValues, 0.0d);
      SparseInstance wekaInstance = new SparseInstance(1.0d, zeroValues);
      wekaInstance.setDataset(instances);
      // set instance id
      Attribute instanceId = instances.attribute(INSTANCE_ID);
      wekaInstance.setValue(instanceId.index(), entry.getKey()
          .doubleValue());
      // set document class
      Attribute classAttr = instances.attribute(CLASS);
      wekaInstance.setValue(classAttr.index(),
          classAttr.indexOfValue(entry.getValue()));
View Full Code Here

      Attribute instanceId = instances.attribute(INSTANCE_ID);
      wekaInstance.setValue(instanceId.index(), entry.getKey()
          .doubleValue());
      // set document class
      Attribute classAttr = instances.attribute(CLASS);
      wekaInstance.setValue(classAttr.index(),
          classAttr.indexOfValue(entry.getValue()));
      // set numeric words
      if (bagOfWordsData.getInstanceNumericWords().get(entry.getKey()) != null) {
        for (Map.Entry<String, Double> word : bagOfWordsData
            .getInstanceNumericWords().get(entry.getKey())
View Full Code Here

      if (bagOfWordsData.getInstanceNumericWords().get(entry.getKey()) != null) {
        for (Map.Entry<String, Double> word : bagOfWordsData
            .getInstanceNumericWords().get(entry.getKey())
            .entrySet()) {
          Attribute wordAttr = instances.attribute(word.getKey());
          wekaInstance.setValue(wordAttr.index(), word.getValue()
              .doubleValue());
        }
      }
      // set nominal words
      if (bagOfWordsData.getInstanceNominalWords().get(entry.getKey()) != null) {
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.