Package weka.core

Examples of weka.core.Instance.classValue()


     */
    private double computeDefAccu(Instances data){
      double defAccu=0;
      for(int i=0; i<data.numInstances(); i++){
  Instance inst = data.instance(i);
  if((int)inst.classValue() == (int)m_Consequent)
    defAccu += inst.weight();
      }
      return defAccu;
    }
 
View Full Code Here


    Instance ins=newData.instance(y);
       
    if(antd.covers(ins)){   // Covered by this antecedent
      coverage[x] += ins.weight();
      data.add(ins);                 // Add to data for further pruning
      if((int)ins.classValue() == (int)m_Consequent) // Accurate prediction
        worthValue[x] += ins.weight();
    }
    else if(useWhole){ // Not covered
      if((int)ins.classValue() != (int)m_Consequent)
        tn += ins.weight();
View Full Code Here

      data.add(ins);                 // Add to data for further pruning
      if((int)ins.classValue() == (int)m_Consequent) // Accurate prediction
        worthValue[x] += ins.weight();
    }
    else if(useWhole){ // Not covered
      if((int)ins.classValue() != (int)m_Consequent)
        tn += ins.weight();
    }     
  }
   
  if(useWhole){
View Full Code Here

    // compute counts for all the values
    for (int i = 0; i < instances.numInstances(); i++) {
      Instance inst = instances.instance(i);
      if (!inst.isMissing(attIndex)) {
  distribution[1][(int)inst.classValue()] += inst.weight();
      } else {
  distribution[2][(int)inst.classValue()] += inst.weight();
  numMissing++;
      }
    }
View Full Code Here

    for (int i = 0; i < instances.numInstances(); i++) {
      Instance inst = instances.instance(i);
      if (!inst.isMissing(attIndex)) {
  distribution[1][(int)inst.classValue()] += inst.weight();
      } else {
  distribution[2][(int)inst.classValue()] += inst.weight();
  numMissing++;
      }
    }

    // sort instances
View Full Code Here

    new ReferenceInstances(m_trainInstances, m_negTrainInstances.numInstances());
  for (Enumeration e = clone.m_trainInstances.enumerateInstances();
       e.hasMoreElements(); ) {
    Instance inst = (Instance) e.nextElement();
    try { // ignore classValue() exception
      if ((int) inst.classValue() == 0)
        clone.m_negTrainInstances.addReference(inst); // belongs in negative class
      else
        clone.m_posTrainInstances.addReference(inst); // belongs in positive class
    } catch (Exception ignored) {}
  }
View Full Code Here

            // ... calculate the counts for this class
            Enumeration enu = ruleE.enumerateInstances();
            while (enu.hasMoreElements()) {
              Instance i = (Instance) enu.nextElement();
              covers[(int) i.value(attr)]++;
              if ((int) i.classValue() == cl) {
                correct[(int) i.value(attr)]++;
        }
            }

            // ... for each value of this attribute, see if this test is better
View Full Code Here

        // Use training data
        for (int j = 0; j < insts.numInstances(); j++) {
          Instance inst = insts.instance(j);
          double[] vals = new double[2];
          vals[0] = SVMOutput(-1, inst);
          if (inst.classValue() == cl2) {
            vals[1] = 1;
          }
          data.add(new Instance(inst.weight(), vals));
        }
      } else {
View Full Code Here

    break;
  }
   
  sndCover += inst.weight();
  if(m_ClassAttribute.isNominal()) // Nominal class
    snd[(int)inst.classValue()] += inst.weight();   
  else{                            // Numeric class
    sndWtSq += inst.weight() * inst.classValue() * inst.classValue();
    sndWtVl += inst.weight() * inst.classValue();
  }
      }
View Full Code Here

   
  sndCover += inst.weight();
  if(m_ClassAttribute.isNominal()) // Nominal class
    snd[(int)inst.classValue()] += inst.weight();   
  else{                            // Numeric class
    sndWtSq += inst.weight() * inst.classValue() * inst.classValue();
    sndWtVl += inst.weight() * inst.classValue();
  }
      }
     
     
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.