diff --git a/README.md b/README.md index e20fa89..6546a45 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,18 @@ # README -This repository contains two Java projects; +This repository contains the largeRCRF Java library, containing all of the logic used for training the random forests. This provides the Jar file used in the R package [largeRCRF](https://github.com/jatherrien/largeRCRF). -* The first is the largeRCRF library (`library/`) containing all of the logic used for training the random forests. This part provides the Jar file used in the R package [largeRCRF](https://github.com/jatherrien/largeRCRF). -* The second is a small executable (`executable/`) Java project that uses the library and can be run directly outside of R. It's still in its early stages and isn't polished, nor is it yet well documented; but you can take a look if you want. - -Most users interested in training random competing risks forests should use the [R package component](https://github.com/jatherrien/largeRCRF); the content in this repository will only be useful to advanced users. +Most users interested in training random competing risks forests should use the [R package component](https://github.com/jatherrien/largeRCRF); the content in this repository is only useful for advanced users. ## License -You're free to use / modify / redistribute either of the two projects above, as long as you follow the terms of the GPL-3 license. +You're free to use / modify / redistribute thep project, as long as you follow the terms of the GPL-3 license. ## Extending Documentation on how to extend the library to add support for other types of random forests will eventually be added, but for now if you're interested in that I suggest you take a look at the `MeanResponseCombiner` and `WeightedVarianceSplitFinder` classes to see how some basic regression random forests were introduced. -If you've made a modification to the package and would like to integrate it into the R package component, build the project in Maven with `mvn clean package` (in the same directory as this `README` file), then just copy `library/target/largeRCRF-library-1.0-SNAPSHOT.jar` into the `inst/java/` directory for the R package, replacing the previous Jar file there. Then build the R package, possibly with your modifications to the code there, with `R> devtools::build()`. +If you've made a modification to the package and would like to integrate it into the R package component, build the project in Maven with `mvn clean package`, then just copy `target/largeRCRF-library-1.0-SNAPSHOT.jar` into the `inst/java/` directory for the R package, replacing the previous Jar file there. Then build the R package, possibly with your modifications to the code there, with `R> devtools::build()`. Please don't take the current lack of documentation as a sign that I oppose others extending or modifying the project; if you have any questions on running, extending, integrating with R, or anything else related to this project, please don't hesitate to either [email me](mailto:joelt@sfu.ca) or create an Issue. Most likely my answers to your questions will end up forming the basis for any documentation written. @@ -26,26 +23,3 @@ You need: * A Java runtime version 1.8 or greater * Maven to build the project -## Troubleshooting (Running `executable`) - -Some of these Troubleshooting items can also apply if you are integrating the library classes into your own Java project. - -### I get an `OutOfMemoryException` error but I have plenty of RAM - -By default the Java virtual machine only uses a quarter of the available system memory. When launching the Jar file you can manually specify the memory available like below: -``` -java -jar -Xmx15G -Xms15G largeRCRF-executable-1.0-SNAPSHOT.jar settings.yaml -``` - -with `15G` replaced with a little less than your available system memory. - -### I get an `OutOfMemoryException` error and I'm short on RAM - -Try reducing the number of trees being trained simultaneously by reducing the number of threads in the settings file. - -### Training stalls immediately at 0 trees and the CPU is idle - -This issue has been observed before on one particular system (and only on that system) but it's not clear what causes it. If you encounter this, please open an Issue and describe what operating system you're running on, what cloud system (if relevant) you're running on, and the entire output of `java --version`. - -From my observation this issues occurs randomly but only at 0 trees; so as an imperfect workaround you can cancel the training and try again. Another imperfect workaround is to set the number of threads to 1; this causes the code to not use Java's parallel code capabilities which will bypass the problem (at the cost of slower training). - diff --git a/executable/pom.xml b/executable/pom.xml deleted file mode 100644 index 7fdcc5d..0000000 --- a/executable/pom.xml +++ /dev/null @@ -1,126 +0,0 @@ - - - - largeRCRF - ca.joeltherrien - 1.0-SNAPSHOT - - 4.0.0 - - largeRCRF-executable - - - 1.8 - 1.8 - 1.8 - 2.9.9 - - UTF-8 - UTF-8 - - - - - org.projectlombok - lombok - 1.18.0 - provided - - - - org.apache.commons - commons-csv - 1.5 - - - - com.fasterxml.jackson.core - jackson-databind - - 2.9.9.3 - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - - org.junit.jupiter - junit-jupiter-api - 5.2.0 - test - - - - org.junit.jupiter - junit-jupiter-engine - 5.2.0 - test - - - - org.mockito - mockito-core - 2.20.0 - test - - - ca.joeltherrien - largeRCRF-library - 1.0-SNAPSHOT - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - - - - ca.joeltherrien.randomforest.Main - - - - true - - - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.11.0 - - - package - - check - - - - - - - ${project.basedir}/../pmd-rules.xml - - - - - - - - diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/Main.java b/executable/src/main/java/ca/joeltherrien/randomforest/Main.java deleted file mode 100644 index 569a51b..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/Main.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest; - -import ca.joeltherrien.randomforest.covariates.Covariate; -import ca.joeltherrien.randomforest.covariates.settings.BooleanCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.FactorCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.NumericCovariateSettings; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskErrorRateCalculator; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskFunctions; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponseWithCensorTime; -import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskFunctionCombiner; -import ca.joeltherrien.randomforest.tree.Forest; -import ca.joeltherrien.randomforest.tree.ForestTrainer; -import ca.joeltherrien.randomforest.tree.ResponseCombiner; -import ca.joeltherrien.randomforest.tree.TreeTrainer; -import ca.joeltherrien.randomforest.utils.CSVUtils; -import ca.joeltherrien.randomforest.utils.DataUtils; -import ca.joeltherrien.randomforest.utils.StepFunction; -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 java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.List; -import java.util.Optional; -import java.util.Random; - -public class Main { - - public static void main(String[] args) throws IOException, ClassNotFoundException { - if(args.length < 2){ - System.out.println("Must provide two arguments - the path to the settings.yaml file and instructions to either train or analyze."); - System.out.println("Note that analyzing only supports competing risk data, and that you must then specify a sample size for testing errors."); - if(args.length == 0){ - final File templateFile = new File("template.yaml"); - if(templateFile.exists()){ - System.out.println("Template file exists; not creating a new one"); - } - else{ - System.out.println("Generating template file."); - defaultTemplate().save(templateFile); - } - - - } - return; - } - final File settingsFile = new File(args[0]); - final Settings settings = Settings.load(settingsFile); - - final List covariates = settings.getCovariates(); - - if(args[1].equalsIgnoreCase("train")){ - final List> dataset = CSVUtils.loadData(covariates, settings.getResponseLoader(), settings.getTrainingDataLocation()); - - final ForestTrainer forestTrainer = constructForestTrainer(settings, dataset, covariates); - - if(settings.isSaveProgress()){ - if(settings.getNumberOfThreads() > 1){ - forestTrainer.trainParallelOnDisk(Optional.empty(), settings.getNumberOfThreads()); - } else{ - forestTrainer.trainSerialOnDisk(Optional.empty()); - } - } - else{ - if(settings.getNumberOfThreads() > 1){ - forestTrainer.trainParallelInMemory(Optional.empty(), settings.getNumberOfThreads()); - } else{ - forestTrainer.trainSerialInMemory(Optional.empty()); - } - } - } - else if(args[1].equalsIgnoreCase("analyze")){ - // Perform different prediction measures - - if(args.length < 3){ - System.out.println("Specify error sample size"); - return; - } - - final String yVarType = settings.getYVarSettings().get("type").asText(); - - if(!yVarType.equalsIgnoreCase("CompetingRiskResponse") && !yVarType.equalsIgnoreCase("CompetingRiskResponseWithCensorTime")){ - System.out.println("Analyze currently only works on competing risk data"); - return; - } - - final ResponseCombiner responseCombiner = settings.getTreeCombiner(); - final int[] events; - - if(responseCombiner instanceof CompetingRiskFunctionCombiner){ - events = ((CompetingRiskFunctionCombiner) responseCombiner).getEvents(); - } - else{ - System.out.println("Unsupported tree combiner"); - return; - } - - final List> dataset = CSVUtils.loadData(covariates, settings.getResponseLoader(), settings.getValidationDataLocation()); - - // Let's reduce this down to n - final int n = Integer.parseInt(args[2]); - Utils.reduceListToSize(dataset, n, new Random()); - - final File folder = new File(settings.getSaveTreeLocation()); - final Forest forest = DataUtils.loadOnlineForest(folder, responseCombiner); - - final boolean useBootstrapPredictions = settings.getTrainingDataLocation().equals(settings.getValidationDataLocation()); - - if(useBootstrapPredictions){ - System.out.println("Finished loading trees + dataset; creating calculator and evaluating OOB predictions"); - } - else{ - System.out.println("Finished loading trees + dataset; creating calculator and evaluating predictions"); - } - - - final CompetingRiskErrorRateCalculator errorRateCalculator = new CompetingRiskErrorRateCalculator(dataset, forest, useBootstrapPredictions); - final PrintWriter printWriter = new PrintWriter(settings.getSaveTreeLocation() + "/errors.txt"); - - System.out.println("Running Naive Concordance"); - - final double[] naiveConcordance = errorRateCalculator.calculateConcordance(events); - printWriter.write("Naive concordance:\n"); - for(int i=0; i ((CompetingRiskResponseWithCensorTime) row.getResponse()).getC()) - .toArray(); - final StepFunction censorDistribution = Utils.estimateOneMinusECDF(censorTimes); - - System.out.println("Finished generating censor distribution - running concordance"); - - final double[] ipcwConcordance = errorRateCalculator.calculateIPCWConcordance(events, censorDistribution); - printWriter.write("IPCW concordance:\n"); - for(int i=0; i> data, final List covariates){ - - return ForestTrainer.builder() - .ntree(settings.getNtree()) - .data(data) - .displayProgress(true) - .saveTreeLocation(settings.getSaveTreeLocation()) - .covariates(covariates) - .treeResponseCombiner(settings.getTreeCombiner()) - .treeTrainer(constructTreeTrainer(settings, covariates)) - .randomSeed(settings.getRandomSeed() != null ? settings.getRandomSeed() : System.nanoTime()) - .build(); - - } - - private static TreeTrainer constructTreeTrainer(final Settings settings, final List covariates) { - - return TreeTrainer.builder() - .numberOfSplits(settings.getNumberOfSplits()) - .nodeSize(settings.getNodeSize()) - .maxNodeDepth(settings.getMaxNodeDepth()) - .mtry(settings.getMtry()) - .checkNodePurity(settings.isCheckNodePurity()) - .responseCombiner(settings.getResponseCombiner()) - .splitFinder(settings.getSplitFinder()) - .covariates(covariates) - .build(); - } - - - private static Settings defaultTemplate(){ - - final ObjectNode splitFinderSettings = new ObjectNode(JsonNodeFactory.instance); - splitFinderSettings.set("type", new TextNode("WeightedVarianceSplitFinder")); - - final ObjectNode responseCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - responseCombinerSettings.set("type", new TextNode("MeanResponseCombiner")); - - final ObjectNode treeCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - treeCombinerSettings.set("type", new TextNode("MeanResponseCombiner")); - - final ObjectNode yVarSettings = new ObjectNode(JsonNodeFactory.instance); - yVarSettings.set("type", new TextNode("Double")); - yVarSettings.set("name", new TextNode("y")); - - return Settings.builder() - .covariateSettings(Utils.easyList( - new NumericCovariateSettings("x1", true), - new BooleanCovariateSettings("x2", false), - new FactorCovariateSettings("x3", Utils.easyList("cat", "mouse", "dog"), true) - ) - ) - .trainingDataLocation("training_data.csv") - .validationDataLocation("validation_data.csv") - .responseCombinerSettings(responseCombinerSettings) - .treeCombinerSettings(treeCombinerSettings) - .splitFinderSettings(splitFinderSettings) - .yVarSettings(yVarSettings) - .maxNodeDepth(100000) - .mtry(2) - .nodeSize(5) - .ntree(500) - .numberOfSplits(5) - .numberOfThreads(1) - .saveProgress(true) - .saveTreeLocation("trees/") - .build(); - } - -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/Settings.java b/executable/src/main/java/ca/joeltherrien/randomforest/Settings.java deleted file mode 100644 index a5ca343..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/Settings.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest; - -import ca.joeltherrien.randomforest.covariates.Covariate; -import ca.joeltherrien.randomforest.covariates.settings.CovariateSettings; -import ca.joeltherrien.randomforest.loaders.CompetingResponseLoader; -import ca.joeltherrien.randomforest.loaders.CompetingResponseWithCensorTimeLoader; -import ca.joeltherrien.randomforest.loaders.DoubleLoader; -import ca.joeltherrien.randomforest.loaders.ResponseLoader; -import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskFunctionCombiner; -import ca.joeltherrien.randomforest.responses.competingrisk.combiner.CompetingRiskResponseCombiner; -import ca.joeltherrien.randomforest.responses.competingrisk.splitfinder.GrayLogRankSplitFinder; -import ca.joeltherrien.randomforest.responses.competingrisk.splitfinder.LogRankSplitFinder; -import ca.joeltherrien.randomforest.responses.regression.MeanResponseCombiner; -import ca.joeltherrien.randomforest.responses.regression.WeightedVarianceSplitFinder; -import ca.joeltherrien.randomforest.tree.ForestResponseCombiner; -import ca.joeltherrien.randomforest.tree.ResponseCombiner; -import ca.joeltherrien.randomforest.tree.SplitFinder; -import ca.joeltherrien.randomforest.utils.JsonUtils; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -/** - * This class is saved & loaded using a saved configuration file. It contains all relevant settings when training a forest. - */ -@Data -@Builder -@AllArgsConstructor -@EqualsAndHashCode -public class Settings { - - private static Map> RESPONSE_LOADER_MAP = new HashMap<>(); - public static Function getResponseLoaderConstructor(final String name){ - return RESPONSE_LOADER_MAP.get(name.toLowerCase()); - } - public static void registerResponseLoaderConstructor(final String name, final Function responseLoaderConstructor){ - RESPONSE_LOADER_MAP.put(name.toLowerCase(), responseLoaderConstructor); - } - - static{ - registerResponseLoaderConstructor("double", - node -> new DoubleLoader(node) - ); - registerResponseLoaderConstructor("CompetingRiskResponse", - node -> new CompetingResponseLoader(node) - ); - registerResponseLoaderConstructor("CompetingRiskResponseWithCensorTime", - node -> new CompetingResponseWithCensorTimeLoader(node) - ); - } - - private static Map> SPLIT_FINDER_MAP = new HashMap<>(); - public static Function getSplitFinderConstructor(final String name){ - return SPLIT_FINDER_MAP.get(name.toLowerCase()); - } - public static void registerSplitFinderConstructor(final String name, final Function splitFinderConstructor){ - SPLIT_FINDER_MAP.put(name.toLowerCase(), splitFinderConstructor); - } - static{ - registerSplitFinderConstructor("WeightedVarianceSplitFinder", - (node) -> new WeightedVarianceSplitFinder() - ); - registerSplitFinderConstructor("GrayLogRankSplitFinder", - (objectNode) -> { - final int[] eventsOfFocusArray = JsonUtils.jsonToIntArray(objectNode.get("eventsOfFocus")); - final int[] eventArray = JsonUtils.jsonToIntArray(objectNode.get("events")); - - return new GrayLogRankSplitFinder(eventsOfFocusArray, eventArray); - } - ); - registerSplitFinderConstructor("LogRankSplitFinder", - (objectNode) -> { - final int[] eventsOfFocusArray = JsonUtils.jsonToIntArray(objectNode.get("eventsOfFocus")); - final int[] eventArray = JsonUtils.jsonToIntArray(objectNode.get("events")); - - return new LogRankSplitFinder(eventsOfFocusArray, eventArray); - } - ); - } - - - - private static Map> RESPONSE_COMBINER_MAP = new HashMap<>(); - private static Map> FOREST_RESPONSE_COMBINER_MAP = new HashMap<>(); - - public static Function getResponseCombinerConstructor(final String name){ - return RESPONSE_COMBINER_MAP.get(name.toLowerCase()); - } - public static void registerResponseCombinerConstructor(final String name, final Function responseCombinerConstructor){ - RESPONSE_COMBINER_MAP.put(name.toLowerCase(), responseCombinerConstructor); - } - - public static Function getForestResponseCombinerConstructor(final String name){ - return FOREST_RESPONSE_COMBINER_MAP.get(name.toLowerCase()); - } - public static void registerForestResponseCombinerConstructor(final String name, final Function responseCombinerConstructor){ - FOREST_RESPONSE_COMBINER_MAP.put(name.toLowerCase(), responseCombinerConstructor); - } - - static{ - - registerResponseCombinerConstructor("MeanResponseCombiner", - (node) -> new MeanResponseCombiner() - ); - registerForestResponseCombinerConstructor("MeanResponseCombiner", - (node) -> new MeanResponseCombiner() - ); - registerResponseCombinerConstructor("CompetingRiskResponseCombiner", - (node) -> { - final int[] events = JsonUtils.jsonToIntArray(node.get("events")); - - return new CompetingRiskResponseCombiner(events); - - } - ); - - registerForestResponseCombinerConstructor("CompetingRiskFunctionCombiner", - (node) -> { - final int[] events = JsonUtils.jsonToIntArray(node.get("events")); - - double[] times = null; - if(node.hasNonNull("times")){ - times = JsonUtils.jsonToDoubleArray(node.get("times")); - } - - return new CompetingRiskFunctionCombiner(events, times); - - } - ); - } - - private int numberOfSplits = 5; - private int nodeSize = 5; - private int maxNodeDepth = 1000000; // basically no maxNodeDepth - private boolean checkNodePurity = false; - private Long randomSeed; - - private ObjectNode responseCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - private ObjectNode splitFinderSettings = new ObjectNode(JsonNodeFactory.instance); - private ObjectNode treeCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - - private List covariateSettings = new ArrayList<>(); - private ObjectNode yVarSettings = new ObjectNode(JsonNodeFactory.instance); - - // number of covariates to randomly try - private int mtry = 0; - - // number of trees to try - private int ntree = 500; - - private String trainingDataLocation = "data.csv"; - private String validationDataLocation = "data.csv"; - private String saveTreeLocation = "trees/"; - - private int numberOfThreads = 1; - private boolean saveProgress = false; - - public Settings(){ - } // required for Jackson - - public static Settings load(File file) throws IOException { - final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - //mapper.enableDefaultTyping(); - - return mapper.readValue(file, Settings.class); - - } - - public void save(File file) throws IOException { - final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); - //mapper.enableDefaultTyping(); - - // Jackson can struggle with some types of Lists, such as that returned by the useful List.of(...) - this.covariateSettings = new ArrayList<>(this.covariateSettings); - - mapper.writeValue(file, this); - } - - @JsonIgnore - public SplitFinder getSplitFinder(){ - final String type = splitFinderSettings.get("type").asText(); - - return getSplitFinderConstructor(type).apply(splitFinderSettings); - } - - @JsonIgnore - public ResponseLoader getResponseLoader(){ - final String type = yVarSettings.get("type").asText(); - - return getResponseLoaderConstructor(type).apply(yVarSettings); - } - - @JsonIgnore - public ResponseCombiner getResponseCombiner(){ - final String type = responseCombinerSettings.get("type").asText(); - - return getResponseCombinerConstructor(type).apply(responseCombinerSettings); - } - - @JsonIgnore - public ForestResponseCombiner getTreeCombiner(){ - final String type = treeCombinerSettings.get("type").asText(); - - return getForestResponseCombinerConstructor(type).apply(treeCombinerSettings); - } - - @JsonIgnore - public List getCovariates(){ - final List covariateSettingsList = this.getCovariateSettings(); - final List covariates = new ArrayList<>(covariateSettingsList.size()); - for(int i = 0; i < covariateSettingsList.size(); i++){ - covariates.add(covariateSettingsList.get(i).build(i)); - } - return covariates; - } - -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/BooleanCovariateSettings.java b/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/BooleanCovariateSettings.java deleted file mode 100644 index 0c7ba46..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/BooleanCovariateSettings.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.covariates.settings; - -import ca.joeltherrien.randomforest.covariates.bool.BooleanCovariate; -import lombok.Data; -import lombok.NoArgsConstructor; - -@NoArgsConstructor // required by Jackson -@Data -public final class BooleanCovariateSettings extends CovariateSettings { - - public BooleanCovariateSettings(String name, boolean naSplitPenalty){ - super(name, naSplitPenalty); - } - - @Override - public BooleanCovariate build(int index) { - return new BooleanCovariate(name, index, naSplitPenalty); - } -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/CovariateSettings.java b/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/CovariateSettings.java deleted file mode 100644 index e658dc0..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/CovariateSettings.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.covariates.settings; - -import ca.joeltherrien.randomforest.covariates.Covariate; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import lombok.Getter; -import lombok.NoArgsConstructor; - -/** - * Nuisance class to work with Jackson for persisting settings. - * - * @param - */ -@NoArgsConstructor // required for Jackson -@Getter -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = BooleanCovariateSettings.class, name = "boolean"), - @JsonSubTypes.Type(value = NumericCovariateSettings.class, name = "numeric"), - @JsonSubTypes.Type(value = FactorCovariateSettings.class, name = "factor") -}) -public abstract class CovariateSettings { - - String name; - boolean naSplitPenalty; - - CovariateSettings(String name, boolean naSplitPenalty){ - this.name = name; - this.naSplitPenalty = naSplitPenalty; - } - - public abstract Covariate build(int index); -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/FactorCovariateSettings.java b/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/FactorCovariateSettings.java deleted file mode 100644 index 499bba1..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/FactorCovariateSettings.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.covariates.settings; - -import ca.joeltherrien.randomforest.covariates.factor.FactorCovariate; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.ArrayList; -import java.util.List; - -@NoArgsConstructor // required by Jackson -@Data -public final class FactorCovariateSettings extends CovariateSettings { - - private List levels; - - public FactorCovariateSettings(String name, List levels, boolean naSplitPenalty){ - super(name, naSplitPenalty); - this.levels = new ArrayList<>(levels); // Jackson struggles with List.of(...) - } - - @Override - public FactorCovariate build(int index) { - return new FactorCovariate(name, index, levels, naSplitPenalty); - } -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/NumericCovariateSettings.java b/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/NumericCovariateSettings.java deleted file mode 100644 index 6820dde..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/covariates/settings/NumericCovariateSettings.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.covariates.settings; - -import ca.joeltherrien.randomforest.covariates.numeric.NumericCovariate; -import lombok.Data; -import lombok.NoArgsConstructor; - -@NoArgsConstructor // required by Jackson -@Data -public final class NumericCovariateSettings extends CovariateSettings { - - public NumericCovariateSettings(String name, boolean naSplitPenalty){ - super(name, naSplitPenalty); - } - - @Override - public NumericCovariate build(int index) { - return new NumericCovariate(name, index, naSplitPenalty); - } -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseLoader.java b/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseLoader.java deleted file mode 100644 index ebfe755..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseLoader.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.loaders; - -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponse; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.RequiredArgsConstructor; -import org.apache.commons.csv.CSVRecord; - -@RequiredArgsConstructor -public class CompetingResponseLoader implements ResponseLoader { - - private final String deltaName; - private final String uName; - - public CompetingResponseLoader(ObjectNode node){ - this.deltaName = node.get("delta").asText(); - this.uName = node.get("u").asText(); - } - - @Override - public CompetingRiskResponse parse(CSVRecord record) { - final int delta = Integer.parseInt(record.get(deltaName)); - final double u = Double.parseDouble(record.get(uName)); - - return new CompetingRiskResponse(delta, u); - } -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseWithCensorTimeLoader.java b/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseWithCensorTimeLoader.java deleted file mode 100644 index 9003046..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/CompetingResponseWithCensorTimeLoader.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.loaders; - -import ca.joeltherrien.randomforest.responses.competingrisk.CompetingRiskResponseWithCensorTime; -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.RequiredArgsConstructor; -import org.apache.commons.csv.CSVRecord; - -@RequiredArgsConstructor -public class CompetingResponseWithCensorTimeLoader implements ResponseLoader{ - - private final String deltaName; - private final String uName; - private final String cName; - - public CompetingResponseWithCensorTimeLoader(ObjectNode node){ - this.deltaName = node.get("delta").asText(); - this.uName = node.get("u").asText(); - this.cName = node.get("c").asText(); - } - - @Override - public CompetingRiskResponseWithCensorTime parse(CSVRecord record) { - final int delta = Integer.parseInt(record.get(deltaName)); - final double u = Double.parseDouble(record.get(uName)); - final double c = Double.parseDouble(record.get(cName)); - - return new CompetingRiskResponseWithCensorTime(delta, u, c); - } -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/DoubleLoader.java b/executable/src/main/java/ca/joeltherrien/randomforest/loaders/DoubleLoader.java deleted file mode 100644 index 920a112..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/DoubleLoader.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.loaders; - -import com.fasterxml.jackson.databind.node.ObjectNode; -import lombok.RequiredArgsConstructor; -import org.apache.commons.csv.CSVRecord; - -@RequiredArgsConstructor -public class DoubleLoader implements ResponseLoader { - - private final String yName; - - public DoubleLoader(final ObjectNode node){ - this.yName = node.get("name").asText(); - } - - @Override - public Double parse(CSVRecord record) { - return Double.parseDouble(record.get(yName)); - } -} \ No newline at end of file diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/ResponseLoader.java b/executable/src/main/java/ca/joeltherrien/randomforest/loaders/ResponseLoader.java deleted file mode 100644 index e777aee..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/loaders/ResponseLoader.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.loaders; - -import org.apache.commons.csv.CSVRecord; - -@FunctionalInterface -public interface ResponseLoader { - - Y parse(CSVRecord record); - -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/utils/CSVUtils.java b/executable/src/main/java/ca/joeltherrien/randomforest/utils/CSVUtils.java deleted file mode 100644 index 3defa8a..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/utils/CSVUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.utils; - -import ca.joeltherrien.randomforest.Row; -import ca.joeltherrien.randomforest.covariates.Covariate; -import ca.joeltherrien.randomforest.loaders.ResponseLoader; -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.List; -import java.util.zip.GZIPInputStream; - -public class CSVUtils { - - public static List> loadData(final List covariates, final ResponseLoader responseLoader, String filename) throws IOException { - - final List> dataset = new ArrayList<>(); - - final Reader input; - if(filename.endsWith(".gz")){ - final FileInputStream inputStream = new FileInputStream(filename); - final GZIPInputStream gzipInputStream = new GZIPInputStream(inputStream); - - input = new InputStreamReader(gzipInputStream); - } - else{ - input = new FileReader(filename); - } - - - final CSVParser parser = CSVFormat.RFC4180.withFirstRecordAsHeader().parse(input); - - - int id = 1; - for(final CSVRecord record : parser){ - final Covariate.Value[] valueArray = new Covariate.Value[covariates.size()]; - - for(final Covariate covariate : covariates){ - valueArray[covariate.getIndex()] = covariate.createValue(record.get(covariate.getName())); - } - - final Y y = responseLoader.parse(record); - - dataset.add(new Row<>(valueArray, id++, y)); - - } - - return dataset; - - } - -} diff --git a/executable/src/main/java/ca/joeltherrien/randomforest/utils/JsonUtils.java b/executable/src/main/java/ca/joeltherrien/randomforest/utils/JsonUtils.java deleted file mode 100644 index a6e3264..0000000 --- a/executable/src/main/java/ca/joeltherrien/randomforest/utils/JsonUtils.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.utils; - -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -public class JsonUtils { - - public static int[] jsonToIntArray(final JsonNode node){ - final Iterator elements = node.elements(); - final List elementList = new ArrayList<>(); - elements.forEachRemaining(n -> elementList.add(n)); - - final int[] array = elementList.stream().mapToInt(n -> n.asInt()).toArray(); - return array; - } - - public static double[] jsonToDoubleArray(final JsonNode node){ - final Iterator elements = node.elements(); - final List elementList = new ArrayList<>(); - elements.forEachRemaining(n -> elementList.add(n)); - - final double[] array = elementList.stream().mapToDouble(n -> n.asDouble()).toArray(); - return array; - } -} diff --git a/executable/src/test/java/ca/joeltherrien/randomforest/TestPersistence.java b/executable/src/test/java/ca/joeltherrien/randomforest/TestPersistence.java deleted file mode 100644 index acc53c3..0000000 --- a/executable/src/test/java/ca/joeltherrien/randomforest/TestPersistence.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import ca.joeltherrien.randomforest.covariates.settings.BooleanCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.FactorCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.NumericCovariateSettings; -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.junit.jupiter.api.Test; - -import java.io.File; -import java.io.IOException; - -public class TestPersistence { - - @Test - public void testSaving() throws IOException { - final ObjectNode splitFinderSettings = new ObjectNode(JsonNodeFactory.instance); - splitFinderSettings.set("type", new TextNode("WeightedVarianceSplitFinder")); - - final ObjectNode responseCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - responseCombinerSettings.set("type", new TextNode("MeanResponseCombiner")); - - final ObjectNode treeCombinerSettings = new ObjectNode(JsonNodeFactory.instance); - treeCombinerSettings.set("type", new TextNode("MeanResponseCombiner")); - - final ObjectNode yVarSettings = new ObjectNode(JsonNodeFactory.instance); - yVarSettings.set("type", new TextNode("Double")); - yVarSettings.set("name", new TextNode("y")); - - final Settings settingsOriginal = Settings.builder() - .covariateSettings(Utils.easyList( - new NumericCovariateSettings("x1", true), - new BooleanCovariateSettings("x2", false), - new FactorCovariateSettings("x3", Utils.easyList("cat", "mouse", "dog"), true) - ) - ) - .trainingDataLocation("training_data.csv") - .validationDataLocation("validation_data.csv") - .responseCombinerSettings(responseCombinerSettings) - .treeCombinerSettings(treeCombinerSettings) - .splitFinderSettings(splitFinderSettings) - .yVarSettings(yVarSettings) - .maxNodeDepth(100000) - .mtry(2) - .nodeSize(5) - .ntree(500) - .numberOfSplits(5) - .numberOfThreads(1) - .saveProgress(true) - .saveTreeLocation("trees/") - .build(); - - final File templateFile = new File("template.yaml"); - settingsOriginal.save(templateFile); - - final Settings reloadedSettings = Settings.load(templateFile); - - assertEquals(settingsOriginal, reloadedSettings); - - //templateFile.delete(); - - - } -} \ No newline at end of file diff --git a/executable/src/test/java/ca/joeltherrien/randomforest/csv/TestLoadingCSV.java b/executable/src/test/java/ca/joeltherrien/randomforest/csv/TestLoadingCSV.java deleted file mode 100644 index 3c5991f..0000000 --- a/executable/src/test/java/ca/joeltherrien/randomforest/csv/TestLoadingCSV.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2019 Joel Therrien. - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package ca.joeltherrien.randomforest.csv; - -import ca.joeltherrien.randomforest.Row; -import ca.joeltherrien.randomforest.Settings; -import ca.joeltherrien.randomforest.covariates.Covariate; -import ca.joeltherrien.randomforest.covariates.settings.BooleanCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.FactorCovariateSettings; -import ca.joeltherrien.randomforest.covariates.settings.NumericCovariateSettings; -import ca.joeltherrien.randomforest.loaders.ResponseLoader; -import ca.joeltherrien.randomforest.utils.CSVUtils; -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.junit.jupiter.api.Test; - -import java.io.IOException; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class TestLoadingCSV { - - /* - y,x1,x2,x3 - 5,3.0,"mouse",true - 2,1.0,"dog",false - 9,1.5,"cat",true - -3,NA,NA,NA - */ - - - public List> loadData(String filename) throws IOException { - final ObjectNode yVarSettings = new ObjectNode(JsonNodeFactory.instance); - yVarSettings.set("type", new TextNode("Double")); - yVarSettings.set("name", new TextNode("y")); - - final Settings settings = Settings.builder() - .trainingDataLocation(filename) - .covariateSettings( - Utils.easyList(new NumericCovariateSettings("x1", true), - new FactorCovariateSettings("x2", Utils.easyList("dog", "cat", "mouse"), false), - new BooleanCovariateSettings("x3", true)) - ) - .yVarSettings(yVarSettings) - .build(); - - final List covariates = settings.getCovariates(); - - - final ResponseLoader loader = settings.getResponseLoader(); - - return CSVUtils.loadData(covariates, loader, settings.getTrainingDataLocation()); - } - - @Test - public void testLoadingNormal(final List covariates) throws IOException { - final List> data = loadData("src/test/resources/testCSV.csv"); - - assertData(data, covariates); - } - - @Test - public void testLoadingGz(final List covariates) throws IOException { - final List> data = loadData("src/test/resources/testCSV.csv.gz"); - - assertData(data, covariates); - } - - - private void assertData(final List> data, final List covariates){ - final Covariate x1 = covariates.get(0); - final Covariate x2 = covariates.get(0); - final Covariate x3 = covariates.get(0); - - assertEquals(4, data.size()); - - Row row = data.get(0); - assertEquals(5.0, (double)row.getResponse()); - assertEquals(3.0, row.getCovariateValue(x1).getValue()); - assertEquals("mouse", row.getCovariateValue(x2).getValue()); - assertEquals(true, row.getCovariateValue(x3).getValue()); - - row = data.get(1); - assertEquals(2.0, (double)row.getResponse()); - assertEquals(1.0, row.getCovariateValue(x1).getValue()); - assertEquals("dog", row.getCovariateValue(x2).getValue()); - assertEquals(false, row.getCovariateValue(x3).getValue()); - - row = data.get(2); - assertEquals(9.0, (double)row.getResponse()); - assertEquals(1.5, row.getCovariateValue(x1).getValue()); - assertEquals("cat", row.getCovariateValue(x2).getValue()); - assertEquals(true, row.getCovariateValue(x3).getValue()); - - row = data.get(3); - assertEquals(-3.0, (double)row.getResponse()); - assertTrue(row.getCovariateValue(x1).isNA()); - assertTrue(row.getCovariateValue(x2).isNA()); - assertTrue(row.getCovariateValue(x3).isNA()); - } - -} diff --git a/library/pom.xml b/library/pom.xml deleted file mode 100644 index 962f1dd..0000000 --- a/library/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - 4.0.0 - - largeRCRF-library - - - - ca.joeltherrien - largeRCRF - 1.0-SNAPSHOT - - - - 1.8 - 1.8 - 1.8 - - UTF-8 - UTF-8 - - - - - - org.projectlombok - lombok - 1.18.0 - provided - - - - org.apache.commons - commons-csv - 1.5 - test - - - - org.junit.jupiter - junit-jupiter-api - 5.2.0 - test - - - - org.junit.jupiter - junit-jupiter-engine - 5.2.0 - test - - - - org.mockito - mockito-core - 2.20.0 - test - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.11.0 - - - package - - check - - - - - - - ${project.basedir}/../pmd-rules.xml - - - - - - - - - diff --git a/pom.xml b/pom.xml index 8f1fbbb..6429306 100644 --- a/pom.xml +++ b/pom.xml @@ -1,21 +1,98 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - ca.joeltherrien - largeRCRF + ca.joeltherrien.ca + largeRCRF-library 1.0-SNAPSHOT - pom - - - library - executable - + + 1.8 + 1.8 + 1.8 + + UTF-8 + UTF-8 + + + + + + org.projectlombok + lombok + 1.18.0 + provided + + + + org.apache.commons + commons-csv + 1.5 + test + + + + org.junit.jupiter + junit-jupiter-api + 5.2.0 + test + + + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + test + + + + org.mockito + mockito-core + 2.20.0 + test + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.11.0 + + + package + + check + + + + + + + pmd-rules.xml + + + + + + + - diff --git a/library/src/main/java/ca/joeltherrien/randomforest/Bootstrapper.java b/src/main/java/ca/joeltherrien/randomforest/Bootstrapper.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/Bootstrapper.java rename to src/main/java/ca/joeltherrien/randomforest/Bootstrapper.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java b/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/CovariateRow.java rename to src/main/java/ca/joeltherrien/randomforest/CovariateRow.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/Row.java b/src/main/java/ca/joeltherrien/randomforest/Row.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/Row.java rename to src/main/java/ca/joeltherrien/randomforest/Row.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/VisibleForTesting.java b/src/main/java/ca/joeltherrien/randomforest/VisibleForTesting.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/VisibleForTesting.java rename to src/main/java/ca/joeltherrien/randomforest/VisibleForTesting.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/Covariate.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/SplitRule.java b/src/main/java/ca/joeltherrien/randomforest/covariates/SplitRule.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/SplitRule.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/SplitRule.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanCovariate.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanCovariate.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanSplitRule.java b/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanSplitRule.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanSplitRule.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/bool/BooleanSplitRule.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorCovariate.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorCovariate.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorSplitRule.java b/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorSplitRule.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorSplitRule.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/factor/FactorSplitRule.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericCovariate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericCovariate.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericCovariate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericCovariate.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRule.java b/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRule.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRule.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRule.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRuleUpdater.java b/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRuleUpdater.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRuleUpdater.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitRuleUpdater.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitUpdate.java b/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitUpdate.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitUpdate.java rename to src/main/java/ca/joeltherrien/randomforest/covariates/numeric/NumericSplitUpdate.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskErrorRateCalculator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskErrorRateCalculator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskErrorRateCalculator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskErrorRateCalculator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskFunctions.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGraySetsImpl.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGraySetsImpl.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGraySetsImpl.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskGraySetsImpl.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponse.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponse.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponse.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponse.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseWithCensorTime.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseWithCensorTime.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseWithCensorTime.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskResponseWithCensorTime.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSets.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSets.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSets.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSets.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSetsImpl.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSetsImpl.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSetsImpl.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskSetsImpl.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskUtils.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskUtils.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskUtils.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/CompetingRiskUtils.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/IBSCalculator.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/IBSCalculator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/IBSCalculator.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/IBSCalculator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskFunctionCombiner.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/CompetingRiskResponseCombiner.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/IntermediateCompetingRisksFunctionsTimesKnown.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/IntermediateCompetingRisksFunctionsTimesKnown.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/IntermediateCompetingRisksFunctionsTimesKnown.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/combiner/IntermediateCompetingRisksFunctionsTimesKnown.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/CompetingRiskSplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/CompetingRiskSplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/CompetingRiskSplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/CompetingRiskSplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/GrayLogRankSplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/GrayLogRankSplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/GrayLogRankSplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/GrayLogRankSplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/LogRankSplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/LogRankSplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/LogRankSplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/responses/competingrisk/splitfinder/LogRankSplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/regression/MeanResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/responses/regression/MeanResponseCombiner.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/regression/MeanResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/responses/regression/MeanResponseCombiner.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/responses/regression/WeightedVarianceSplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/responses/regression/WeightedVarianceSplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/responses/regression/WeightedVarianceSplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/responses/regression/WeightedVarianceSplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java b/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/Forest.java rename to src/main/java/ca/joeltherrien/randomforest/tree/Forest.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/ForestResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/tree/ForestResponseCombiner.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/ForestResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/tree/ForestResponseCombiner.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java rename to src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/IntermediateCombinedResponse.java b/src/main/java/ca/joeltherrien/randomforest/tree/IntermediateCombinedResponse.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/IntermediateCombinedResponse.java rename to src/main/java/ca/joeltherrien/randomforest/tree/IntermediateCombinedResponse.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/Node.java b/src/main/java/ca/joeltherrien/randomforest/tree/Node.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/Node.java rename to src/main/java/ca/joeltherrien/randomforest/tree/Node.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/OfflineForest.java b/src/main/java/ca/joeltherrien/randomforest/tree/OfflineForest.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/OfflineForest.java rename to src/main/java/ca/joeltherrien/randomforest/tree/OfflineForest.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/OnlineForest.java b/src/main/java/ca/joeltherrien/randomforest/tree/OnlineForest.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/OnlineForest.java rename to src/main/java/ca/joeltherrien/randomforest/tree/OnlineForest.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java b/src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java rename to src/main/java/ca/joeltherrien/randomforest/tree/ResponseCombiner.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/SimpleSplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/tree/SimpleSplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/SimpleSplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/tree/SimpleSplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/Split.java b/src/main/java/ca/joeltherrien/randomforest/tree/Split.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/Split.java rename to src/main/java/ca/joeltherrien/randomforest/tree/Split.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/SplitAndScore.java b/src/main/java/ca/joeltherrien/randomforest/tree/SplitAndScore.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/SplitAndScore.java rename to src/main/java/ca/joeltherrien/randomforest/tree/SplitAndScore.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/SplitFinder.java b/src/main/java/ca/joeltherrien/randomforest/tree/SplitFinder.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/SplitFinder.java rename to src/main/java/ca/joeltherrien/randomforest/tree/SplitFinder.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java b/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java rename to src/main/java/ca/joeltherrien/randomforest/tree/SplitNode.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/TerminalNode.java b/src/main/java/ca/joeltherrien/randomforest/tree/TerminalNode.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/TerminalNode.java rename to src/main/java/ca/joeltherrien/randomforest/tree/TerminalNode.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/Tree.java b/src/main/java/ca/joeltherrien/randomforest/tree/Tree.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/Tree.java rename to src/main/java/ca/joeltherrien/randomforest/tree/Tree.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java rename to src/main/java/ca/joeltherrien/randomforest/tree/TreeTrainer.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/ErrorCalculator.java b/src/main/java/ca/joeltherrien/randomforest/tree/vimp/ErrorCalculator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/ErrorCalculator.java rename to src/main/java/ca/joeltherrien/randomforest/tree/vimp/ErrorCalculator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapper.java b/src/main/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapper.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapper.java rename to src/main/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapper.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculator.java b/src/main/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculator.java rename to src/main/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/VariableImportanceCalculator.java b/src/main/java/ca/joeltherrien/randomforest/tree/vimp/VariableImportanceCalculator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/tree/vimp/VariableImportanceCalculator.java rename to src/main/java/ca/joeltherrien/randomforest/tree/vimp/VariableImportanceCalculator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/DataUtils.java b/src/main/java/ca/joeltherrien/randomforest/utils/DataUtils.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/DataUtils.java rename to src/main/java/ca/joeltherrien/randomforest/utils/DataUtils.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/IndexedIterator.java b/src/main/java/ca/joeltherrien/randomforest/utils/IndexedIterator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/IndexedIterator.java rename to src/main/java/ca/joeltherrien/randomforest/utils/IndexedIterator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/IterableOfflineTree.java b/src/main/java/ca/joeltherrien/randomforest/utils/IterableOfflineTree.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/IterableOfflineTree.java rename to src/main/java/ca/joeltherrien/randomforest/utils/IterableOfflineTree.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/MathFunction.java b/src/main/java/ca/joeltherrien/randomforest/utils/MathFunction.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/MathFunction.java rename to src/main/java/ca/joeltherrien/randomforest/utils/MathFunction.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/Point.java b/src/main/java/ca/joeltherrien/randomforest/utils/Point.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/Point.java rename to src/main/java/ca/joeltherrien/randomforest/utils/Point.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/RUtils.java b/src/main/java/ca/joeltherrien/randomforest/utils/RUtils.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/RUtils.java rename to src/main/java/ca/joeltherrien/randomforest/utils/RUtils.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunction.java b/src/main/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunction.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunction.java rename to src/main/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunction.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/SingletonIterator.java b/src/main/java/ca/joeltherrien/randomforest/utils/SingletonIterator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/SingletonIterator.java rename to src/main/java/ca/joeltherrien/randomforest/utils/SingletonIterator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/StepFunction.java b/src/main/java/ca/joeltherrien/randomforest/utils/StepFunction.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/StepFunction.java rename to src/main/java/ca/joeltherrien/randomforest/utils/StepFunction.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/SumFunction.java b/src/main/java/ca/joeltherrien/randomforest/utils/SumFunction.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/SumFunction.java rename to src/main/java/ca/joeltherrien/randomforest/utils/SumFunction.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/UniqueSubsetValueIterator.java b/src/main/java/ca/joeltherrien/randomforest/utils/UniqueSubsetValueIterator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/UniqueSubsetValueIterator.java rename to src/main/java/ca/joeltherrien/randomforest/utils/UniqueSubsetValueIterator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/UniqueValueIterator.java b/src/main/java/ca/joeltherrien/randomforest/utils/UniqueValueIterator.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/UniqueValueIterator.java rename to src/main/java/ca/joeltherrien/randomforest/utils/UniqueValueIterator.java diff --git a/library/src/main/java/ca/joeltherrien/randomforest/utils/Utils.java b/src/main/java/ca/joeltherrien/randomforest/utils/Utils.java similarity index 100% rename from library/src/main/java/ca/joeltherrien/randomforest/utils/Utils.java rename to src/main/java/ca/joeltherrien/randomforest/utils/Utils.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/TestDeterministicForests.java b/src/test/java/ca/joeltherrien/randomforest/TestDeterministicForests.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/TestDeterministicForests.java rename to src/test/java/ca/joeltherrien/randomforest/TestDeterministicForests.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/TestProvidingInitialForest.java b/src/test/java/ca/joeltherrien/randomforest/TestProvidingInitialForest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/TestProvidingInitialForest.java rename to src/test/java/ca/joeltherrien/randomforest/TestProvidingInitialForest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java b/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java rename to src/test/java/ca/joeltherrien/randomforest/TestSavingLoading.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/TestUtils.java b/src/test/java/ca/joeltherrien/randomforest/TestUtils.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/TestUtils.java rename to src/test/java/ca/joeltherrien/randomforest/TestUtils.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/IBSCalculatorTest.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/IBSCalculatorTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/IBSCalculatorTest.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/IBSCalculatorTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.R b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.R similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.R rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.R diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRisk.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskErrorRateCalculator.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskErrorRateCalculator.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskErrorRateCalculator.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskErrorRateCalculator.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctionCombiner.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctionCombiner.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctionCombiner.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctionCombiner.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctions.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctions.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctions.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskFunctions.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.R b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.R similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.R rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.R diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestCompetingRiskResponseCombiner.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.R b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.R similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.R rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSingleGroupDifferentiator.R diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinder.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinder.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinder.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinder.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinderSingleEvent.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinderSingleEvent.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinderSingleEvent.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestLogRankSplitFinderSingleEvent.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestMathFunctions.java b/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestMathFunctions.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/competingrisk/TestMathFunctions.java rename to src/test/java/ca/joeltherrien/randomforest/competingrisk/TestMathFunctions.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java b/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java rename to src/test/java/ca/joeltherrien/randomforest/covariates/FactorCovariateTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/covariates/NumericCovariateTest.java b/src/test/java/ca/joeltherrien/randomforest/covariates/NumericCovariateTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/covariates/NumericCovariateTest.java rename to src/test/java/ca/joeltherrien/randomforest/covariates/NumericCovariateTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/nas/TestNAs.java b/src/test/java/ca/joeltherrien/randomforest/nas/TestNAs.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/nas/TestNAs.java rename to src/test/java/ca/joeltherrien/randomforest/nas/TestNAs.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapperTest.java b/src/test/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapperTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapperTest.java rename to src/test/java/ca/joeltherrien/randomforest/tree/vimp/IBSErrorCalculatorWrapperTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculatorTest.java b/src/test/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculatorTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculatorTest.java rename to src/test/java/ca/joeltherrien/randomforest/tree/vimp/RegressionErrorCalculatorTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/TestVariableImportanceCalculator.java b/src/test/java/ca/joeltherrien/randomforest/tree/vimp/TestVariableImportanceCalculator.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/tree/vimp/TestVariableImportanceCalculator.java rename to src/test/java/ca/joeltherrien/randomforest/tree/vimp/TestVariableImportanceCalculator.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/Data.java b/src/test/java/ca/joeltherrien/randomforest/utils/Data.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/Data.java rename to src/test/java/ca/joeltherrien/randomforest/utils/Data.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/ResponseLoader.java b/src/test/java/ca/joeltherrien/randomforest/utils/ResponseLoader.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/ResponseLoader.java rename to src/test/java/ca/joeltherrien/randomforest/utils/ResponseLoader.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionIntegrationTest.java b/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionIntegrationTest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionIntegrationTest.java rename to src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionIntegrationTest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionOperatorTests.java b/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionOperatorTests.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionOperatorTests.java rename to src/test/java/ca/joeltherrien/randomforest/utils/RightContinuousStepFunctionOperatorTests.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/TestSingletonIterator.java b/src/test/java/ca/joeltherrien/randomforest/utils/TestSingletonIterator.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/TestSingletonIterator.java rename to src/test/java/ca/joeltherrien/randomforest/utils/TestSingletonIterator.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueSubsetValueIterator.java b/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueSubsetValueIterator.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueSubsetValueIterator.java rename to src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueSubsetValueIterator.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueValueIterator.java b/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueValueIterator.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueValueIterator.java rename to src/test/java/ca/joeltherrien/randomforest/utils/TestUniqueValueIterator.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java rename to src/test/java/ca/joeltherrien/randomforest/workshop/TrainForest.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java rename to src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTree.java diff --git a/library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java b/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java similarity index 100% rename from library/src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java rename to src/test/java/ca/joeltherrien/randomforest/workshop/TrainSingleTreeFactor.java diff --git a/library/src/test/resources/testCSV.csv b/src/test/resources/testCSV.csv similarity index 100% rename from library/src/test/resources/testCSV.csv rename to src/test/resources/testCSV.csv diff --git a/library/src/test/resources/testCSV.csv.gz b/src/test/resources/testCSV.csv.gz similarity index 100% rename from library/src/test/resources/testCSV.csv.gz rename to src/test/resources/testCSV.csv.gz diff --git a/library/src/test/resources/test_single_split.csv b/src/test/resources/test_single_split.csv similarity index 100% rename from library/src/test/resources/test_single_split.csv rename to src/test/resources/test_single_split.csv diff --git a/library/src/test/resources/test_split_data.csv b/src/test/resources/test_split_data.csv similarity index 100% rename from library/src/test/resources/test_split_data.csv rename to src/test/resources/test_split_data.csv diff --git a/library/src/test/resources/wihs.bootstrapped.csv b/src/test/resources/wihs.bootstrapped.csv similarity index 100% rename from library/src/test/resources/wihs.bootstrapped.csv rename to src/test/resources/wihs.bootstrapped.csv diff --git a/library/src/test/resources/wihs.bootstrapped2.csv b/src/test/resources/wihs.bootstrapped2.csv similarity index 100% rename from library/src/test/resources/wihs.bootstrapped2.csv rename to src/test/resources/wihs.bootstrapped2.csv diff --git a/library/src/test/resources/wihs.csv b/src/test/resources/wihs.csv similarity index 100% rename from library/src/test/resources/wihs.csv rename to src/test/resources/wihs.csv