Improve documentation and add a final to MeanResponseCombiner.

This commit is contained in:
Joel Therrien 2019-01-22 11:01:21 -08:00
parent d935fe0bc0
commit 115c57f829

View file

@ -21,16 +21,14 @@ import ca.joeltherrien.randomforest.tree.ResponseCombiner;
import java.util.List;
/**
* This implementation of the collector isn't great... but good enough given that I'm not planning to fully support regression trees.
*
* (It's not great because you'll lose accuracy as you sum up the doubles, since dividing by n is the very last step.)
* Returns the Mean value of a group of Doubles.
*
*/
public class MeanResponseCombiner implements ResponseCombiner<Double, Double> {
@Override
public Double combine(List<Double> responses) {
double size = responses.size();
final double size = responses.size();
return responses.stream().mapToDouble(db -> db/size).sum();