Class Pg2vecModel

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Pg2vecModel
    extends Model<Pg2vecModel>
    • Constructor Detail

      • Pg2vecModel

        public Pg2vecModel​(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.Pg2vecModelMetadata modelMetadata)
        Please do not use; only meant for being used by PGX itself. Use Analyst.pg2vecModelBuilder() to get a model builder and then create a model, or load a model with oracle.pgx.api.Analyst#loadPg2vecModel(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 Pg2vec Model
      • Pg2vecModel

        public Pg2vecModel​(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 Pg2vec 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.
      • computeSimilarsAsync

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

        public PgxFrame computeSimilars​(java.lang.Object graphletId,
                                        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> graphletIdObjects,
                                                        int k)
        Computes the top-k similar graphlets for a list of input graphlets
        Parameters:
        graphletIdObjects - list of ids of graphlets for which to compute the similar graphlets
        k - number of similars to return
        Returns:
        PgxFrame containing the top-k similar graphlets for the list of input graphlets
      • computeSimilars

        public PgxFrame computeSimilars​(java.util.List<java.lang.Object> graphletIds,
                                        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.
      • inferGraphletVectorAsync

        public PgxFuture<PgxFrame> inferGraphletVectorAsync​(PgxGraph graph)
        Infers the vector of the input graphlet
        Parameters:
        graph - graphlet for which to infer a vector
        Returns:
        PgxFrame containing the inferred vector
      • inferGraphletVector

        public PgxFrame inferGraphletVector​(PgxGraph graph)
                                     throws java.util.concurrent.ExecutionException,
                                            java.lang.InterruptedException
        Blocking version of inferGraphletVectorAsync(PgxGraph). Calls inferGraphletVectorAsync(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.
      • inferGraphletVectorBatchedAsync

        public PgxFuture<PgxFrame> inferGraphletVectorBatchedAsync​(PgxGraph graph)
        Infers the vectors of the input graphlets
        Parameters:
        graph - graphlets (as a single graph but different graphlet-id) for which to infer vectors
        Returns:
        PgxFrame containing the inferred vectors
      • inferGraphletVectorBatched

        public PgxFrame inferGraphletVectorBatched​(PgxGraph graph)
                                            throws java.util.concurrent.ExecutionException,
                                                   java.lang.InterruptedException
        Blocking version of inferGraphletVectorBatchedAsync(PgxGraph). Calls inferGraphletVectorBatchedAsync(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.
      • getTrainedGraphletVectorsAsync

        public PgxFuture<PgxFrame> getTrainedGraphletVectorsAsync()
        Gets the trained graphlet vectors for the current pg2vec model
        Returns:
        PgxFrame containing the trained graphlet vectors
      • getTrainedGraphletVectors

        public PgxFrame getTrainedGraphletVectors()
                                           throws java.util.concurrent.ExecutionException,
                                                  java.lang.InterruptedException
        Blocking version of getTrainedGraphletVectorsAsync(). Calls getTrainedGraphletVectorsAsync() 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 Pg2vec 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 Pg2vec 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 Pg2vec model
        Specified by:
        destroyAsync in class Model<Pg2vecModel>
        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.
      • getGraphLetIdPropertyName

        public java.lang.String getGraphLetIdPropertyName()
        Gets the property name of the graphlet-id in the input graph
        Returns:
        property name of the graphlet-id in the input graph
      • getVertexPropertyNames

        public java.util.Collection<java.lang.String> getVertexPropertyNames()
        Gets the property names to consider for pg2vec model training
        Returns:
        property names to consider for pg2vec model training
      • getMinWordFrequency

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

        public java.lang.Boolean getUseGraphletSize()
        Gets whether the model uses the graphlet size
        Returns:
        whether the model uses the graphlet size
      • 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
      • getGraphletSizePropertyName

        public java.lang.String getGraphletSizePropertyName()
        Gets the property-name for component size (used by default)
        Returns:
        the property-name for component size (used by default)
      • 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