Package weka.core

Examples of weka.core.Instance.numValues()


                                          Instances insts) {
    double[] attrVals = new double[insts.numAttributes()];
    Instance temp;
    for(int i=start; i<=end; i++) {
      temp = insts.instance(instList[i]);
      for(int j=0; j<temp.numValues(); j++) {
        attrVals[j] += temp.valueSparse(j);
      }
    }
    for(int j=0, numInsts=end-start+1; j<attrVals.length; j++) {
      attrVals[j] /= numInsts;
View Full Code Here


      if (m_filterType != FILTER_NONE) {
  m_AvgDocLength = 0;
  for(int i=0; i<fv.size(); i++) {
    Instance inst = (Instance) fv.elementAt(i);
    double docLength = 0;
    for(int j=0; j<inst.numValues(); j++) {
      if(inst.index(j)>=firstCopy) {
        docLength += inst.valueSparse(j) * inst.valueSparse(j);
      }
    }       
    m_AvgDocLength += Math.sqrt(docLength);
View Full Code Here

      {
  instance = (Instance) enumInsts.nextElement();
  classIndex = (int)instance.value(instance.classIndex());
  docsPerClass[classIndex] += instance.weight();
   
  for(int a = 0; a<instance.numValues(); a++)
    if(instance.index(a) != instance.classIndex())
      {
        if(!instance.isMissing(a))
    {
      numOccurences = instance.valueSparse(a) * instance.weight();
 
View Full Code Here

  sums[i] = sumOfWeights;
      }
      double[] results = new double[getInputFormat().numAttributes()];
      for (int j = 0; j < getInputFormat().numInstances(); j++) {
  Instance inst = getInputFormat().instance(j);
  for (int i = 0; i < inst.numValues(); i++) {
    if (!inst.isMissingSparse(i)) {
      double value = inst.valueSparse(i);
      if (inst.attributeSparse(i).isNominal()) {
              if (counts[inst.index(i)].length > 0) {
                counts[inst.index(i)][(int)value] += inst.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.