Package weka.core

Examples of weka.core.Instance.index()


                                          [instance.index(a)] += numOccurrences;
                                    //For the time being wordweights[0][i]
                                    //will hold the total occurrence of word
                                    // i over all classes
                                    wordWeights[0]
                                          [instance.index(a)] += numOccurrences;
                            }
                    }
        }

  //Calculating the complement class probability for all classes except 0       
View Full Code Here


  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();
                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

  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();
                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

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

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

      } else if (inst.attributeSparse(i).isNumeric()) {
        results[inst.index(i)] += inst.weight() * inst.valueSparse(i);
      }
    } else {
      if (inst.attributeSparse(i).isNominal()) {
              if (counts[inst.index(i)].length > 0) {
          counts[inst.index(i)][0] -= inst.weight();
              }
      } else if (inst.attributeSparse(i).isNumeric()) {
        sums[inst.index(i)] -= inst.weight();
      }
View Full Code Here

        results[inst.index(i)] += inst.weight() * inst.valueSparse(i);
      }
    } else {
      if (inst.attributeSparse(i).isNominal()) {
              if (counts[inst.index(i)].length > 0) {
          counts[inst.index(i)][0] -= inst.weight();
              }
      } else if (inst.attributeSparse(i).isNumeric()) {
        sums[inst.index(i)] -= inst.weight();
      }
    }
View Full Code Here

      if (inst.attributeSparse(i).isNominal()) {
              if (counts[inst.index(i)].length > 0) {
          counts[inst.index(i)][0] -= inst.weight();
              }
      } else if (inst.attributeSparse(i).isNumeric()) {
        sums[inst.index(i)] -= inst.weight();
      }
    }
  }
      }
      m_ModesAndMeans = new double[getInputFormat().numAttributes()];
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();
      if(numOccurences < 0)
View Full Code Here

    {
      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

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.