Change Forest to keep trees in a List instead of a Collection

This commit is contained in:
Joel Therrien 2019-03-27 10:57:01 -07:00
parent 585d6d3c5b
commit 526a127b9d

View file

@ -20,13 +20,16 @@ import ca.joeltherrien.randomforest.CovariateRow;
import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.covariates.Covariate;
import lombok.Builder; import lombok.Builder;
import java.util.*; import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Builder @Builder
public class Forest<O, FO> { // O = output of trees, FO = forest output. In practice O == FO, even in competing risk & survival settings public class Forest<O, FO> { // O = output of trees, FO = forest output. In practice O == FO, even in competing risk & survival settings
private final Collection<Tree<O>> trees; private final List<Tree<O>> trees;
private final ResponseCombiner<O, FO> treeResponseCombiner; private final ResponseCombiner<O, FO> treeResponseCombiner;
private final List<Covariate> covariateList; private final List<Covariate> covariateList;
@ -63,8 +66,8 @@ public class Forest<O, FO> { // O = output of trees, FO = forest output. In prac
} }
public Collection<Tree<O>> getTrees(){ public List<Tree<O>> getTrees(){
return Collections.unmodifiableCollection(trees); return Collections.unmodifiableList(trees);
} }
public Map<Integer, Integer> findSplitsByCovariate(){ public Map<Integer, Integer> findSplitsByCovariate(){