Package weka.core

Examples of weka.core.Instance.numValues()


        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[k][tempSortedAtt[k][j]][1])
              : m_trainInstances.instance((int)m_karray[k][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

              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

   * @throws Exception  if missing values are encountered
   */
  protected void checkMissing(Instances instances) throws Exception {
    for (int i = 0; i < instances.numInstances(); i++) {
      Instance ins = instances.instance(i);
      for (int j = 0; j < ins.numValues(); j++) {
        if (ins.index(j) != ins.classIndex())
          if (ins.isMissingSparse(j)) {
            throw new Exception("ERROR: KDTree can not deal with missing "
                + "values. Please run ReplaceMissingValues filter "
                + "on the dataset before passing it on to the KDTree.");
View Full Code Here

      }
     
      // Update weight vector to reflect change a1 and a2, if linear SVM
      if (m_KernelIsLinear) {
  Instance inst1 = m_data.instance(i1);
  for (int p1 = 0; p1 < inst1.numValues(); p1++) {
    if (inst1.index(p1) != m_data.classIndex()) {
      m_weights[inst1.index(p1)] +=
        y1 * (a1 - alph1) * inst1.valueSparse(p1);
    }
  }
View Full Code Here

      m_weights[inst1.index(p1)] +=
        y1 * (a1 - alph1) * inst1.valueSparse(p1);
    }
  }
  Instance inst2 = m_data.instance(i2);
  for (int p2 = 0; p2 < inst2.numValues(); p2++) {
    if (inst2.index(p2) != m_data.classIndex()) {
      m_weights[inst2.index(p2)] +=
        y2 * (a2 - alph2) * inst2.valueSparse(p2);
    }
  }
View Full Code Here

   * @throws Exception   if missing values are encountered
   */
  protected void checkMissing(Instances instances) throws Exception {
    for (int i = 0; i < instances.numInstances(); i++) {
      Instance ins = instances.instance(i);
      for (int j = 0; j < ins.numValues(); j++) {
  if (ins.index(j) != ins.classIndex())
    if (ins.isMissingSparse(j)) {
      throw new Exception("ERROR: KDTree can not deal with missing "
    + "values. Please run ReplaceMissingValues filter "
    + "on the dataset before passing it on to the KDTree.");
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

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.