public void findBestValEntropyNominalAtt ( AutoExpandVector < DoubleVector > attrib , int attNumValues ) { ArrayList < ArrayList < Double >> distClassValue = new ArrayList < ArrayList < Double > > ( ) ; // System.out.print("attrib"+attrib+"\n"); for ( int z = 0 ; z < attrib . size ( ) ; z ++ ) { distClassValue . add ( new ArrayList < Double > ( ) ) ; } for ( int v = 0 ; v < attNumValues ; v ++ ) { DoubleVector saveVal = new DoubleVector ( ) ; for ( int z = 0 ; z < attrib . size ( ) ; z ++ ) { if ( attrib . get ( z ) != null ) { distClassValue . get ( z ) . add ( attrib . get ( z ) . getValue ( v ) ) ; } else { distClassValue . get ( z ) . add ( 0.0 ) ; } if ( distClassValue . get ( z ) . get ( v ) . isNaN ( ) ) { distClassValue . get ( z ) . add ( 0.0 ) ; } saveVal . setValue ( z , distClassValue . get ( z ) . get ( v ) ) ; } double sumValue = saveVal . sumOfValues ( ) ; if ( sumValue > 0.0 ) { double entropyVal = entropy ( saveVal ) ; if ( entropyVal <= this . minEntropyNominalAttrib ) { this . minEntropyNominalAttrib = entropyVal ; this . saveBestEntropyNominalAttrib . setValue ( 0 , v ) ; this . saveBestEntropyNominalAttrib . setValue ( 1 , entropyVal ) ; this . saveBestEntropyNominalAttrib . setValue ( 2 , 0.0 ) ; } } } }
Find best value of entropy for nominal attributes