Examples of valueSparse()


Examples of weka.core.Instance.valueSparse()

      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);
    }
  }
  Instance inst2 = m_data.instance(i2);
  for (int p2 = 0; p2 < inst2.numValues(); p2++) {
    if (inst2.index(p2) != m_data.classIndex()) {
View Full Code Here

Examples of weka.core.Instance.valueSparse()

  }
  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);
    }
  }
      }
     
      // Update error cache using new Lagrange multipliers
View Full Code Here

Examples of weka.core.Instance.valueSparse()

  for(int a = 0; a<instance.numValues(); a++)
    if(instance.index(a) != instance.classIndex())
      {
        if(!instance.isMissing(a))
    {
      numOccurences = instance.valueSparse(a) * instance.weight();
      if(numOccurences < 0)
        throw new Exception("Numeric attribute values must all be greater or equal to zero.");
      wordsPerClass[classIndex] += numOccurences;
      m_probOfWordGivenClass[classIndex][instance.index(a)] += numOccurences;
    }
View Full Code Here

Examples of weka.core.Instance.valueSparse()

    //docsPerClass[docClass] += instance.weight();
   
    for(int a = 0; a<instance.numValues(); a++)
        if(instance.index(a) != instance.classIndex()) {
          if(!instance.isMissing(a)) {
            numOccurrences = instance.valueSparse(a) * instance.weight();
            if(numOccurrences < 0)
          throw new Exception("Numeric attribute"+
                                                  " values must all be greater"+
                                                  " or equal to zero.");
                                    totalWordOccurrences += numOccurrences;
View Full Code Here

Examples of weka.core.Instance.valueSparse()

  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);
  }
  m_AvgDocLength /= m_NumInstances;
View Full Code Here

Examples of weka.core.Instance.valueSparse()

  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);
  }
  m_AvgDocLength /= m_NumInstances;
View Full Code Here

Examples of weka.core.Instance.valueSparse()

      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();
      } else if (inst.attributeSparse(i).isNumeric()) {
        results[inst.index(i)] += inst.weight() * inst.valueSparse(i);
 
View Full Code Here

Examples of weka.core.Instance.valueSparse()

      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();
      } else if (inst.attributeSparse(i).isNumeric()) {
        results[inst.index(i)] += inst.weight() * inst.valueSparse(i);
      }
    } else {
      if (inst.attributeSparse(i).isNominal()) {
        counts[inst.index(i)][0] -= inst.weight();
      } else if (inst.attributeSparse(i).isNumeric()) {
View Full Code Here

Examples of weka.core.Instance.valueSparse()

    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);
      }
    }
    for(int j=0; j<list2.length(); j++) {
      temp = insts.instance(((ListNode)list2.get(j)).idx);
      for(int k=0; k<temp.numValues(); k++) {
View Full Code Here

Examples of weka.core.Instance.valueSparse()

    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);
      }
    }
    for(int j=0, numInsts=list1.length()+list2.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.