java代码错误可以帮我纠正它 [英] java code errors can you correct it with me

查看:73
本文介绍了java代码错误可以帮我纠正它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生

这里是代码



Dear sir
here is the code

package weka.classifiers.trees.j48;

/**
 * "Abstract" class for computing splitting criteria
 * based on the entropy of a class distribution.
 *
 * @author Eibe Frank (eibe@cs.waikato.ac.nz)
 * @version $Revision$
 */
public abstract class EntropyBasedSplitCrit
  extends SplitCriterion {

  /** for serialization */
  private static final long serialVersionUID = -2618691439791653056L;

  /** The log of 2. */
  protected static double log2 = Math.log(2);

  /**
   * Help method for computing entropy.
   */
  public final double logFunc(double num) {

    // Constant hard coded for efficiency reasons
    if (num < 1e-6)
      return 0;
    else
      return num*Math.log(num)/log2;
  }

  /**
   * Computes entropy of distribution before splitting.
   */
  public final double oldEnt(Distribution bags) {

    double returnValue = 0;
    int j;

    for (j=0;j<bags.numClasses();j++)
      returnValue = returnValue+logFunc(bags.perClass(j));
    return logFunc(bags.total())-returnValue;
  }

  /**
   * Computes entropy of distribution after splitting.
   */
  public final double newEnt(Distribution bags) {

    double returnValue = 0;
    int i,j;

    for (i=0;i<bags.numBags();i++){
      for (j=0;j<bags.numClasses();j++)
    returnValue = returnValue+logFunc(bags.perClassPerBag(i,j));
      returnValue = returnValue-logFunc(bags.perBag(i));
    }
    return -returnValue;
  }

  /**
   * Computes entropy after splitting without considering the
   * class values.
   */
  public final double splitEnt(Distribution bags) {

    double returnValue = 0;
    int i;

    for (i=0;i<bags.numBags();i++)
      returnValue = returnValue + logFunc(bags.perBag(i));
    return logFunc(bags.total())-returnValue;
  }
}





当执行这些错误时出现



and when execute these errors appear

cannot find symbol
cannot find symbol class Distribution
cannot find symbol class Distribution
cannot find symbol class Distribution
operator + cannot be applied to double,<any>
incompatible types
operator + cannot be applied to double,<any>
incompatible types
operator + cannot be applied to double,<any>
incompatible types



你能帮我解决这些问题吗?



提前致谢

Dalia


Can you help me to solve these problems?

Thanks in advance
Dalia

推荐答案

修订


* /
public abstract class EntropyBasedSplitCrit
extends SplitCriterion {

/ * * for序列化* /
私有 静态 final long serialVersionUID = -2618691439791653056L;

/ * *日志2. * /
protected static double log2 = Math.log ( 2 );

/ * *
*计算熵的帮助方法。
* /

public final double logFunc( double num){

// 由于效率原因而进行硬编码
if (num <1e- 6
return 0 ;
else
return num * Math.log(num)/ log2;
}

/ * *
*计算之前的分配熵分裂。
* /

public final double oldEnt(分发袋){

double returnValue = 0 ;
int j;

for (j = 0; j< bags.numClasses(); j ++)
returnValue = returnValue + logFunc(bags。 perClass(J));
return logFunc(bags.total()) - returnValue;
}

/ * *
*计算分配后的熵分裂。
* /

public final double newEnt(分发袋){

double returnValue = 0 ;
int i,j;

for (i = 0; i< bags.numBags(); i ++){
for (j = 0; j< bags.numClasses(); j ++)
returnValue = returnValue + logFunc(bags.perClassPerBag(i,j));
returnValue = returnValue-logFunc(bags.perBag(i));
}
return -returnValue;
}

/ * *
*分割后计算熵考虑
*类值。
* /

public final double splitEnt(分发袋){

double returnValue = 0 ;
int i;

for (i = 0; i< bags.numBags(); i ++)
returnValue = returnValue + logFunc(bags。 perBag(I));
return logFunc(bags.total()) - returnValue;
}
}
*/ public abstract class EntropyBasedSplitCrit extends SplitCriterion { /** for serialization */ private static final long serialVersionUID = -2618691439791653056L; /** The log of 2. */ protected static double log2 = Math.log(2); /** * Help method for computing entropy. */ public final double logFunc(double num) { // Constant hard coded for efficiency reasons if (num < 1e-6) return 0; else return num*Math.log(num)/log2; } /** * Computes entropy of distribution before splitting. */ public final double oldEnt(Distribution bags) { double returnValue = 0; int j; for (j=0;j<bags.numClasses();j++) returnValue = returnValue+logFunc(bags.perClass(j)); return logFunc(bags.total())-returnValue; } /** * Computes entropy of distribution after splitting. */ public final double newEnt(Distribution bags) { double returnValue = 0; int i,j; for (i=0;i<bags.numBags();i++){ for (j=0;j<bags.numClasses();j++) returnValue = returnValue+logFunc(bags.perClassPerBag(i,j)); returnValue = returnValue-logFunc(bags.perBag(i)); } return -returnValue; } /** * Computes entropy after splitting without considering the * class values. */ public final double splitEnt(Distribution bags) { double returnValue = 0; int i; for (i=0;i<bags.numBags();i++) returnValue = returnValue + logFunc(bags.perBag(i)); return logFunc(bags.total())-returnValue; } }





当执行这些错误时出现



and when execute these errors appear

cannot find symbol
cannot find symbol class Distribution
cannot find symbol class Distribution
cannot find symbol class Distribution
operator + cannot be applied to double,<any>
incompatible types
operator + cannot be applied to double,<any>
incompatible types
operator + cannot be applied to double,<any>
incompatible types



你能帮我解决这些问题吗?



提前致谢

Dalia


Can you help me to solve these problems?

Thanks in advance
Dalia


您需要找到 Distribution 的来源并导入它。这段代码需要该类。错误很清楚。我无法看到你离开它的源头所以你需要自己找到它。



祝你好运!
You need to find the source of Distribution and import it. This code needs that class. The error is pretty clear on that. I cannot see where you left the source for it so you need to find it yourself.

Good luck!


这篇关于java代码错误可以帮我纠正它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆