Package weka.core

Examples of weka.core.Instance.weight()


    int count = 0;
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
      if (!inst.isMissing(j)) {
        sortedIndices[0][j][count] = i;
        weights[0][j][count] = inst.weight();
        count++;
      }
    }
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
View Full Code Here


  private double computeAccu(Instances data, int clas){
    double accu = 0;
    for(int i=0; i<data.numInstances(); i++){
      Instance inst = data.instance(i);
      if((int)inst.classValue() == clas)
  accu += inst.weight();
    }
    return accu;
  }
   
View Full Code Here

      return 0;
 
    double mSqErr=0, sum = data.sumOfWeights();
    for(int i=0; i < data.numInstances(); i++){
      Instance datum = data.instance(i);
      mSqErr += datum.weight()*
  (datum.classValue() - mean)*
  (datum.classValue() - mean);
    }  
 
    return (mSqErr / sum);
View Full Code Here

    }
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
      if (inst.isMissing(j)) {
        sortedIndices[0][j][count] = i;
        weights[0][j][count] = inst.weight();
        count++;
      }
    }
  } else {
View Full Code Here

    double[] classProbs = new double[train.numClasses()];
    double totalWeight = 0, totalSumSquared = 0;
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
      if (data.classAttribute().isNominal()) {
  classProbs[(int)inst.classValue()] += inst.weight();
  totalWeight += inst.weight();
      } else {
  classProbs[0] += inst.classValue() * inst.weight();
  totalSumSquared += inst.classValue() * inst.classValue() * inst.weight();
  totalWeight += inst.weight();
View Full Code Here

    double totalWeight = 0, totalSumSquared = 0;
    for (int i = 0; i < train.numInstances(); i++) {
      Instance inst = train.instance(i);
      if (data.classAttribute().isNominal()) {
  classProbs[(int)inst.classValue()] += inst.weight();
  totalWeight += inst.weight();
      } else {
  classProbs[0] += inst.classValue() * inst.weight();
  totalSumSquared += inst.classValue() * inst.classValue() * inst.weight();
  totalWeight += inst.weight();
      }
View Full Code Here

      Instance inst = train.instance(i);
      if (data.classAttribute().isNominal()) {
  classProbs[(int)inst.classValue()] += inst.weight();
  totalWeight += inst.weight();
      } else {
  classProbs[0] += inst.classValue() * inst.weight();
  totalSumSquared += inst.classValue() * inst.classValue() * inst.weight();
  totalWeight += inst.weight();
      }
    }
    m_Tree = new Tree();
View Full Code Here

      if (data.classAttribute().isNominal()) {
  classProbs[(int)inst.classValue()] += inst.weight();
  totalWeight += inst.weight();
      } else {
  classProbs[0] += inst.classValue() * inst.weight();
  totalSumSquared += inst.classValue() * inst.classValue() * inst.weight();
  totalWeight += inst.weight();
      }
    }
    m_Tree = new Tree();
    double trainVariance = 0;
View Full Code Here

  classProbs[(int)inst.classValue()] += inst.weight();
  totalWeight += inst.weight();
      } else {
  classProbs[0] += inst.classValue() * inst.weight();
  totalSumSquared += inst.classValue() * inst.classValue() * inst.weight();
  totalWeight += inst.weight();
      }
    }
    m_Tree = new Tree();
    double trainVariance = 0;
    if (data.classAttribute().isNumeric()) {
View Full Code Here

    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();
  }
  sumOfWeights += instance.weight();
      }
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.