Package weka.core

Examples of weka.core.Instance.classValue()


      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


  Instance inst;
  double llsum = 0.0;
  for (int i=0; i<m_validationSet.numInstances(); i++) {
    inst = m_validationSet.instance(i);
    llsum += (logLikelihood(m_validationFs[i],(int) inst.classValue()));
  }
  m_lastLogLikelihood = llsum / (double) m_validationSet.numInstances();
  m_modelHasChangedLL = false;
      }
      return m_lastLogLikelihood;
View Full Code Here

  Instance inst;
  double llsum = 0.0;
  for (int i=0; i<m_validationSet.numInstances(); i++) {
    inst = m_validationSet.instance(i);
    llsum += (logLikelihood(m_newValidationFs[i],(int) inst.classValue()));
  }
  return llsum / (double) m_validationSet.numInstances();
    }

   
View Full Code Here

  Instance inst;
  int numIncorrect = 0;
  for (int i=0; i<m_validationSet.numInstances(); i++) {
    inst = m_validationSet.instance(i);
    if (classifyInstance(m_validationFs[i]) != inst.classValue())
      numIncorrect++;
  }
  m_lastValidationError = (double) numIncorrect / (double) m_validationSet.numInstances();
  m_modelHasChanged = false;
      }
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

      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();
      }
    }
    if (instances.classAttribute().isNumeric()) {
View Full Code Here

   * @throws Exception if the returned exemplar is wrong
   */
  public Instance preprocess(Instances data, int pos)
    throws Exception{
    Instance before = data.instance(pos);
    if((int)before.classValue() == 0){
      m_NoiseM[pos] = null;
      m_NoiseV[pos] = null;
      return before;
    }

View Full Code Here

    total = x;
    break;
  }
   
  sndCover += inst.weight();
  if(Utils.eq(inst.classValue(), cl))
    sndAccu += inst.weight();   
      }     

      if(total == 0) return null; // Data all missing for the attribute
      splitPoint = data.instance(total-1).value(att)
View Full Code Here

  Instance inst=data.instance(x);
  if(!inst.isMissing(att)){
    int v = (int)inst.value(att);
    splitData[v].add(inst);
    coverage[v] += inst.weight();
    if((int)inst.classValue() == (int)cl)
      accurate[v] += inst.weight();
  }
      }
     
      for(int x=0; x<bag; x++){
View Full Code Here

             m_trainInstances.numInstances());
    m_negTrainInstances = new ReferenceInstances(m_trainInstances,
             m_trainInstances.numInstances());
    for (Enumeration e = m_trainInstances.enumerateInstances(); e.hasMoreElements(); ) {
      Instance inst = (Instance) e.nextElement();
      if ((int) inst.classValue() == 0)
  m_negTrainInstances.addReference(inst); // belongs in negative class
      else
  m_posTrainInstances.addReference(inst); // belongs in positive class
    }
    m_posTrainInstances.compactify();
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.