Package gov.nih.mipav.model.algorithms
Class StochasticForests
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
gov.nih.mipav.model.algorithms.StochasticForests
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate classprivate classprivate classprivate classprivate classprivate classprivate classprivate classprivate static enumprivate classprivate classprivate classprivate static enumprivate static enumprivate classprivate static enumprivate classprivate classprivate classprivate classprivate classprivate static enumprivate classNested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate String(package private) final double(package private) final StochasticForests.ImportanceMode(package private) final int(package private) final int(package private) final int(package private) final int(package private) final double(package private) final int(package private) final int(package private) final int(package private) final StochasticForests.PredictionType(package private) final StochasticForests.SplitRuleprivate Stringprivate booleanprivate StochasticForests.ImportanceModeprivate Stringprivate Stringstatic double(package private) static final int[]private StochasticForests.MemoryModeprivate booleanprivate intprivate doubleprivate intprivate intprivate intprivate int(package private) static final int[]private Stringprivate booleanprivate StochasticForests.PredictionTypeprivate boolean(package private) final doublestatic intprivate doubleprivate booleanprivate longprivate Stringprivate StochasticForests.SplitRule(package private) final doubleprivate Stringprivate booleanprivate booleanprivate StochasticForests.TreeTypeprivate booleanprivate booleanFields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionStochasticForests(StochasticForests.TreeType treetype, boolean probability, boolean verbose_out, String dependent_variable_name, StochasticForests.MemoryMode memory_mode, String input_file, int mtry, String output_prefix, int num_trees, long seed, int num_threads, String load_forest_filename, StochasticForests.ImportanceMode importance_mode, int min_node_size, String split_select_weights_file, Vector<String> always_split_variable_names, String status_variable_name, boolean sample_with_replacement, Vector<String> unordered_variable_names, boolean memory_saving_splitting, StochasticForests.SplitRule splitrule, String case_weights_file, boolean predict_all, double sample_fraction, double alpha, double minprop, boolean holdout, StochasticForests.PredictionType prediction_type, int num_random_splits, boolean write) -
Method Summary
Modifier and TypeMethodDescriptionadjustPvalues(Vector<Double> unadjusted_pvalues) private StringbeautifyTime(int seconds) private booleancheckPositiveIntegers(Vector<Double> all_values) private StringcheckUnorderedVariables(StochasticForests.Data data, Vector<String> unordered_variable_names) private doublecomputeConcordanceIndex(StochasticForests.Data data, Vector<Double> sum_chf, int dependent_varID, int status_varID, Vector<Integer> sample_IDs) private voiddrawWithoutReplacementFisherYates(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples) private voiddrawWithoutReplacementSimple(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples) private voiddrawWithoutReplacementSkip(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples) private voiddrawWithoutReplacementWeighted(Vector<Integer> result, Random random, int max_index, int num_samples, Vector<Double> weights) private voiddrawWithoutReplacementWeighted(Vector<Integer> result, Random random, Vector<Integer> indices, int num_samples, Vector<Double> weights) private doubledstdnorm(double x) private voidequalSplit(Vector<Integer> result, int start, int end, int num_parts) private booleanprivate booleanprivate booleanprivate booleanprivate doubleerf(double x) private booleanexpectNear(double val1, double val2, double error, String str) (package private) voidloadDoubleVectorFromFile(Vector<Double> result, String filename) logrankScores(Vector<Double> time, Vector<Double> status) private voidmaxstat(Vector<Double> scores, Vector<Double> x, Vector<Integer> indices, double[] best_maxstat, double[] best_split_value, double minprop, double maxprop) private doublemaxstatPValueLau92(double b, double minprop, double maxprop) private doublemaxstatPValueLau94(double b, double minprop, double maxprop, int N, Vector<Integer> m) private doublemaxstatPValueUnadjusted(double b) private intmostFrequentClass(Vector<Integer> class_count, Random random) Returns the most frequent class index of a vector with counts for the classes.private intmostFrequentDClass(Vector<Double> class_count, Random random) Returns the most frequent class index of a vector with counts for the classes.private doublemostFrequentValue(HashMap<Double, Integer> class_count, Random random) numSamplesLeftOfCutpoint(Vector<Double> x, Vector<Integer> indices) private doublepstdnorm(double x) Sample ranks starting from 1.private voidreadBVector1D(Vector<Boolean> result, BufferedReader br) Read a 1d vector written by saveVector1D() from filestream.private voidreadDVector1D(Vector<Double> result, BufferedReader br) Read a 1d vector written by saveVector1D() from filestream.private voidreadDVector2D(Vector<Vector<Double>> result, BufferedReader br) Read a 2d vector written by saveVector2D() from filestream.private voidreadVector1D(Vector<Integer> result, BufferedReader br) Read a 1d vector written by saveVector1D() from filestream.private voidreadVector2D(Vector<Vector<Integer>> result, BufferedReader br) Read a 2d vector written by saveVector2D() from filestream.private introundToNextMultiple(int value, int multiple) voidActually runs the algorithm.private voidsaveBVector1D(Vector<Boolean> vector, BufferedWriter bw) Write a 1d vector to filestream.private voidsaveDVector1D(Vector<Double> vector, BufferedWriter bw) Write a 1d vector to filestream.private voidsaveDVector2D(Vector<Vector<Double>> vector, BufferedWriter bw) Write a 2d vector to filestream.private voidsaveVector1D(Vector<Integer> vector, BufferedWriter bw) Write a 1d vector to filestream.private voidsaveVector2D(Vector<Vector<Integer>> vector, BufferedWriter bw) Write a 2d vector to filestream.private voidprivate voidshuffleAndSplit(Vector<Integer> first_part, Vector<Integer> second_part, int n_all, int n_first, Random random) private voidshuffleAndSplitAppend(Vector<Integer> first_part, Vector<Integer> second_part, int n_all, int n_first, Vector<Integer> mapping, Random random) private voidsplitString(Vector<String> result, String input, String split_string) private StringuintToString(int number) Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpenedMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
mask
static final int[] mask -
offset
static final int[] offset -
DEFAULT_NUM_TREE
final int DEFAULT_NUM_TREE- See Also:
-
DEFAULT_NUM_THREADS
final int DEFAULT_NUM_THREADS- See Also:
-
DEFAULT_IMPORTANCE_MODE
-
DEFAULT_MIN_NODE_SIZE_CLASSIFICATION
final int DEFAULT_MIN_NODE_SIZE_CLASSIFICATION- See Also:
-
DEFAULT_MIN_NODE_SIZE_REGRESSION
final int DEFAULT_MIN_NODE_SIZE_REGRESSION- See Also:
-
DEFAULT_MIN_NODE_SIZE_SURVIVAL
final int DEFAULT_MIN_NODE_SIZE_SURVIVAL- See Also:
-
DEFAULT_MIN_NODE_SIZE_PROBABILITY
final int DEFAULT_MIN_NODE_SIZE_PROBABILITY- See Also:
-
DEFAULT_SPLITRULE
-
DEFAULT_ALPHA
final double DEFAULT_ALPHA- See Also:
-
DEFAULT_MINPROP
final double DEFAULT_MINPROP- See Also:
-
DEFAULT_PREDICTIONTYPE
-
DEFAULT_NUM_RANDOM_SPLITS
final int DEFAULT_NUM_RANDOM_SPLITS- See Also:
-
STATUS_INTERVAL
final double STATUS_INTERVAL- See Also:
-
Q_THRESHOLD
final double Q_THRESHOLD- See Also:
-
RAND_MAX
public static int RAND_MAX -
logprop
public static double logprop -
testUtility
private boolean testUtility -
testMain
private boolean testMain -
treetype
-
probability
private boolean probability -
verbose_out
private boolean verbose_out -
dependent_variable_name
-
memory_mode
-
input_file
-
mtry
private int mtry -
output_prefix
-
num_trees
private int num_trees -
seed
private long seed -
num_threads
private int num_threads -
load_forest_filename
-
importance_mode
-
min_node_size
private int min_node_size -
split_select_weights_file
-
always_split_variable_names
-
status_variable_name
-
sample_with_replacement
private boolean sample_with_replacement -
unordered_variable_names
-
memory_saving_splitting
private boolean memory_saving_splitting -
splitrule
-
case_weights_file
-
predict_all
private boolean predict_all -
sample_fraction
private double sample_fraction -
alpha
private double alpha -
minprop
private double minprop -
holdout
private boolean holdout -
prediction_type
-
num_random_splits
private int num_random_splits -
write
private boolean write
-
-
Constructor Details
-
StochasticForests
public StochasticForests() -
StochasticForests
public StochasticForests(StochasticForests.TreeType treetype, boolean probability, boolean verbose_out, String dependent_variable_name, StochasticForests.MemoryMode memory_mode, String input_file, int mtry, String output_prefix, int num_trees, long seed, int num_threads, String load_forest_filename, StochasticForests.ImportanceMode importance_mode, int min_node_size, String split_select_weights_file, Vector<String> always_split_variable_names, String status_variable_name, boolean sample_with_replacement, Vector<String> unordered_variable_names, boolean memory_saving_splitting, StochasticForests.SplitRule splitrule, String case_weights_file, boolean predict_all, double sample_fraction, double alpha, double minprop, boolean holdout, StochasticForests.PredictionType prediction_type, int num_random_splits, boolean write)
-
-
Method Details
-
order
-
rank
Sample ranks starting from 1. Ties are given the average rank.- Parameters:
values- Values to rank- Returns:
- Ranks of input values
-
roundToNextMultiple
private int roundToNextMultiple(int value, int multiple) -
shuffle
-
equalSplit
-
loadDoubleVectorFromFile
-
drawWithoutReplacementSkip
-
drawWithoutReplacementSimple
-
drawWithoutReplacementFisherYates
-
drawWithoutReplacementWeighted
-
drawWithoutReplacementWeighted
-
mostFrequentClass
Returns the most frequent class index of a vector with counts for the classes. Returns a random class if counts are equal.- Parameters:
class_count- Vector with class countsrandom_number_generator- Random number generator- Returns:
- Most frequent class index. Out of range index if all 0.
-
mostFrequentDClass
Returns the most frequent class index of a vector with counts for the classes. Returns a random class if counts are equal.- Parameters:
class_count- Vector with class countsrandom_number_generator- Random number generator- Returns:
- Most frequent class index. Out of range index if all 0.
-
mostFrequentValue
-
computeConcordanceIndex
private double computeConcordanceIndex(StochasticForests.Data data, Vector<Double> sum_chf, int dependent_varID, int status_varID, Vector<Integer> sample_IDs) -
uintToString
-
beautifyTime
-
splitString
-
shuffleAndSplit
-
shuffleAndSplitAppend
-
checkUnorderedVariables
private String checkUnorderedVariables(StochasticForests.Data data, Vector<String> unordered_variable_names) -
checkPositiveIntegers
-
maxstatPValueLau92
private double maxstatPValueLau92(double b, double minprop, double maxprop) -
maxstatPValueLau94
-
maxstatPValueUnadjusted
private double maxstatPValueUnadjusted(double b) -
dstdnorm
private double dstdnorm(double x) -
pstdnorm
private double pstdnorm(double x) -
erf
private double erf(double x) -
adjustPvalues
-
logrankScores
-
maxstat
-
numSamplesLeftOfCutpoint
-
saveVector1D
Write a 1d vector to filestream. First the size is written, then all vector elements.- Parameters:
vector- Vector of type T to savefile- ofstream object to write to.
-
saveBVector1D
Write a 1d vector to filestream. First the size is written, then all vector elements.- Parameters:
vector- Vector of type T to savefile- ofstream object to write to.
-
readVector1D
Read a 1d vector written by saveVector1D() from filestream.- Parameters:
result- Result vector with elements of type T.file- ifstream object to read from.
-
readBVector1D
Read a 1d vector written by saveVector1D() from filestream.- Parameters:
result- Result vector with elements of type T.file- ifstream object to read from.
-
saveDVector1D
Write a 1d vector to filestream. First the size is written, then all vector elements.- Parameters:
vector- Vector of type T to savefile- ofstream object to write to.
-
readDVector1D
Read a 1d vector written by saveVector1D() from filestream.- Parameters:
result- Result vector with elements of type T.file- ifstream object to read from.
-
saveVector2D
Write a 2d vector to filestream. First the size of the first dim is written as size_t, then for all inner vectors the size and elements.- Parameters:
vector- Vector of vectors of type T to write to file.file- ofstream object to write to.
-
readVector2D
Read a 2d vector written by saveVector2D() from filestream.- Parameters:
result- Result vector of vectors with elements of type T.file- ifstream object to read from.
-
saveDVector2D
Write a 2d vector to filestream. First the size of the first dim is written as size_t, then for all inner vectors the size and elements.- Parameters:
vector- Vector of vectors of type T to write to file.file- ofstream object to write to.
-
readDVector2D
Read a 2d vector written by saveVector2D() from filestream.- Parameters:
result- Result vector of vectors with elements of type T.file- ifstream object to read from.
-
equalVectorInteger
-
equalVectorVectorInteger
-
equalVectorDouble
-
equalVectorVectorDouble
-
expectNear
-
runAlgorithm
public void runAlgorithm()Description copied from class:AlgorithmBaseActually runs the algorithm. Implemented by inheriting algorithms.- Specified by:
runAlgorithmin classAlgorithmBase
-