From c6a5787975b1ec3e9345ce37b6a1c2d3820b5e6a Mon Sep 17 00:00:00 2001 From: Joel Therrien Date: Tue, 16 Apr 2019 12:58:23 -0700 Subject: [PATCH] Use UUIDs to save trees instead of tree number. Benefits are for when we restart a previously parallel task in which, say, trees 1, 2, and 4 were completed but tree 3 never did complete. Under the previous implementation we'd start at tree 4 (we'd just count how many trees were done). To fix this would require some additional effort. Since the order of trees is irrelevant, it made sense to just stop ordering them. --- .../randomforest/tree/ForestTrainer.java | 8 +++---- .../randomforest/utils/Utils.java | 22 ------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java index 2686666..5d721f1 100644 --- a/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java +++ b/src/main/java/ca/joeltherrien/randomforest/tree/ForestTrainer.java @@ -17,11 +17,10 @@ package ca.joeltherrien.randomforest.tree; import ca.joeltherrien.randomforest.Bootstrapper; -import ca.joeltherrien.randomforest.utils.DataUtils; import ca.joeltherrien.randomforest.Row; import ca.joeltherrien.randomforest.Settings; import ca.joeltherrien.randomforest.covariates.Covariate; -import ca.joeltherrien.randomforest.utils.Utils; +import ca.joeltherrien.randomforest.utils.DataUtils; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -31,6 +30,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadLocalRandom; @@ -110,7 +110,7 @@ public class ForestTrainer { System.out.print("\rFinished " + treeCount.get() + "/" + ntree + " trees"); } - final Runnable worker = new TreeSavedWorker(data, "tree-" + Utils.formatNumber(j+1, ntree) + ".tree", treeCount); + final Runnable worker = new TreeSavedWorker(data, "tree-" + UUID.randomUUID() + ".tree", treeCount); worker.run(); } @@ -191,7 +191,7 @@ public class ForestTrainer { final AtomicInteger treeCount = new AtomicInteger(treeFiles.length); // tracks how many trees are finished for(int j=treeCount.get(); j