Package weka.core

Examples of weka.core.Attribute.numValues()


      if (!att.isNominal() || (j == getInputFormat().classIndex()) ||
    !m_Columns.isInRange(j)) {
  vals[attSoFar] = instance.value(j);
  attSoFar++;
      } else {
  if ( (att.numValues() <= 2) && (!m_TransformAll) ) {
    vals[attSoFar] = instance.value(j);
    attSoFar++;
  } else {
    if (instance.isMissing(j)) {
      for (int k = 0; k < att.numValues(); k++) {
View Full Code Here


  if ( (att.numValues() <= 2) && (!m_TransformAll) ) {
    vals[attSoFar] = instance.value(j);
    attSoFar++;
  } else {
    if (instance.isMissing(j)) {
      for (int k = 0; k < att.numValues(); k++) {
              vals[attSoFar + k] = instance.value(j);
      }
    } else {
      for (int k = 0; k < att.numValues(); k++) {
        if (k == (int)instance.value(j)) {
View Full Code Here

    if (instance.isMissing(j)) {
      for (int k = 0; k < att.numValues(); k++) {
              vals[attSoFar + k] = instance.value(j);
      }
    } else {
      for (int k = 0; k < att.numValues(); k++) {
        if (k == (int)instance.value(j)) {
                vals[attSoFar + k] = 1;
        } else {
                vals[attSoFar + k] = 0;
        }
View Full Code Here

        } else {
                vals[attSoFar + k] = 0;
        }
      }
    }
    attSoFar += att.numValues();
  }
      }
    }
    Instance inst = null;
    if (instance instanceof SparseInstance) {
View Full Code Here

        new NormalEstimator(numPrecision);
    }
    break;
  case Attribute.NOMINAL:
    m_Distributions[attIndex][j] =
      new DiscreteEstimator(attribute.numValues(), true);
    break;
  default:
    throw new Exception("Attribute type unknown to NaiveBayes");
  }
      }
View Full Code Here

          if (a.name().length() > maxAttWidth) {
            maxAttWidth = m_Instances.attribute(i).name().length();
          }
          if (a.isNominal()) {
            // check values
            for (int j = 0; j < a.numValues(); j++) {
              String val = a.value(j) + "  ";
              if (val.length() > maxAttWidth) {
                maxAttWidth = val.length();
              }
            }
View Full Code Here

          }
          temp.append("\n\n");
           
        } else if (m_Distributions[counter][0] instanceof DiscreteEstimator) {
          Attribute a = m_Instances.attribute(i);
          for (int j = 0; j < a.numValues(); j++) {
            String val = "  " + a.value(j);
            temp.append(pad(val, " ", maxAttWidth + 1 - val.length(), false));
            for (int k = 0; k < m_Instances.numClasses(); k++) {
              DiscreteEstimator d = (DiscreteEstimator)m_Distributions[counter][k];
              String count = "" + d.getCount(j);
View Full Code Here

    Enumeration enu = instances.enumerateAttributes();
    while (enu.hasMoreElements()) {
      Attribute attribute = (Attribute) enu.nextElement();
      if (attribute.isNominal()) {
  for (int j = 0; j < instances.numClasses(); j++) {
    m_Counts[j][attIndex] = new double[attribute.numValues()];
  }
      } else {
  for (int j = 0; j < instances.numClasses(); j++) {
    m_Counts[j][attIndex] = new double[1];
  }
View Full Code Here

    while (enumAtts.hasMoreElements()) {
      Attribute attribute = (Attribute) enumAtts.nextElement();
      if (attribute.isNominal()) {
  for (int j = 0; j < instances.numClasses(); j++) {
    sum = Utils.sum(m_Counts[j][attIndex]);
    for (int i = 0; i < attribute.numValues(); i++) {
      m_Counts[j][attIndex][i] =
        (m_Counts[j][attIndex][i] + 1)
        / (sum + (double)attribute.numValues());
    }
  }
View Full Code Here

  for (int j = 0; j < instances.numClasses(); j++) {
    sum = Utils.sum(m_Counts[j][attIndex]);
    for (int i = 0; i < attribute.numValues(); i++) {
      m_Counts[j][attIndex][i] =
        (m_Counts[j][attIndex][i] + 1)
        / (sum + (double)attribute.numValues());
    }
  }
      }
      attIndex++;
    }
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.