public void updateRuleAttribStatistics ( Instance inst , RuleClassification rl , int ruleIndex ) { rl . instancesSeen ++ ; if ( rl . squaredAttributeStatisticsSupervised . size ( ) == 0 && rl . attributeStatisticsSupervised . size ( ) == 0 ) { for ( int s = 0 ; s < inst . numAttributes ( ) - 1 ; s ++ ) { ArrayList < Double > temp1 = new ArrayList < Double > ( ) ; ArrayList < Double > temp2 = new ArrayList < Double > ( ) ; rl . attributeStatisticsSupervised . add ( temp1 ) ; rl . squaredAttributeStatisticsSupervised . add ( temp2 ) ; int instAttIndex = modelAttIndexToInstanceAttIndex ( s , inst ) ; if ( instance . attribute ( instAttIndex ) . isNumeric ( ) ) { for ( int i = 0 ; i < inst . numClasses ( ) ; i ++ ) { rl . attributeStatisticsSupervised . get ( s ) . add ( 0.0 ) ; rl . squaredAttributeStatisticsSupervised . get ( s ) . add ( 1.0 ) ; } } } } for ( int s = 0 ; s < inst . numAttributes ( ) - 1 ; s ++ ) { int instAttIndex = modelAttIndexToInstanceAttIndex ( s , inst ) ; if ( ! inst . isMissing ( instAttIndex ) ) { if ( instance . attribute ( instAttIndex ) . isNumeric ( ) ) { rl . attributeStatistics . addToValue ( s , inst . value ( s ) ) ; rl . squaredAttributeStatistics . addToValue ( s , inst . value ( s ) * inst . value ( s ) ) ; double sumValue = rl . attributeStatisticsSupervised . get ( s ) . get ( ( int ) inst . classValue ( ) ) + inst . value ( s ) ; rl . attributeStatisticsSupervised . get ( s ) . set ( ( int ) inst . classValue ( ) , sumValue ) ; double squaredSumvalue = rl . squaredAttributeStatisticsSupervised . get ( s ) . get ( ( int ) inst . classValue ( ) ) + ( inst . value ( s ) * inst . value ( s ) ) ; rl . squaredAttributeStatisticsSupervised . get ( s ) . set ( ( int ) inst . classValue ( ) , squaredSumvalue ) ; } } else { rl . attributeMissingValues . addToValue ( s , 1 ) ; } } }
Update rule statistics