Package weka.core

Examples of weka.core.Instance.numValues()


   */
  private Matrix getTransposedMatrix(Instances data) {
    double[][] temp = new double[data.numAttributes()][data.numInstances()];
    for (int i = 0; i < data.numInstances(); i++) {
      Instance inst = data.instance(i);
      for (int v = 0; v < inst.numValues(); v++) {
  temp[inst.index(v)][i] = inst.valueSparse(v);
      }
    }
    Matrix My_x = new Matrix(temp);
    return My_x;
View Full Code Here


    input.Hy = Entropy(input.Py);
   
    double entropy = input.Hx + input.Hy;   
    for (int i=0; i < m_numInstances; i++) {
      Instance inst = m_data.instance(i);
      for (int v = 0; v < inst.numValues(); v++) {
  double tmp = m.get(inst.index(v), i);
  if(tmp <= 0) continue;
  entropy += tmp * Math.log(tmp);
      }
    }
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

   * @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

   * @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

      System.out.format("Warning: zero or negative weights in JS calculation! (pi1 %s, pi2 %s)\n", pi1, pi2);
      return 0;
    }
    Instance inst = m_data.instance(instIdx);
    double kl1 = 0.0, kl2 = 0.0, tmp = 0.0;   
    for (int i = 0; i < inst.numValues(); i++) {
      tmp = input.Py_x.get(inst.index(i), instIdx);     
      if(tmp != 0) {
  kl1 += tmp * Math.log(tmp / (tmp * pi1 + pi2 * T.Py_t.get(inst.index(i), t)));
      }
    }
View Full Code Here

   */
  private Matrix getTransposedMatrix(Instances data) {
    double[][] temp = new double[data.numAttributes()][data.numInstances()];
    for (int i = 0; i < data.numInstances(); i++) {
      Instance inst = data.instance(i);
      for (int v = 0; v < inst.numValues(); v++) {
  temp[inst.index(v)][i] = inst.valueSparse(v);
      }
    }
    Matrix My_x = new Matrix(temp);
    return My_x;
View Full Code Here

    input.Hy = Entropy(input.Py);
   
    double entropy = input.Hx + input.Hy;   
    for (int i=0; i < m_numInstances; i++) {
      Instance inst = m_data.instance(i);
      for (int v = 0; v < inst.numValues(); v++) {
  double tmp = m.get(inst.index(v), i);
  if(tmp <= 0) continue;
  entropy += tmp * Math.log(tmp);
      }
    }
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

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.