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

public class StochasticForests extends AlgorithmBase
  • 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

      final StochasticForests.ImportanceMode 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

      final StochasticForests.SplitRule DEFAULT_SPLITRULE
    • DEFAULT_ALPHA

      final double DEFAULT_ALPHA
      See Also:
    • DEFAULT_MINPROP

      final double DEFAULT_MINPROP
      See Also:
    • DEFAULT_PREDICTIONTYPE

      final StochasticForests.PredictionType 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

      private StochasticForests.TreeType treetype
    • probability

      private boolean probability
    • verbose_out

      private boolean verbose_out
    • dependent_variable_name

      private String dependent_variable_name
    • memory_mode

      private StochasticForests.MemoryMode memory_mode
    • input_file

      private String input_file
    • mtry

      private int mtry
    • output_prefix

      private String output_prefix
    • num_trees

      private int num_trees
    • seed

      private long seed
    • num_threads

      private int num_threads
    • load_forest_filename

      private String load_forest_filename
    • importance_mode

      private StochasticForests.ImportanceMode importance_mode
    • min_node_size

      private int min_node_size
    • split_select_weights_file

      private String split_select_weights_file
    • always_split_variable_names

      private Vector<String> always_split_variable_names
    • status_variable_name

      private String status_variable_name
    • sample_with_replacement

      private boolean sample_with_replacement
    • unordered_variable_names

      private Vector<String> unordered_variable_names
    • memory_saving_splitting

      private boolean memory_saving_splitting
    • splitrule

      private StochasticForests.SplitRule splitrule
    • case_weights_file

      private String 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

      private StochasticForests.PredictionType prediction_type
    • num_random_splits

      private int num_random_splits
    • write

      private boolean write
  • Constructor Details

  • Method Details

    • order

      private Vector<Integer> order(Vector<Double> x, boolean decreasing)
    • rank

      Vector<Double> rank(Vector<Double> values)
      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

      private void shuffle(Vector<Integer> v, Random random)
    • equalSplit

      private void equalSplit(Vector<Integer> result, int start, int end, int num_parts)
    • loadDoubleVectorFromFile

      void loadDoubleVectorFromFile(Vector<Double> result, String filename)
    • drawWithoutReplacementSkip

      private void drawWithoutReplacementSkip(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples)
    • drawWithoutReplacementSimple

      private void drawWithoutReplacementSimple(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples)
    • drawWithoutReplacementFisherYates

      private void drawWithoutReplacementFisherYates(Vector<Integer> result, Random random, int max, Vector<Integer> skip, int num_samples)
    • drawWithoutReplacementWeighted

      private void drawWithoutReplacementWeighted(Vector<Integer> result, Random random, Vector<Integer> indices, int num_samples, Vector<Double> weights)
    • drawWithoutReplacementWeighted

      private void drawWithoutReplacementWeighted(Vector<Integer> result, Random random, int max_index, int num_samples, Vector<Double> weights)
    • mostFrequentClass

      private int mostFrequentClass(Vector<Integer> class_count, Random random)
      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 counts
      random_number_generator - Random number generator
      Returns:
      Most frequent class index. Out of range index if all 0.
    • mostFrequentDClass

      private int mostFrequentDClass(Vector<Double> class_count, Random random)
      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 counts
      random_number_generator - Random number generator
      Returns:
      Most frequent class index. Out of range index if all 0.
    • mostFrequentValue

      private double mostFrequentValue(HashMap<Double,Integer> class_count, Random random)
    • computeConcordanceIndex

      private double computeConcordanceIndex(StochasticForests.Data data, Vector<Double> sum_chf, int dependent_varID, int status_varID, Vector<Integer> sample_IDs)
    • uintToString

      private String uintToString(int number)
    • beautifyTime

      private String beautifyTime(int seconds)
    • splitString

      private void splitString(Vector<String> result, String input, String split_string)
    • shuffleAndSplit

      private void shuffleAndSplit(Vector<Integer> first_part, Vector<Integer> second_part, int n_all, int n_first, Random random)
    • shuffleAndSplitAppend

      private void shuffleAndSplitAppend(Vector<Integer> first_part, Vector<Integer> second_part, int n_all, int n_first, Vector<Integer> mapping, Random random)
    • checkUnorderedVariables

      private String checkUnorderedVariables(StochasticForests.Data data, Vector<String> unordered_variable_names)
    • checkPositiveIntegers

      private boolean checkPositiveIntegers(Vector<Double> all_values)
    • maxstatPValueLau92

      private double maxstatPValueLau92(double b, double minprop, double maxprop)
    • maxstatPValueLau94

      private double maxstatPValueLau94(double b, double minprop, double maxprop, int N, Vector<Integer> m)
    • 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

      private Vector<Double> adjustPvalues(Vector<Double> unadjusted_pvalues)
    • logrankScores

      private Vector<Double> logrankScores(Vector<Double> time, Vector<Double> status)
    • maxstat

      private void maxstat(Vector<Double> scores, Vector<Double> x, Vector<Integer> indices, double[] best_maxstat, double[] best_split_value, double minprop, double maxprop)
    • numSamplesLeftOfCutpoint

      private Vector<Integer> numSamplesLeftOfCutpoint(Vector<Double> x, Vector<Integer> indices)
    • saveVector1D

      private void saveVector1D(Vector<Integer> vector, BufferedWriter bw)
      Write a 1d vector to filestream. First the size is written, then all vector elements.
      Parameters:
      vector - Vector of type T to save
      file - ofstream object to write to.
    • saveBVector1D

      private void saveBVector1D(Vector<Boolean> vector, BufferedWriter bw)
      Write a 1d vector to filestream. First the size is written, then all vector elements.
      Parameters:
      vector - Vector of type T to save
      file - ofstream object to write to.
    • readVector1D

      private void readVector1D(Vector<Integer> result, BufferedReader br)
      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

      private void readBVector1D(Vector<Boolean> result, BufferedReader br)
      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

      private void saveDVector1D(Vector<Double> vector, BufferedWriter bw)
      Write a 1d vector to filestream. First the size is written, then all vector elements.
      Parameters:
      vector - Vector of type T to save
      file - ofstream object to write to.
    • readDVector1D

      private void readDVector1D(Vector<Double> result, BufferedReader br)
      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

      private void saveVector2D(Vector<Vector<Integer>> vector, BufferedWriter bw)
      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

      private void readVector2D(Vector<Vector<Integer>> result, BufferedReader br)
      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

      private void saveDVector2D(Vector<Vector<Double>> vector, BufferedWriter bw)
      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

      private void readDVector2D(Vector<Vector<Double>> result, BufferedReader br)
      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

      private boolean equalVectorInteger(Vector<Integer> v1, Vector<Integer> v2, String str)
    • equalVectorVectorInteger

      private boolean equalVectorVectorInteger(Vector<Vector<Integer>> v1, Vector<Vector<Integer>> v2, String str)
    • equalVectorDouble

      private boolean equalVectorDouble(Vector<Double> v1, Vector<Double> v2, String str)
    • equalVectorVectorDouble

      private boolean equalVectorVectorDouble(Vector<Vector<Double>> v1, Vector<Vector<Double>> v2, String str)
    • expectNear

      private boolean expectNear(double val1, double val2, double error, String str)
    • runAlgorithm

      public void runAlgorithm()
      Description copied from class: AlgorithmBase
      Actually runs the algorithm. Implemented by inheriting algorithms.
      Specified by:
      runAlgorithm in class AlgorithmBase