public void findBestValEntropy(Node node, DoubleVector classCountL, DoubleVector classCountR,
			boolean status, double minEntropy, DoubleVector parentCCLeft ){
		if (this.root != null) {
			if (node != null) {
				int numClass=0;
				DoubleVector classCountLTemp = new DoubleVector(); 
				DoubleVector classCountRTemp = new DoubleVector(); 
				DoubleVector parentCCL = new DoubleVector();
				DoubleVector parentCCLParameter = new DoubleVector();
				for (int f = 0; f < node.classCountsLeft.numValues(); f++) {
					parentCCLParameter.setValue(f, node.classCountsLeft.getValue(f));
					}
				for (int p = 0; p < parentCCLeft.numValues(); p++) {
					parentCCL.addToValue(p, parentCCLeft.getValue(p));
					}
				if (classCountL.numValues() >= classCountR.numValues()) {
					numClass = classCountL.numValues();
				} else {
					numClass = classCountR.numValues();
				}
				// Counting the real class count left and the real class count right.
				if (node.cut_point != this.root.cut_point) {
					for (int i = 0; i < numClass; i++) {
						if (status == true) {		// Left node.
							double parentss = parentCCL.getValue(i) - (node.classCountsLeft.getValue(i) 
									+ node.classCountsRight.getValue(i));
						    double left = classCountL.getValue(i) 
						    		- node.classCountsRight.getValue(i) - parentss;
						    double right = classCountR.getValue(i) 
						    		+ node.classCountsRight.getValue(i) + parentss;
						    classCountLTemp.addToValue(i, left);
					        classCountRTemp.addToValue(i, right);
					        }
						if (status == false) {		// Right node.
							double left = classCountL.getValue(i)+ node.classCountsLeft.getValue(i);
							double right = classCountR.getValue(i)- node.classCountsLeft.getValue(i);
							classCountLTemp.addToValue(i, left);
							classCountRTemp.addToValue(i, right);
							}
						}
					} else {
						classCountLTemp = classCountL;
						classCountRTemp = classCountR;
						}
				double classCountLSum = classCountLTemp.sumOfValues();
				double classCountRSum = classCountRTemp.sumOfValues();
				double numInst = this.root.classCountsLeft.sumOfValues() + this.root.classCountsRight.sumOfValues();
				// The entropy value for all nodes except for the root.
				if ((classCountLSum > this.PminOption.getValue()*numInst) 
						&& (classCountRSum > this.PminOption.getValue() * numInst)) {
					double classCountLEntropy = entropy( classCountLTemp);   // Entropy of class count left.
					double classCountREntropy = entropy(classCountRTemp);    // Entropy of class count right
					if (((classCountLSum / numInst) * classCountLEntropy + (classCountRSum / numInst)* classCountREntropy) <= minEntropy) {
						this.minEntropyTemp = (classCountLSum / numInst) * classCountLEntropy 
								+ (classCountRSum / numInst) * classCountREntropy;
						this.cutPointTemp = node.cut_point;
						if (classCountLEntropy <= classCountREntropy) {
							this.symbol = -1.0;
							double value = 0.0;
							double index = 0.0;
							for (int h = 0; h < numClass; h++) {
								if (value <= classCountLTemp.getValue(h)) {
									value = classCountLTemp.getValue(h);
					    			index = (double)h;
					    			}
								}
							this.saveBestEntropy.setValue(0, this.cutPointTemp);
							this.saveBestEntropy.setValue(1, classCountLEntropy);
							this.saveBestEntropy.setValue(2, this.symbol);
							this.saveBestEntropy.setValue(4, index);
					    	} else {
					    		this.symbol = 1.0;
					    		double value = 0.0;
					    		double index = 0.0;
					    		for (int h = 0; h < numClass; h++) {
					    			if (value <= classCountRTemp.getValue(h)) {
					    				value = classCountRTemp.getValue(h);
					    				index = (double)h;
					    				}
					    			}
					    		this.saveBestEntropy.setValue(0, this.cutPointTemp);
					    		this.saveBestEntropy.setValue(1, classCountREntropy);
					    		this.saveBestEntropy.setValue(2, this.symbol);
					    		this.saveBestEntropy.setValue(4, index);
						    	}
						}
					}
				findBestValEntropy(node.left ,classCountLTemp , classCountRTemp,
						true, this.minEntropyTemp, parentCCLParameter);
				findBestValEntropy(node.right ,classCountLTemp , classCountRTemp,
						false, this.minEntropyTemp, parentCCLParameter);
				}
			}
		}
public void findBestValEntropy ( Node node , DoubleVector classCountL , DoubleVector classCountR , boolean status , double minEntropy , DoubleVector parentCCLeft ) { if ( this . root != null ) { if ( node != null ) { int numClass = 0 ; DoubleVector classCountLTemp = new DoubleVector ( ) ; DoubleVector classCountRTemp = new DoubleVector ( ) ; DoubleVector parentCCL = new DoubleVector ( ) ; DoubleVector parentCCLParameter = new DoubleVector ( ) ; for ( int f = 0 ; f < node . classCountsLeft . numValues ( ) ; f ++ ) { parentCCLParameter . setValue ( f , node . classCountsLeft . getValue ( f ) ) ; } for ( int p = 0 ; p < parentCCLeft . numValues ( ) ; p ++ ) { parentCCL . addToValue ( p , parentCCLeft . getValue ( p ) ) ; } if ( classCountL . numValues ( ) >= classCountR . numValues ( ) ) { numClass = classCountL . numValues ( ) ; } else { numClass = classCountR . numValues ( ) ; } if ( node . cut_point != this . root . cut_point ) { for ( int i = 0 ; i < numClass ; i ++ ) { if ( status == true ) { double parentss = parentCCL . getValue ( i ) - ( node . classCountsLeft . getValue ( i ) + node . classCountsRight . getValue ( i ) ) ; double left = classCountL . getValue ( i ) - node . classCountsRight . getValue ( i ) - parentss ; double right = classCountR . getValue ( i ) + node . classCountsRight . getValue ( i ) + parentss ; classCountLTemp . addToValue ( i , left ) ; classCountRTemp . addToValue ( i , right ) ; } if ( status == false ) { double left = classCountL . getValue ( i ) + node . classCountsLeft . getValue ( i ) ; double right = classCountR . getValue ( i ) - node . classCountsLeft . getValue ( i ) ; classCountLTemp . addToValue ( i , left ) ; classCountRTemp . addToValue ( i , right ) ; } } } else { classCountLTemp = classCountL ; classCountRTemp = classCountR ; } double classCountLSum = classCountLTemp . sumOfValues ( ) ; double classCountRSum = classCountRTemp . sumOfValues ( ) ; double numInst = this . root . classCountsLeft . sumOfValues ( ) + this . root . classCountsRight . sumOfValues ( ) ; if ( ( classCountLSum > this . PminOption . getValue ( ) * numInst ) && ( classCountRSum > this . PminOption . getValue ( ) * numInst ) ) { double classCountLEntropy = entropy ( classCountLTemp ) ; double classCountREntropy = entropy ( classCountRTemp ) ; if ( ( ( classCountLSum / numInst ) * classCountLEntropy + ( classCountRSum / numInst ) * classCountREntropy ) <= minEntropy ) { this . minEntropyTemp = ( classCountLSum / numInst ) * classCountLEntropy + ( classCountRSum / numInst ) * classCountREntropy ; this . cutPointTemp = node . cut_point ; if ( classCountLEntropy <= classCountREntropy ) { this . symbol = - 1.0 ; double value = 0.0 ; double index = 0.0 ; for ( int h = 0 ; h < numClass ; h ++ ) { if ( value <= classCountLTemp . getValue ( h ) ) { value = classCountLTemp . getValue ( h ) ; index = ( double ) h ; } } this . saveBestEntropy . setValue ( 0 , this . cutPointTemp ) ; this . saveBestEntropy . setValue ( 1 , classCountLEntropy ) ; this . saveBestEntropy . setValue ( 2 , this . symbol ) ; this . saveBestEntropy . setValue ( 4 , index ) ; } else { this . symbol = 1.0 ; double value = 0.0 ; double index = 0.0 ; for ( int h = 0 ; h < numClass ; h ++ ) { if ( value <= classCountRTemp . getValue ( h ) ) { value = classCountRTemp . getValue ( h ) ; index = ( double ) h ; } } this . saveBestEntropy . setValue ( 0 , this . cutPointTemp ) ; this . saveBestEntropy . setValue ( 1 , classCountREntropy ) ; this . saveBestEntropy . setValue ( 2 , this . symbol ) ; this . saveBestEntropy . setValue ( 4 , index ) ; } } } findBestValEntropy ( node . left , classCountLTemp , classCountRTemp , true , this . minEntropyTemp , parentCCLParameter ) ; findBestValEntropy ( node . right , classCountLTemp , classCountRTemp , false , this . minEntropyTemp , parentCCLParameter ) ; } } }
Get the best value of entropy and its cutPoint for a numeric attribute