From 2cdcbe6cbf649b42e31a9631c82dd55e933539b6 Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Thu, 5 Jul 2018 12:59:29 -0700 Subject: [PATCH] Refactor different classes into subpackages. --- .../java/ca/joeltherrien/randomforest/CovariateRow.java | 1 + src/main/java/ca/joeltherrien/randomforest/Row.java | 2 ++ .../randomforest/{ => covariates}/BooleanCovariate.java | 2 +- .../randomforest/{ => covariates}/Covariate.java | 6 +++++- .../randomforest/{ => covariates}/FactorCovariate.java | 2 +- .../randomforest/{ => covariates}/NumericCovariate.java | 2 +- .../randomforest/regression/MeanResponseCombiner.java | 2 +- src/main/java/ca/joeltherrien/randomforest/tree/Forest.java | 2 -- .../ca/joeltherrien/randomforest/tree/ForestTrainer.java | 3 +-- .../randomforest/{ => tree}/ResponseCombiner.java | 2 +- .../java/ca/joeltherrien/randomforest/{ => tree}/Split.java | 3 ++- .../java/ca/joeltherrien/randomforest/tree/SplitNode.java | 2 +- .../java/ca/joeltherrien/randomforest/tree/TreeTrainer.java | 1 + .../randomforest/covariates/FactorCovariateTest.java | 1 - .../ca/joeltherrien/randomforest/workshop/TrainForest.java | 5 ++--- .../joeltherrien/randomforest/workshop/TrainSingleTree.java | 4 ++-- .../randomforest/workshop/TrainSingleTreeFactor.java | 4 +++- 17 files changed, 25 insertions(+), 19 deletions(-) rename src/main/java/ca/joeltherrien/randomforest/{ => covariates}/BooleanCovariate.java (97%) rename src/main/java/ca/joeltherrien/randomforest/{ => covariates}/Covariate.java (93%) rename src/main/java/ca/joeltherrien/randomforest/{ => covariates}/FactorCovariate.java (98%) rename src/main/java/ca/joeltherrien/randomforest/{ => covariates}/NumericCovariate.java (98%) rename src/main/java/ca/joeltherrien/randomforest/{ => tree}/ResponseCombiner.java (79%) rename src/main/java/ca/joeltherrien/randomforest/{ => tree}/Split.java (75%) diff --git a/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java b/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java index 181d80b..5802da1 100644 --- a/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java +++ b/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java @@ -1,5 +1,6 @@ package ca.joeltherrien.randomforest; +import ca.joeltherrien.randomforest.covariates.Covariate; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/ca/joeltherrien/randomforest/Row.java b/src/main/java/ca/joeltherrien/randomforest/Row.java index b762f15..ef263bf 100644 --- a/src/main/java/ca/joeltherrien/randomforest/Row.java +++ b/src/main/java/ca/joeltherrien/randomforest/Row.java @@ -1,6 +1,8 @@ package ca.joeltherrien.randomforest; +import ca.joeltherrien.randomforest.covariates.Covariate; + import java.util.Map; public class Row extends CovariateRow { diff --git a/src/main/java/ca/joeltherrien/randomforest/BooleanCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/BooleanCovariate.java similarity index 97% rename from src/main/java/ca/joeltherrien/randomforest/BooleanCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/BooleanCovariate.java index 6e0743f..b57df47 100644 --- a/src/main/java/ca/joeltherrien/randomforest/BooleanCovariate.java +++ b/src/main/java/ca/joeltherrien/randomforest/covariates/BooleanCovariate.java @@ -1,4 +1,4 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.covariates; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/ca/joeltherrien/randomforest/Covariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java similarity index 93% rename from src/main/java/ca/joeltherrien/randomforest/Covariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java index 0cf40c8..75bc672 100644 --- a/src/main/java/ca/joeltherrien/randomforest/Covariate.java +++ b/src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java @@ -1,4 +1,8 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.covariates; + +import ca.joeltherrien.randomforest.CovariateRow; +import ca.joeltherrien.randomforest.Row; +import ca.joeltherrien.randomforest.tree.Split; import java.io.Serializable; import java.util.*; diff --git a/src/main/java/ca/joeltherrien/randomforest/FactorCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/FactorCovariate.java similarity index 98% rename from src/main/java/ca/joeltherrien/randomforest/FactorCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/FactorCovariate.java index ed4c4e9..cf48933 100644 --- a/src/main/java/ca/joeltherrien/randomforest/FactorCovariate.java +++ b/src/main/java/ca/joeltherrien/randomforest/covariates/FactorCovariate.java @@ -1,4 +1,4 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.covariates; import lombok.EqualsAndHashCode; diff --git a/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/NumericCovariate.java similarity index 98% rename from src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/NumericCovariate.java index 014bbfc..155beee 100644 --- a/src/main/java/ca/joeltherrien/randomforest/NumericCovariate.java +++ b/src/main/java/ca/joeltherrien/randomforest/covariates/NumericCovariate.java @@ -1,4 +1,4 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.covariates; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/ca/joeltherrien/randomforest/regression/MeanResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/regression/MeanResponseCombiner.java index 4923a32..57a3b35 100644 --- a/src/main/java/ca/joeltherrien/randomforest/regression/MeanResponseCombiner.java +++ b/src/main/java/ca/joeltherrien/randomforest/regression/MeanResponseCombiner.java @@ -1,6 +1,6 @@ package ca.joeltherrien.randomforest.regression; -import ca.joeltherrien.randomforest.ResponseCombiner; +import ca.joeltherrien.randomforest.tree.ResponseCombiner; import java.util.List; import java.util.Set; diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java b/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java index 30e222b..427d7ab 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java @@ -1,11 +1,9 @@ package ca.joeltherrien.randomforest.tree; import ca.joeltherrien.randomforest.CovariateRow; -import ca.joeltherrien.randomforest.ResponseCombiner; import lombok.Builder; import java.util.Collection; -import java.util.List; @Builder public class Forest { diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java index bae9f9f..76d4a70 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java @@ -1,8 +1,7 @@ package ca.joeltherrien.randomforest.tree; import ca.joeltherrien.randomforest.Bootstrapper; -import ca.joeltherrien.randomforest.Covariate; -import ca.joeltherrien.randomforest.ResponseCombiner; +import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.Row; import lombok.Builder; diff --git a/src/main/java/ca/joeltherrien/randomforest/ResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java similarity index 79% rename from src/main/java/ca/joeltherrien/randomforest/ResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java index e418fdd..bbcdd30 100644 --- a/src/main/java/ca/joeltherrien/randomforest/ResponseCombiner.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java @@ -1,4 +1,4 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.tree; import java.util.List; import java.util.stream.Collector; diff --git a/src/main/java/ca/joeltherrien/randomforest/Split.java b/src/main/java/ca/joeltherrien/randomforest/tree/Split.java similarity index 75% rename from src/main/java/ca/joeltherrien/randomforest/Split.java rename to src/main/java/ca/joeltherrien/randomforest/tree/Split.java index 9804804..eb90273 100644 --- a/src/main/java/ca/joeltherrien/randomforest/Split.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/Split.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest; +package ca.joeltherrien.randomforest.tree; +import ca.joeltherrien.randomforest.Row; import lombok.Data; import java.util.List; diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java b/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java index 3f5dfdb..c00249a 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java @@ -1,6 +1,6 @@ package ca.joeltherrien.randomforest.tree; -import ca.joeltherrien.randomforest.Covariate; +import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.CovariateRow; import lombok.Builder; diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java index 94a1dad..fd83382 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java @@ -1,6 +1,7 @@ package ca.joeltherrien.randomforest.tree; import ca.joeltherrien.randomforest.*; +import ca.joeltherrien.randomforest.covariates.Covariate; import lombok.Builder; import java.util.*; diff --git a/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java b/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java index 1a22ce9..4f00c6d 100644 --- a/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java +++ b/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java @@ -1,7 +1,6 @@ package ca.joeltherrien.randomforest.covariates; -import ca.joeltherrien.randomforest.FactorCovariate; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; diff --git a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java index 003256c..00ba886 100644 --- a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java +++ b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java @@ -1,15 +1,14 @@ package ca.joeltherrien.randomforest.workshop; import ca.joeltherrien.randomforest.*; +import ca.joeltherrien.randomforest.covariates.Covariate; +import ca.joeltherrien.randomforest.covariates.NumericCovariate; import ca.joeltherrien.randomforest.regression.MeanResponseCombiner; import ca.joeltherrien.randomforest.regression.WeightedVarianceGroupDifferentiator; -import ca.joeltherrien.randomforest.tree.Forest; import ca.joeltherrien.randomforest.tree.ForestTrainer; import ca.joeltherrien.randomforest.tree.TreeTrainer; import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.IntStream; public class TrainForest { diff --git a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java index 72654a8..6e5dd55 100644 --- a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java +++ b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java @@ -1,9 +1,9 @@ package ca.joeltherrien.randomforest.workshop; -import ca.joeltherrien.randomforest.Covariate; +import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.CovariateRow; -import ca.joeltherrien.randomforest.NumericCovariate; +import ca.joeltherrien.randomforest.covariates.NumericCovariate; import ca.joeltherrien.randomforest.Row; import ca.joeltherrien.randomforest.regression.MeanResponseCombiner; import ca.joeltherrien.randomforest.regression.WeightedVarianceGroupDifferentiator; diff --git a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java index e63f8cd..665675c 100644 --- a/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java +++ b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java @@ -2,6 +2,9 @@ package ca.joeltherrien.randomforest.workshop; import ca.joeltherrien.randomforest.*; +import ca.joeltherrien.randomforest.covariates.Covariate; +import ca.joeltherrien.randomforest.covariates.FactorCovariate; +import ca.joeltherrien.randomforest.covariates.NumericCovariate; import ca.joeltherrien.randomforest.regression.MeanResponseCombiner; import ca.joeltherrien.randomforest.regression.WeightedVarianceGroupDifferentiator; import ca.joeltherrien.randomforest.tree.Node; @@ -13,7 +16,6 @@ import java.util.Map; import java.util.Random; import java.util.stream.Collectors; import java.util.stream.DoubleStream; -import java.util.stream.Stream; public class TrainSingleTreeFactor {