From d85f4eb0990193ba5d0f3658be5bb7c9950b8d23 Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 7 Aug 2018 10:59:19 -0700 Subject: [PATCH] Refactored competing risk combiners and differentiators into their own packages. --- src/main/java/ca/joeltherrien/randomforest/Main.java | 7 +------ src/main/java/ca/joeltherrien/randomforest/Settings.java | 6 ++++++ .../{ => combiner}/CompetingRiskFunctionCombiner.java | 3 ++- .../{ => combiner}/CompetingRiskResponseCombiner.java | 4 +++- .../CompetingRiskGroupDifferentiator.java | 3 ++- .../GrayLogRankMultipleGroupDifferentiator.java | 3 ++- .../GrayLogRankSingleGroupDifferentiator.java | 3 ++- .../LogRankMultipleGroupDifferentiator.java | 3 ++- .../LogRankSingleGroupDifferentiator.java | 3 ++- .../ca/joeltherrien/randomforest/TestSavingLoading.java | 2 +- .../competingrisk/TestCompetingRiskResponseCombiner.java | 3 +-- .../TestLogRankSingleGroupDifferentiator.java | 1 + 12 files changed, 25 insertions(+), 16 deletions(-) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => combiner}/CompetingRiskFunctionCombiner.java (95%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => combiner}/CompetingRiskResponseCombiner.java (95%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => differentiator}/CompetingRiskGroupDifferentiator.java (96%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => differentiator}/GrayLogRankMultipleGroupDifferentiator.java (89%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => differentiator}/GrayLogRankSingleGroupDifferentiator.java (87%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => differentiator}/LogRankMultipleGroupDifferentiator.java (88%) rename src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/{ => differentiator}/LogRankSingleGroupDifferentiator.java (86%) diff --git a/src/main/java/ca/joeltherrien/randomforest/Main.java b/src/main/java/ca/joeltherrien/randomforest/Main.java index c9c8d44..3f211bc 100644 --- a/src/main/java/ca/joeltherrien/randomforest/Main.java +++ b/src/main/java/ca/joeltherrien/randomforest/Main.java @@ -5,6 +5,7 @@ import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.covariates.FactorCovariateSettings; import ca.joeltherrien.randomforest.covariates.NumericCovariateSettings; import ca.joeltherrien.randomforest.responses.competingrisk.*; +import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskFunctionCombiner; import ca.joeltherrien.randomforest.tree.Forest; import ca.joeltherrien.randomforest.tree.ForestTrainer; import ca.joeltherrien.randomforest.utils.MathFunction; @@ -12,15 +13,9 @@ import ca.joeltherrien.randomforest.utils.Utils; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; public class Main { diff --git a/src/main/java/ca/joeltherrien/randomforest/Settings.java b/src/main/java/ca/joeltherrien/randomforest/Settings.java index 74dfb25..f8a24f1 100644 --- a/src/main/java/ca/joeltherrien/randomforest/Settings.java +++ b/src/main/java/ca/joeltherrien/randomforest/Settings.java @@ -2,6 +2,12 @@ package ca.joeltherrien.randomforest; import ca.joeltherrien.randomforest.covariates.CovariateSettings; import ca.joeltherrien.randomforest.responses.competingrisk.*; +import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskFunctionCombiner; +import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskResponseCombiner; +import ca.joeltherrien.randomforest.responses.competingrisk.differentiator.GrayLogRankMultipleGroupDifferentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.differentiator.GrayLogRankSingleGroupDifferentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.differentiator.LogRankMultipleGroupDifferentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.differentiator.LogRankSingleGroupDifferentiator; import ca.joeltherrien.randomforest.responses.regression.MeanGroupDifferentiator; import ca.joeltherrien.randomforest.responses.regression.MeanResponseCombiner; import ca.joeltherrien.randomforest.responses.regression.WeightedVarianceGroupDifferentiator; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctionCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java similarity index 95% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctionCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java index 4a04c79..8da1d91 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctionCombiner.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.combiner; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctions; import ca.joeltherrien.randomforest.tree.ResponseCombiner; import ca.joeltherrien.randomforest.utils.MathFunction; import ca.joeltherrien.randomforest.utils.Point; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java similarity index 95% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java index 761cbae..0f4a1ac 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseCombiner.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java @@ -1,5 +1,7 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.combiner; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctions; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; import ca.joeltherrien.randomforest.tree.ResponseCombiner; import ca.joeltherrien.randomforest.utils.MathFunction; import ca.joeltherrien.randomforest.utils.Point; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGroupDifferentiator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/CompetingRiskGroupDifferentiator.java similarity index 96% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGroupDifferentiator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/CompetingRiskGroupDifferentiator.java index 35ff237..9ba380b 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGroupDifferentiator.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/CompetingRiskGroupDifferentiator.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.differentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; import ca.joeltherrien.randomforest.tree.GroupDifferentiator; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankMultipleGroupDifferentiator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankMultipleGroupDifferentiator.java similarity index 89% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankMultipleGroupDifferentiator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankMultipleGroupDifferentiator.java index dc3df9b..d993348 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankMultipleGroupDifferentiator.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankMultipleGroupDifferentiator.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.differentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponseWithCensorTime; import lombok.RequiredArgsConstructor; import java.util.List; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankSingleGroupDifferentiator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankSingleGroupDifferentiator.java similarity index 87% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankSingleGroupDifferentiator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankSingleGroupDifferentiator.java index 7ce5d76..7a8d7f9 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/GrayLogRankSingleGroupDifferentiator.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/GrayLogRankSingleGroupDifferentiator.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.differentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponseWithCensorTime; import lombok.RequiredArgsConstructor; import java.util.List; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankMultipleGroupDifferentiator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankMultipleGroupDifferentiator.java similarity index 88% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankMultipleGroupDifferentiator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankMultipleGroupDifferentiator.java index 64404b9..7a62e86 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankMultipleGroupDifferentiator.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankMultipleGroupDifferentiator.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.differentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; import lombok.RequiredArgsConstructor; import java.util.List; diff --git a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankSingleGroupDifferentiator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankSingleGroupDifferentiator.java similarity index 86% rename from src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankSingleGroupDifferentiator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankSingleGroupDifferentiator.java index 26405a5..06cb6bd 100644 --- a/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/LogRankSingleGroupDifferentiator.java +++ b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/differentiator/LogRankSingleGroupDifferentiator.java @@ -1,5 +1,6 @@ -package ca.joeltherrien.randomforest.responses.competingrisk; +package ca.joeltherrien.randomforest.responses.competingrisk.differentiator; +import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; import lombok.RequiredArgsConstructor; import java.util.List; diff --git a/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java b/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java index 71a6ff8..c544b37 100644 --- a/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java +++ b/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java @@ -3,7 +3,7 @@ package ca.joeltherrien.randomforest; import ca.joeltherrien.randomforest.covariates.BooleanCovariateSettings; import ca.joeltherrien.randomforest.covariates.Covariate; import ca.joeltherrien.randomforest.covariates.NumericCovariateSettings; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctionCombiner; +import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskFunctionCombiner; import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctions; import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; import ca.joeltherrien.randomforest.tree.Forest; diff --git a/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java index ce18106..24cfaae 100644 --- a/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java +++ b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java @@ -2,12 +2,11 @@ package ca.joeltherrien.randomforest.competingrisk; import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctions; import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponseCombiner; +import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskResponseCombiner; import ca.joeltherrien.randomforest.utils.MathFunction; import org.junit.jupiter.api.Test; import static ca.joeltherrien.randomforest.TestUtils.closeEnough; -import static org.junit.jupiter.api.Assertions.*; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.java index c8e7090..56e668b 100644 --- a/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.java +++ b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.java @@ -1,6 +1,7 @@ package ca.joeltherrien.randomforest.competingrisk; import ca.joeltherrien.randomforest.responses.competingrisk.*; +import ca.joeltherrien.randomforest.responses.competingrisk.differentiator.LogRankSingleGroupDifferentiator; import org.junit.jupiter.api.Test; import java.util.ArrayList;