Class DeepWalkModelBuilder


  • public class DeepWalkModelBuilder
    extends java.lang.Object
    Builder for a DeepWalk model. The builder can be used to set the configuration of the model and create the model object.
    • Constructor Detail

      • DeepWalkModelBuilder

        public DeepWalkModelBuilder​(PgxSession session,
                                    oracle.pgx.api.internal.Core core,
                                    java.util.function.Supplier<java.lang.String> keystorePathSupplier,
                                    java.util.function.Supplier<char[]> keystorePasswordSupplier)
        Please do not use; only meant for being used by PGX itself. Use Analyst.deepWalkModelBuilder() to get a model builder instead.
        Parameters:
        session - PgxSession to which the model is connected
        core - Core to which the model is connected
    • Method Detail

      • setMinWordFrequency

        public DeepWalkModelBuilder setMinWordFrequency​(int minWordFrequency)
        Sets the minimum word frequency to consider before pruning (default: 1)
        Parameters:
        minWordFrequency - minimum word frequency to consider before pruning
        Returns:
        builder
      • setShuffle

        public DeepWalkModelBuilder setShuffle​(boolean shuffle)
        Sets whether to shuffle the random walks before training on them
        Parameters:
        shuffle - whether to shuffle
        Returns:
        builder
      • isShuffle

        public boolean isShuffle()
        Gets whether the model will shuffle the shuffle the random walks before training on them
        Returns:
        whether the model will shuffle the random walks
      • getMinWordFrequency

        public int getMinWordFrequency()
        Gets the minimum word frequency to consider before pruning (default: 1)
        Returns:
        minimum word frequency to consider before pruning
      • setSeed

        public DeepWalkModelBuilder setSeed​(java.lang.Long seed)
        Sets the random seed for training the model. If set to null, execution will be non-deterministic.

        Note that setting the seed will limit the amount of threads during the learning phase to 1

        Parameters:
        seed - random seed for training the model
        Returns:
        builder
      • getSeed

        public java.lang.Long getSeed()
        Gets the random seed for training the model (default: null)
        Returns:
        seed random seed for training the model
      • setBatchSize

        public DeepWalkModelBuilder setBatchSize​(int batchSize)
        Sets the batch size for training the model (default: 128)
        Parameters:
        batchSize - batch size for training the model
        Returns:
        builder
      • getBatchSize

        public int getBatchSize()
        Gets the batch size for training the model (default: 128)
        Returns:
        batchSize batch size for training the model
      • setNumEpochs

        public DeepWalkModelBuilder setNumEpochs​(int numEpochs)
        Sets the number of epochs to train the model (default: 2)
        Parameters:
        numEpochs - number of epochs to train the model
        Returns:
        builder
      • getNumEpochs

        public int getNumEpochs()
        Gets the number of epochs to train the model (default: 2)
        Returns:
        number of epochs to train the model
      • setLayerSize

        public DeepWalkModelBuilder setLayerSize​(int layerSize)
        Sets the number of dimensions for the output vectors (default: 200)
        Parameters:
        layerSize - number of dimensions for the output vectors
        Returns:
        builder
      • getLayerSize

        public int getLayerSize()
        Gets the number of dimensions for the output vectors (default: 200)
        Returns:
        number of dimensions for the output vectors
      • setLearningRate

        public DeepWalkModelBuilder setLearningRate​(double lr)
        Sets the initial learning rate (default: 0.025)
        Parameters:
        lr - initial learning rate
        Returns:
        builder
      • getLearningRate

        public double getLearningRate()
        Gets the initial learning rate (default: 0.025)
        Returns:
        initial learning rate
      • setMinLearningRate

        public DeepWalkModelBuilder setMinLearningRate​(double minLr)
        Sets the minimum learning rate (default: 0.0001)
        Parameters:
        minLr - minimum learning rate
        Returns:
        builder
      • getMinLearningRate

        public double getMinLearningRate()
        Gets the minimum learning rate (default: 0.0001)
        Returns:
        minimum learning rate
      • setWindowSize

        public DeepWalkModelBuilder setWindowSize​(int windowSize)
        Sets the window size to consider while training the model (default: 5)
        Parameters:
        windowSize - window size to consider while training the model
        Returns:
        builder
      • getWindowSize

        public int getWindowSize()
        Gets the window size to consider while training the model (default: 5)
        Returns:
        window size to consider while training the model
      • setWalkLength

        public DeepWalkModelBuilder setWalkLength​(int walkLength)
        Sets the length of the walks (default: 5)
        Parameters:
        walkLength - length of the walks
        Returns:
        builder
      • getWalkLength

        public int getWalkLength()
        Gets the length of the walks (default: 5)
        Returns:
        length of the walks
      • setWalksPerVertex

        public DeepWalkModelBuilder setWalksPerVertex​(int walksPerVertex)
        Sets the number of walks to consider per vertex (default: 4)
        Parameters:
        walksPerVertex - number of walks to consider per vertex
        Returns:
        builder
      • getWalksPerVertex

        public int getWalksPerVertex()
        Gets the number of walks to consider per vertex (default: 4)
        Returns:
        number of walks to consider per vertex
      • setSampleRate

        public DeepWalkModelBuilder setSampleRate​(double sampleRate)
        Sets the sample rate (default: 0.0) Used to subsample frequent nodes. Nodes are sampled based on their relative frequency computed over all walks. The probability of keeping a node x is max(1.0, P(x) = (sqrt(xFrequency/ sampleRate) + 1) * sampleRate/xFrequency) Smaller values for sample rate mean frequent nodes become less likely to be retained in walks. No subsampling happens if sample rate is 0.0. Values for sample rate should be < 0.4 to have some effect.
        Parameters:
        sampleRate - the sampling rate
        Returns:
        builder
      • getSampleRate

        public double getSampleRate()
        Gets the sampling rate (default: 0.00001)
        Returns:
        the sampling rate
      • setNegativeSample

        public DeepWalkModelBuilder setNegativeSample​(int negativeSample)
        Sets the number of negative samples (default: 10)
        Parameters:
        negativeSample - the number of negative samples
        Returns:
        builder
      • getNegativeSample

        public int getNegativeSample()
        Gets the number of negative samples (default: 10)
        Returns:
        the number of negative samples
      • setIgnoreIsolated

        public DeepWalkModelBuilder setIgnoreIsolated​(boolean ignoreIsolated)
        Whether to ignore isolated vertices. If false, pseudo-walks will consisting of only the node itself will be inserted into the dataset (default: true).
        Parameters:
        ignoreIsolated - whether to ignore
        Returns:
        builder
      • isIgnoreIsolated

        public boolean isIgnoreIsolated()
        Gets whether the model ignores isolated vertices.
        Returns:
        whether the model ignores isolated vertices
      • setEnableAccelerator

        public DeepWalkModelBuilder setEnableAccelerator​(boolean enableAccelerator)
        If true, use the accelerator (GPU) if available as the machine learning backend.

        default: {true}

        Parameters:
        enableAccelerator - whether to use the accelerator if available
        Returns:
        this
        Since:
        24.1
      • build

        public DeepWalkModel build()
                            throws java.lang.InterruptedException,
                                   java.util.concurrent.ExecutionException
        Builds the DeepWalk model with the builder configuration
        Returns:
        DeepWalk model
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException