Package weka.core

Examples of weka.core.Attribute.index()


          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


        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
View Full Code Here

            .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()
View Full Code Here

          .createDataFieldType();
      dataField.setDataType(DATATYPE.DOUBLE); // DATATYPE
      dataField.setName(attr.name()); // String
      dataField.setOptype(OPTYPE.CONTINUOUS); // OPTYPE
      String[] strCoordinates = null;
      strCoordinates = createAnchors(attr.index(), k);
      // Add Extension - Coordinate X
      ExtensionType extension = _40Factory.eINSTANCE
          .createExtensionType();
      extension.setName("xCoordinate");
      extension.setValue(strCoordinates[0]);
View Full Code Here

    Attribute attr = (Attribute) attrEnum.nextElement();
    if (!attr.equals(getInputFormat().classAttribute())) {
      if (attr.isNumeric()) {
        double dif = nnArray[nn].value(attr) - instanceI.value(attr);
        double gap = rand.nextDouble();
        values[attr.index()] = (double) (instanceI.value(attr) + gap * dif);
      } else if (attr.isDate()) {
        double dif = nnArray[nn].value(attr) - instanceI.value(attr);
        double gap = rand.nextDouble();
        values[attr.index()] = (long) (instanceI.value(attr) + gap * dif);
      } else {
View Full Code Here

        double gap = rand.nextDouble();
        values[attr.index()] = (double) (instanceI.value(attr) + gap * dif);
      } else if (attr.isDate()) {
        double dif = nnArray[nn].value(attr) - instanceI.value(attr);
        double gap = rand.nextDouble();
        values[attr.index()] = (long) (instanceI.value(attr) + gap * dif);
      } else {
        int[] valueCounts = new int[attr.numValues()];
        int iVal = (int) instanceI.value(attr);
        valueCounts[iVal]++;
        for (int nnEx = 0; nnEx < nearestNeighbors; nnEx++) {
View Full Code Here

    if (valueCounts[index] > max) {
      max = valueCounts[index];
      maxIndex = index;
    }
        }
        values[attr.index()] = maxIndex;
      }
    }
  }
  values[sample.classIndex()] = minIndex;
  Instance synthetic = new Instance(1.0, values);
View Full Code Here

      // nothing to do
    } else {
      // try to look up class attribute as a label
      Attribute classAtt = format.attribute(classColString);
      if (classAtt != null) {
        existingClassCol = classAtt.index();
      } else {
        // parse it as a number
        existingClassCol = Integer.parseInt(classColString);
        if (existingClassCol < 0) {
          existingClassCol = -1; // no class
View Full Code Here

      splitData(subsetIndices, subsetWeights, m_Attribute, m_SplitValue,
    m_SplitString, sortedIndices, weights, data);

      // If split will generate node(s) which has total weights less than m_minNumObj,
      // do not split.
      int attIndex = att.index();
      if (subsetIndices[0][attIndex].length<minNumObj ||
    subsetIndices[1][attIndex].length<minNumObj) {
  makeLeaf(data);
      }
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.