Package weka.core

Examples of weka.core.Instance.classIsMissing()


        break;
    }
    Enumeration enu = instances.enumerateInstances();
    while (enu.hasMoreElements()) {
      Instance instance = (Instance) enu.nextElement();
      if (!instance.classIsMissing()) {
  if (instances.classAttribute().isNominal()) {
    m_Counts[(int)instance.classValue()] += instance.weight();
  } else {
    m_ClassValue += instance.weight() * instance.classValue();
  }
 
View Full Code Here


    m_K = 0;
  out:
    for (int it = 0; it < m_NumIterations; it++) {
      for (int i = 0; i < m_Train.numInstances(); i++) {
  Instance inst = m_Train.instance(i);
  if (!inst.classIsMissing()) {
    int prediction = makePrediction(m_K, inst);
    int classValue = (int) inst.classValue();
    if (prediction == classValue) {
      m_Weights[m_K]++;
    } else {
View Full Code Here

  double sumWeightedXDiffSquared = 0;
  double sumWeightedYDiffSquared = 0;
  m_slope = 0;
  for (int j = 0; j < insts.numInstances(); j++) {
    Instance inst = insts.instance(j);
    if (!inst.isMissing(i) && !inst.classIsMissing()) {
      double xDiff = inst.value(i) - xMean;
      double yDiff = inst.classValue() - yMean;
      double weightedXDiff = inst.weight() * xDiff;
      double weightedYDiff = inst.weight() * yDiff;
      m_slope += weightedXDiff * yDiff;
 
View Full Code Here

    // Calculate the mean value for each bin of the new class attribute
    m_ClassMeans = new double [numClasses];
    m_ClassCounts = new int [numClasses];
    for (int i = 0; i < instances.numInstances(); i++) {
      Instance inst = newTrain.instance(i);
      if (!inst.classIsMissing()) {
  int classVal = (int) inst.classValue();
  m_ClassCounts[classVal]++;
  m_ClassMeans[classVal] += instances.instance(i).classValue();
      }
    }
View Full Code Here

   
    // divide instances into subsets
    Enumeration e = runInstances.enumerateInstances();
    while(e.hasMoreElements()) {
      Instance inst = (Instance) e.nextElement();
      if (inst.classIsMissing()) {
        subsets[numClasses].add(inst);
      } else {
        subsets[(int) inst.classValue()].add(inst);
      }
    }
View Full Code Here

    int[] classIndices = new int [getInputFormat().numClasses() + 1];
    int currentClass = 0;
    classIndices[currentClass] = 0;
    for (int i = 0; i < getInputFormat().numInstances(); i++) {
      Instance current = getInputFormat().instance(i);
      if (current.classIsMissing()) {
  for (int j = currentClass + 1; j < classIndices.length; j++) {
    classIndices[j] = i;
  }
  break;
      } else if (current.classValue() != currentClass) {
View Full Code Here

    int [] counts = new int [getInputFormat().numClasses()];
    double [] weights = new double [getInputFormat().numClasses()];
    int min = -1;
    for (int i = 0; i < getInputFormat().numInstances(); i++) {
      Instance current = getInputFormat().instance(i);
      if (current.classIsMissing() == false) {
        counts[(int)current.classValue()]++;
        weights[(int)current.classValue()]+= current.weight();
      }
    }
View Full Code Here

    int [] classIndices = new int [getInputFormat().numClasses() + 1];
    int currentClass = 0;
    classIndices[currentClass] = 0;
    for (int i = 0; i < getInputFormat().numInstances(); i++) {
      Instance current = getInputFormat().instance(i);
      if (current.classIsMissing()) {
        for (int j = currentClass + 1; j < classIndices.length; j++) {
          classIndices[j] = i;
        }
        break;
      } else if (current.classValue() != currentClass) {
View Full Code Here

      if (att.isNominal()) {
  avgClassValues[j] = new double [att.numValues()];
  counts = new double [att.numValues()];
  for (int i = 0; i < getInputFormat().numInstances(); i++) {
    instance = getInputFormat().instance(i);
    if (!instance.classIsMissing() &&
        (!instance.isMissing(j))) {
      counts[(int)instance.value(j)] += instance.weight();
      avgClassValues[j][(int)instance.value(j)] +=
        instance.weight() * instance.classValue();
    }
View Full Code Here

            this.instanceClasses = new Integer[numberInstances];
            this.countByClassValue = new int[numberClassValues];

            for (int i = 0; i < numberInstances; i++) {
                Instance inst = instances.get(i);
                if (inst.classIsMissing()) {
                    instanceClasses[i] = null;
                } else {
                    instanceClasses[i] = (int) inst.classValue();

                    //Record how many instances have each class value
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.