Improve documentation and add a final
to MeanResponseCombiner.
This commit is contained in:
parent
d935fe0bc0
commit
115c57f829
1 changed files with 2 additions and 4 deletions
|
@ -21,16 +21,14 @@ import ca.joeltherrien.randomforest.tree.ResponseCombiner;
|
||||||
import java.util.List;
|
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.
|
* Returns the Mean value of a group of Doubles.
|
||||||
*
|
|
||||||
* (It's not great because you'll lose accuracy as you sum up the doubles, since dividing by n is the very last step.)
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MeanResponseCombiner implements ResponseCombiner<Double, Double> {
|
public class MeanResponseCombiner implements ResponseCombiner<Double, Double> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Double combine(List<Double> responses) {
|
public Double combine(List<Double> responses) {
|
||||||
double size = responses.size();
|
final double size = responses.size();
|
||||||
|
|
||||||
return responses.stream().mapToDouble(db -> db/size).sum();
|
return responses.stream().mapToDouble(db -> db/size).sum();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue