Package weka.core

Examples of weka.core.Attribute.numValues()


   
    // prepare arrays
    for (attIndex = 0; attIndex < m_numAtts; attIndex++) {
      Attribute attribute = (Attribute) instances.attribute(attIndex);
      for (j = 0; j < m_numClasses; j++) {
        m_Counts[j][attIndex] = new int[attribute.numValues()];
        m_tCounts[j][attIndex] = new int[attribute.numValues()];
      }
    }

    // Compute counts and priors
View Full Code Here


    // prepare arrays
    for (attIndex = 0; attIndex < m_numAtts; attIndex++) {
      Attribute attribute = (Attribute) instances.attribute(attIndex);
      for (j = 0; j < m_numClasses; j++) {
        m_Counts[j][attIndex] = new int[attribute.numValues()];
        m_tCounts[j][attIndex] = new int[attribute.numValues()];
      }
    }

    // Compute counts and priors
    for(i = 0; i < m_numInsts; i++) {
View Full Code Here

      int [][] countsPointer1 = m_Counts[classVal];
      for(attIndex = 0; attIndex < m_numAtts; attIndex++) {
        Attribute attribute = m_Instances.attribute(attIndex);
         // love those pointers for saving time
         int [] countsPointer2 = countsPointer1[attIndex];
        for(attVal = 0; attVal < attribute.numValues(); attVal++)  {
          countsPointer2[attVal] = 0;
        }
     }
     m_Priors[classVal] = 0;
   }
View Full Code Here

         newVals.addElement(oldAtt.value(selection[i]));
      }
      instanceInfo.deleteAttributeAt(m_AttIndex.getIndex());
      instanceInfo.insertAttributeAt(new Attribute(oldAtt.name(), newVals),
            m_AttIndex.getIndex());
      m_NominalMapping = new int [oldAtt.numValues()];
      for (i = 0; i < m_NominalMapping.length; i++) {
         boolean found = false;
         for (int j = 0; j < selection.length; j++) {
            if (selection[j] == i) {
               m_NominalMapping[i] = j;
View Full Code Here

    int indexOfFirstMissingValue = -1;

    if (attribute.isNominal()) {

      // For nominal attributes
      dist = new double[attribute.numValues()][data.numClasses()];
      for (int i = 0; i < data.numInstances(); i++) {
        Instance inst = data.instance(i);
        if (inst.isMissing(att)) {

          // Skip missing values at this stage
View Full Code Here

  newVals.addElement(oldAtt.value(selection[i]));
      }
      instanceInfo.deleteAttributeAt(m_AttIndex.getIndex());
      instanceInfo.insertAttributeAt(new Attribute(oldAtt.name(), newVals),
              m_AttIndex.getIndex());
      m_NominalMapping = new int [oldAtt.numValues()];
      for (int i = 0; i < m_NominalMapping.length; i++) {
  boolean found = false;
  for (int j = 0; j < selection.length; j++) {
    if (selection[j] == i) {
      m_NominalMapping[i] = j;
View Full Code Here

  // attribute index remains unchanged.
  newAtts.addElement(att);
      } else {
   
  // Compute list of attribute values
  newVals = new FastVector(att.numValues());
  for (int i = 0; i < att.numValues(); i++) {
          newVals.addElement(att.value(i));
  }
  newAtts.addElement(new Attribute(att.name(), newVals));
      }
View Full Code Here

  newAtts.addElement(att);
      } else {
   
  // Compute list of attribute values
  newVals = new FastVector(att.numValues());
  for (int i = 0; i < att.numValues(); i++) {
          newVals.addElement(att.value(i));
  }
  newAtts.addElement(new Attribute(att.name(), newVals));
      }
    }
View Full Code Here

      FastVector attInfo = new FastVector();
      for (int i = 0; i < miningSchemaI.numAttributes(); i++) {
        Attribute tempA = miningSchemaI.attribute(i);
        if (tempA.isString()) {
          FastVector valueVector = new FastVector();
          for (int j = 0; j < tempA.numValues(); j++) {
            valueVector.addElement(tempA.value(j));
          }
          Attribute newAtt = new Attribute(tempA.name(), valueVector);
          attInfo.addElement(newAtt);
        } else {
View Full Code Here

                  incomingAtt.toString() + ".");
            }
          }

          // check nominal values (number, names...)
          if (miningSchemaAtt.numValues() != incomingAtt.numValues()) {
            String warningString = "[MappingInfo] WARNING: incoming nominal attribute "
              + incomingAtt.name() + " does not have the same "
              + "number of values as the corresponding mining "
              + "schema attribute.";
            if (m_log != 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.