Package weka.core

Examples of weka.core.Instance.numValues()


      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


  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()) {
        counts[inst.index(i)][(int)value] += inst.weight();
        counts[inst.index(i)][0] -= inst.weight();
View Full Code Here

    double[] attrVals = new double[insts.numAttributes()];
   
    Instance temp;
    for(int i=0; i<list1.length(); i++) {
      temp = insts.instance(((ListNode)list1.get(i)).idx);
      for(int k=0; k<temp.numValues(); k++) {
        if(temp.index(k)==classIdx)
          continue;
        attrVals[k] += temp.valueSparse(k);
      }
    }
View Full Code Here

        attrVals[k] += temp.valueSparse(k);
      }
    }
    for(int j=0; j<list2.length(); j++) {
      temp = insts.instance(((ListNode)list2.get(j)).idx);
      for(int k=0; k<temp.numValues(); k++) {
        if(temp.index(k)==classIdx)
          continue;
        attrVals[k] += temp.valueSparse(k);
      }
    }
View Full Code Here

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

                                          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

    }

    // Get counts
    for (int k = 0; k < numInstances; k++) {
      Instance inst = data.instance(k);
      for (int i = 0; i < inst.numValues(); i++) {
        if (inst.index(i) != classIndex) {
          if (inst.isMissingSparse(i) || inst.classIsMissing()) {
            if (!inst.isMissingSparse(i)) {
              counts[inst.index(i)][(int)inst.valueSparse(i)][numClasses] +=
                inst.weight();
View Full Code Here

      double temp_diffP_diffA_givNearest =
        difference(m_classIndex, inst.value(m_classIndex),
                   cmp.value(m_classIndex));
      // now the attributes
      for (int p1 = 0, p2 = 0;
           p1 < inst.numValues() || p2 < cmp.numValues();) {
        if (p1 >= inst.numValues()) {
          firstI = m_trainInstances.numAttributes();
        } else {
          firstI = inst.index(p1);
        }
View Full Code Here

        if (p1 >= inst.numValues()) {
          firstI = m_trainInstances.numAttributes();
        } else {
          firstI = inst.index(p1);
        }
        if (p2 >= cmp.numValues()) {
          secondI = m_trainInstances.numAttributes();
        } else {
          secondI = cmp.index(p2);
        }
        if (firstI == m_trainInstances.classIndex()) {
View Full Code Here

        ? m_trainInstances.
        instance((int)m_karray[cl][tempSortedClass[j]][1])
        : m_trainInstances.instance((int)m_karray[cl][j][1]);

      for (int p1 = 0, p2 = 0;
           p1 < inst.numValues() || p2 < cmp.numValues();) {
        if (p1 >= inst.numValues()) {
          firstI = m_trainInstances.numAttributes();
        } else {
          firstI = inst.index(p1);
        }
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.