Class DeepWalkModel

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class DeepWalkModel
    extends Model<DeepWalkModel>
    • Constructor Detail

      • DeepWalkModel

        public DeepWalkModel​(PgxSession session,
                             oracle.pgx.api.internal.Core core,
                             java.util.function.Supplier<java.lang.String> keystorePathSupplier,
                             java.util.function.Supplier<char[]> keystorePasswordSupplier,
                             oracle.pgx.api.internal.mllib.DeepWalkModelMetadata modelMetadata)
        Please do not use; only meant for being used by PGX itself. Use Analyst.deepWalkModelBuilder() to get a model builder and then create a model, or load a model with Analyst.loadDeepWalkModel(String, String).
        Parameters:
        session - PgxSession to which the model is connected
        core - Core to which the model is connected
        modelMetadata - Metadata concerning the different hyper-parameters of the DeepWalk Model
      • DeepWalkModel

        public DeepWalkModel​(PgxSession session,
                             oracle.pgx.api.internal.Core core,
                             java.util.function.Supplier<java.lang.String> keystorePathSupplier,
                             java.util.function.Supplier<char[]> keystorePasswordSupplier,
                             oracle.pgx.api.internal.mllib.ModelMetadata modelMetadata)
    • Method Detail

      • fitAsync

        public PgxFuture<java.lang.Void> fitAsync​(PgxGraph graph)
        Trains the DeepWalk model on the input graph
        Parameters:
        graph - input graph to fit on
      • fit

        public void fit​(PgxGraph graph)
                 throws java.util.concurrent.ExecutionException,
                        java.lang.InterruptedException
        Blocking version of fitAsync(PgxGraph). Calls fitAsync(PgxGraph) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • getTrainedVertexVectorsAsync

        public PgxFuture<PgxFrame> getTrainedVertexVectorsAsync()
        Gets the trained vertex vectors for the current DeepWalk model
        Returns:
        PgxFrame containing the trained vertex vectors
      • getTrainedVertexVectors

        public PgxFrame getTrainedVertexVectors()
                                         throws java.util.concurrent.ExecutionException,
                                                java.lang.InterruptedException
        Blocking version of getTrainedVertexVectorsAsync(). Calls getTrainedVertexVectorsAsync() and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • computeSimilarsAsync

        public PgxFuture<PgxFrame> computeSimilarsAsync​(java.lang.Object vertexIdObject,
                                                        int k)
        Computes the top-k similar vertices for a given vertex
        Parameters:
        vertexIdObject - id of the vertex for which to compute the similar vertices
        k - number of similars to return
        Returns:
        PgxFrame containing the top-k similar vertices
      • computeSimilars

        public PgxFrame computeSimilars​(java.lang.Object vertexId,
                                        int k)
                                 throws java.util.concurrent.ExecutionException,
                                        java.lang.InterruptedException
        Blocking version of computeSimilarsAsync(Object, int). Calls computeSimilarsAsync(Object, int) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • computeSimilarsAsync

        public PgxFuture<PgxFrame> computeSimilarsAsync​(java.util.List<java.lang.Object> vertexIdObjects,
                                                        int k)
        Computes the top-k similar vertices for a list of input vertices
        Parameters:
        vertexIdObjects - list of ids of vertices for which to compute the similar vertices
        k - number of similars to return
        Returns:
        PgxFrame containing the top-k similar vertices for the list of input vertices
      • computeSimilars

        public PgxFrame computeSimilars​(java.util.List<java.lang.Object> vertexIds,
                                        int k)
                                 throws java.util.concurrent.ExecutionException,
                                        java.lang.InterruptedException
        Blocking version of computeSimilarsAsync(List, int). Calls computeSimilarsAsync(List, int) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • storeAsync

        public PgxFuture<java.lang.Void> storeAsync​(java.lang.String path,
                                                    java.lang.String key)
        Stores the DeepWalk model in the specified path, with encryption.
        Parameters:
        path - path to store the model
        key - the encryption key, or null if no encryption should be used.
      • storeAsync

        public PgxFuture<java.lang.Void> storeAsync​(java.lang.String path,
                                                    java.lang.String key,
                                                    boolean overwrite)
        Stores the DeepWalk model in the specified path, with encryption.
        Parameters:
        path - path to store the model
        key - the encryption key, or null if no encryption should be used.
      • store

        public void store​(java.lang.String path,
                          java.lang.String key)
                   throws java.util.concurrent.ExecutionException,
                          java.lang.InterruptedException
        Blocking version of storeAsync(String, String). Calls storeAsync(String, String) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • store

        public void store​(java.lang.String path,
                          java.lang.String key,
                          boolean overwrite)
                   throws java.util.concurrent.ExecutionException,
                          java.lang.InterruptedException
        Blocking version of storeAsync(String, String). Calls storeAsync(String, String) and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • destroyAsync

        public PgxFuture<java.lang.Void> destroyAsync()
        Destroys a pre-trained DeepWalk model
        Specified by:
        destroyAsync in class Model<DeepWalkModel>
        Returns:
        a future which will be completed once the destruction request finishes.
      • destroy

        public void destroy()
                     throws java.util.concurrent.ExecutionException,
                            java.lang.InterruptedException
        Blocking version of destroyAsync(). Calls destroyAsync() and waits for the returned PgxFuture to complete.
        Throws:
        java.lang.InterruptedException - if the caller thread gets interrupted while waiting for completion.
        java.util.concurrent.ExecutionException - if any exception occurred during asynchronous execution. The actual exception will be nested.
      • getNegativeSample

        public int getNegativeSample()
        Gets the number of negative samples
        Returns:
        the number of negative samples
      • getSampleRate

        public double getSampleRate()
        Gets the sampling rate
        Returns:
        the sampling rate
      • getMinWordFrequency

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

        public int getBatchSize()
        Gets the batch size of the model
        Returns:
        batchSize batch size ofthe model
      • getNumEpochs

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

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

        public double getLearningRate()
        Gets the initial learning rate
        Returns:
        initial learning rate
      • getMinLearningRate

        public double getMinLearningRate()
        Gets the minimum learning rate
        Returns:
        minimum learning rate
      • getWindowSize

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

        public int getWalkLength()
        Gets the length of the walks
        Returns:
        length of the walks
      • getWalksPerVertex

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

        public double getLoss()
        Gets the loss value during training
        Returns:
        loss value during training
      • getSeed

        public double getSeed()
        Gets the random seed
        Returns:
        seed
      • isEnableAccelerator

        public boolean isEnableAccelerator()
        Gets if the model uses accelerator or not
        Returns:
        whether the model uses accelerator