Package weka.core

Examples of weka.core.Instance.weight()


    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


   
    // do positives
    double weightMultiplier = Math.pow(Math.E, -predictionValue);
    for (Enumeration e = posInstances.enumerateInstances(); e.hasMoreElements(); ) {
      Instance inst = (Instance) e.nextElement();
      inst.setWeight(inst.weight() * weightMultiplier);
    }
    // do negatives
    weightMultiplier = Math.pow(Math.E, predictionValue);
    for (Enumeration e = negInstances.enumerateInstances(); e.hasMoreElements(); ) {
      Instance inst = (Instance) e.nextElement();
View Full Code Here

   
  for(int y=0; y<newData.numInstances(); y++){
    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
View Full Code Here

       
    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

    }
    // do negatives
    weightMultiplier = Math.pow(Math.E, predictionValue);
    for (Enumeration e = negInstances.enumerateInstances(); e.hasMoreElements(); ) {
      Instance inst = (Instance) e.nextElement();
      inst.setWeight(inst.weight() * weightMultiplier);
    }
  }

  /**
   * Finds the nominal attribute value to split on that results in the lowest Z-value.
View Full Code Here

      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){
    worthValue[x] += tn;
View Full Code Here

    double[] weights = new double[instances.attribute(attIndex).numValues()];
    for(int i = 0; i < weights.length; i++) weights[i] = 0.0;

    for (Enumeration e = instances.enumerateInstances(); e.hasMoreElements(); ) {
      Instance inst = (Instance) e.nextElement();
      if (!inst.isMissing(attIndex)) weights[(int)inst.value(attIndex)] += inst.weight();
    }
    return weights;
  }

  /**
 
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

          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 {

        // Check whether number of folds too large
        if (numFolds > insts.numInstances()) {
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.