Package oracle.pgx.api.mllib
Class DeepWalkModel
- java.lang.Object
-
- oracle.pgx.api.mllib.Model<DeepWalkModel>
-
- oracle.pgx.api.mllib.DeepWalkModel
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class DeepWalkModel extends Model<DeepWalkModel>
-
-
Constructor Summary
Constructors Constructor Description 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.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PgxFramecomputeSimilars(java.lang.Object vertexId, int k)Blocking version ofcomputeSimilarsAsync(Object, int).PgxFramecomputeSimilars(java.util.List<java.lang.Object> vertexIds, int k)Blocking version ofcomputeSimilarsAsync(List, int).PgxFuture<PgxFrame>computeSimilarsAsync(java.lang.Object vertexIdObject, int k)Computes the top-k similar vertices for a given vertexPgxFuture<PgxFrame>computeSimilarsAsync(java.util.List<java.lang.Object> vertexIdObjects, int k)Computes the top-k similar vertices for a list of input verticesvoiddestroy()Blocking version ofdestroyAsync().PgxFuture<java.lang.Void>destroyAsync()Destroys a pre-trained DeepWalk modelvoidfit(PgxGraph graph)Blocking version offitAsync(PgxGraph).PgxFuture<java.lang.Void>fitAsync(PgxGraph graph)Trains the DeepWalk model on the input graphintgetBatchSize()Gets the batch size of the modelintgetLayerSize()Gets the number of dimensions for the output vectorsdoublegetLearningRate()Gets the initial learning ratedoublegetLoss()Gets the loss value during trainingdoublegetMinLearningRate()Gets the minimum learning rateintgetMinWordFrequency()Gets the minimum word frequency to consider before pruningintgetNegativeSample()Gets the number of negative samplesintgetNumEpochs()Gets the number of epochs to train the modeldoublegetSampleRate()Gets the sampling ratedoublegetSeed()Gets the random seedPgxFramegetTrainedVertexVectors()Blocking version ofgetTrainedVertexVectorsAsync().PgxFuture<PgxFrame>getTrainedVertexVectorsAsync()Gets the trained vertex vectors for the current DeepWalk modelintgetWalkLength()Gets the length of the walksintgetWalksPerVertex()Gets the number of walks to consider per vertexintgetWindowSize()Gets the window size to consider while training the modelbooleanisEnableAccelerator()Gets if the model uses accelerator or notvoidstore(java.lang.String path, java.lang.String key)Blocking version ofstoreAsync(String, String).voidstore(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 DeepWalk model in the specified path, with encryption.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.
-
-
-
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. UseAnalyst.deepWalkModelBuilder()to get a model builder and then create a model, or load a model withAnalyst.loadDeepWalkModel(String, 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 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 offitAsync(PgxGraph). CallsfitAsync(PgxGraph)and waits for the returnedPgxFutureto 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 ofgetTrainedVertexVectorsAsync(). CallsgetTrainedVertexVectorsAsync()and waits for the returnedPgxFutureto 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 verticesk- 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 ofcomputeSimilarsAsync(Object, int). CallscomputeSimilarsAsync(Object, int)and waits for the returnedPgxFutureto 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 verticesk- 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 ofcomputeSimilarsAsync(List, int). CallscomputeSimilarsAsync(List, int)and waits for the returnedPgxFutureto 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 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 DeepWalk 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.InterruptedExceptionBlocking version ofstoreAsync(String, String). CallsstoreAsync(String, String)and waits for the returnedPgxFutureto 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.InterruptedExceptionBlocking version ofstoreAsync(String, String). CallsstoreAsync(String, String)and waits for the returnedPgxFutureto 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:
destroyAsyncin classModel<DeepWalkModel>- Returns:
- a future which will be completed once the destruction request finishes.
-
destroy
public void destroy() throws java.util.concurrent.ExecutionException, java.lang.InterruptedExceptionBlocking version ofdestroyAsync(). CallsdestroyAsync()and waits for the returnedPgxFutureto 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
-
-