Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir
here is the code

Java
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

Can you help me to solve these problems?

Thanks in advance
Dalia
Posted
Updated 5-May-13 23:34pm
v3
Comments
TorstenH. 6-May-13 5:36am    
Debug it. that code only makes sense in the context.
Debugging with Eclipse
NEtbeans Debugger
H.Brydon 11-May-13 1:06am    
You should really edit the question and remove your email address from the comments. Spammers will find this info and spam you into oblivion.

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900