Package oracle.pgx.api.mllib
Class Pg2vecModel
- java.lang.Object
-
- oracle.pgx.api.mllib.Model<Pg2vecModel>
-
- oracle.pgx.api.mllib.Pg2vecModel
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Pg2vecModel extends Model<Pg2vecModel>
-
-
Constructor Summary
Constructors Constructor Description 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)
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PgxFrame
computeSimilars(java.lang.Object graphletId, int k)
Blocking version ofcomputeSimilarsAsync(Object, int)
.PgxFrame
computeSimilars(java.util.List<java.lang.Object> graphletIds, int k)
Blocking version ofcomputeSimilarsAsync(List, int)
.PgxFuture<PgxFrame>
computeSimilarsAsync(java.lang.Object graphletIdObject, int k)
Computes the top-k similar graphlets for a given graphletPgxFuture<PgxFrame>
computeSimilarsAsync(java.util.List<java.lang.Object> graphletIdObjects, int k)
Computes the top-k similar graphlets for a list of input graphletsvoid
destroy()
Blocking version ofdestroyAsync()
.PgxFuture<java.lang.Void>
destroyAsync()
Destroys a pre-trained Pg2vec modelvoid
fit(PgxGraph graph)
Blocking version offitAsync(PgxGraph)
.PgxFuture<java.lang.Void>
fitAsync(PgxGraph graph)
Trains the Pg2vec model on the input graphint
getBatchSize()
Gets the batch size of the modeljava.lang.String
getGraphLetIdPropertyName()
Gets the property name of the graphlet-id in the input graphjava.lang.String
getGraphletSizePropertyName()
Gets the property-name for component size (used by default)int
getLayerSize()
Gets the number of dimensions for the output vectorsdouble
getLearningRate()
Gets the initial learning ratedouble
getLoss()
Gets the loss value during trainingdouble
getMinLearningRate()
Gets the minimum learning rateint
getMinWordFrequency()
Gets the minimum word frequency to consider before pruningint
getNumEpochs()
Gets the number of epochs to train the modeldouble
getSeed()
Gets the random seedPgxFrame
getTrainedGraphletVectors()
Blocking version ofgetTrainedGraphletVectorsAsync()
.PgxFuture<PgxFrame>
getTrainedGraphletVectorsAsync()
Gets the trained graphlet vectors for the current pg2vec modeljava.lang.Boolean
getUseGraphletSize()
Gets whether the model uses the graphlet sizejava.util.Collection<java.lang.String>
getVertexPropertyNames()
Gets the property names to consider for pg2vec model trainingint
getWalkLength()
Gets the length of the walksint
getWalksPerVertex()
Gets the number of walks to consider per vertexint
getWindowSize()
Gets the window size to consider while training the modelPgxFrame
inferGraphletVector(PgxGraph graph)
Blocking version ofinferGraphletVectorAsync(PgxGraph)
.PgxFuture<PgxFrame>
inferGraphletVectorAsync(PgxGraph graph)
Infers the vector of the input graphletPgxFrame
inferGraphletVectorBatched(PgxGraph graph)
Blocking version ofinferGraphletVectorBatchedAsync(PgxGraph)
.PgxFuture<PgxFrame>
inferGraphletVectorBatchedAsync(PgxGraph graph)
Infers the vectors of the input graphletsboolean
isEnableAccelerator()
Gets if the model uses accelerator or notvoid
store(java.lang.String path, java.lang.String key)
Blocking version ofstoreAsync(String, String)
.void
store(java.lang.String path, java.lang.String key, boolean overwrite)
Blocking version ofstoreAsync(String, String)
.PgxFuture<java.lang.Void>
storeAsync(java.lang.String path, java.lang.String key)
Stores the Pg2vec model in the specified path, with encryption.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.
-
-
-
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. UseAnalyst.pg2vecModelBuilder()
to get a model builder and then create a model, or load a model withoracle.pgx.api.Analyst#loadPg2vecModel(String)
.- Parameters:
session
- PgxSession to which the model is connectedcore
- Core to which the model is connectedmodelMetadata
- 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 offitAsync(PgxGraph)
. CallsfitAsync(PgxGraph)
and waits for the returnedPgxFuture
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 graphletsk
- 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 ofcomputeSimilarsAsync(Object, int)
. CallscomputeSimilarsAsync(Object, int)
and waits for the returnedPgxFuture
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 graphletsk
- 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 ofcomputeSimilarsAsync(List, int)
. CallscomputeSimilarsAsync(List, int)
and waits for the returnedPgxFuture
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 ofinferGraphletVectorAsync(PgxGraph)
. CallsinferGraphletVectorAsync(PgxGraph)
and waits for the returnedPgxFuture
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 ofinferGraphletVectorBatchedAsync(PgxGraph)
. CallsinferGraphletVectorBatchedAsync(PgxGraph)
and waits for the returnedPgxFuture
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 ofgetTrainedGraphletVectorsAsync()
. CallsgetTrainedGraphletVectorsAsync()
and waits for the returnedPgxFuture
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 modelkey
- 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 modelkey
- 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 ofstoreAsync(String, String)
. CallsstoreAsync(String, String)
and waits for the returnedPgxFuture
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 ofstoreAsync(String, String)
. CallsstoreAsync(String, String)
and waits for the returnedPgxFuture
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 classModel<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 ofdestroyAsync()
. CallsdestroyAsync()
and waits for the returnedPgxFuture
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
-
-