A program to recognize and reward our most engaged community members
double precision=0.0;Iterator<Attribute> attributeIterator; // the iterator for all attributesIterator<Example> exampleIterator; // the iterator for all examples// save the text vector into arraydouble text_array[][] = new double [num_exp][num_att-2];exampleIterator = exampleSet.iterator(); // move the iterator to the beginingfor(int i=0; i<num_exp; i++){ Example example = exampleIterator.next(); // read one example attributeIterator = attributes.allAttributes(); // build the iterator for the attributes for(int j=0; j<num_att-2; j++) // read all the attributes except that last two { Attribute att = attributeIterator.next(); text_array = example.getValue(att); // read the TF-IDF value into array }}// adjust TF-IDF with weightsdouble fWeight = 0;for(int i=0; i<20; i++){ exampleIterator = exampleSet.iterator(); // move the iterator to the beginning for(int i2=0; i2<num_exp; i2++) { Example example = exampleIterator.next(); attributeIterator = attributes.allAttributes(); for(int j=0; j<num_att-2; j++) { Attribute att = attributeIterator.next(); double val = text_array[i2] * fWeight; // adjust the TF-IDF by weight example.setValue(att, val); // save the adjusted TF-IDF into the ExampleSet } } precision = my_validate_classiciation(); // do classification by naive bayes based on the adjusted TF-IDF System.out.println("(" + fWeight + "): " + precision + " "); fWeight += 0.05; // increase the weight fWeight = roundTwoDecimals(fWeight); // keep two places behind the decimal point}
(weight): precision(0.0): 0.0 (0.05): 0.3875 (0.1): 0.3125 (0.15): 0.3125 (0.2): 0.3125 (0.25): 0.2875 (0.3): 0.275 (0.35): 0.2625 (0.4): 0.2625 (0.45): 0.2625 (0.5): 0.25 (0.55): 0.25 (0.6): 0.25 (0.65): 0.2375 (0.7): 0.2375 (0.75): 0.2375 (0.8): 0.2375 (0.85): 0.2375 (0.9): 0.2375 (0.95): 0.2375 (1.0): 0.2375