Package weka.core

Examples of weka.core.Instance.weight()


      m_MaxTarget = -Double.MAX_VALUE;

      for (int i = 0; i < train.numInstances(); i++) {
        Instance currentInst = train.instance(i);
        if (!currentInst.classIsMissing()) {
          addNumericTrainClass(currentInst.classValue(), currentInst.weight());
        }
      }

      m_ClassPriors[0] = m_ClassPriorsSum = 0;
      for (int i = 0; i < train.numInstances(); i++) {
View Full Code Here


  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;
      sumWeightedXDiffSquared += weightedXDiff * xDiff;
      sumWeightedYDiffSquared += weightedYDiff * yDiff;
    }
View Full Code Here

    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;
      sumWeightedXDiffSquared += weightedXDiff * xDiff;
      sumWeightedYDiffSquared += weightedYDiff * yDiff;
    }
  }
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

 
    for (int i = 0; i < nC; i++) {
      // initialize X[][]
      Instance current = train.instance(i);
      Y[i] = (int)current.classValue()// Class value starts from 0
      weights[i] = current.weight();     // Dealing with weights
      totWeights += weights[i];
     
      m_Data[i][0] = 1;
      int j = 1;
      for (int k = 0; k <= nR; k++) {
View Full Code Here

  start++;
      }

      // create new instance
      if (oldInstance instanceof SparseInstance)
  newInstance = new SparseInstance(oldInstance.weight(), newValues);
      else
  newInstance = new Instance(oldInstance.weight(), newValues);

      // copy string/relational values from input to output
      copyValues(newInstance, false, oldInstance.dataset(), getOutputFormat());
View Full Code Here

      // create new instance
      if (oldInstance instanceof SparseInstance)
  newInstance = new SparseInstance(oldInstance.weight(), newValues);
      else
  newInstance = new Instance(oldInstance.weight(), newValues);

      // copy string/relational values from input to output
      copyValues(newInstance, false, oldInstance.dataset(), getOutputFormat());

      result.add(newInstance);
View Full Code Here

    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();
      }
    }

    // Convert from total weight to average weight
    for (int i = 0; i < counts.length; i++) {
View Full Code Here

  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();
    }
  }
  sum = Utils.sum(avgClassValues[j]);
View Full Code Here

    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();
    }
  }
  sum = Utils.sum(avgClassValues[j]);
  totalCounts = Utils.sum(counts);
  if (Utils.gr(totalCounts, 0)) {
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.