Package oracle.pgx.api.mllib
Class SupervisedEdgeWiseModel
- java.lang.Object
-
- oracle.pgx.api.mllib.Model<ModelType>
-
- oracle.pgx.api.mllib.EdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
-
- oracle.pgx.api.mllib.SupervisedEdgeWiseModel
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class SupervisedEdgeWiseModel extends EdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
A variant of GraphSAGE working on edges. SeeSupervisedEdgeWiseModelBuilder
for documentation of the hyperparameters.- Since:
- 23.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SupervisedEdgeWiseModel.SupervisedEdgeWiseInferenceType
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALGORITHM_NAME
-
Constructor Summary
Constructors Constructor Description SupervisedEdgeWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, java.util.function.Supplier<java.lang.String> keystorePathSupplier, java.util.function.Supplier<char[]> keystorePasswordSupplier, java.util.function.BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.ModelMetadata modelMetadata)
SupervisedEdgeWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, java.util.function.Supplier<java.lang.String> keystorePathSupplier, java.util.function.Supplier<char[]> keystorePasswordSupplier, java.util.function.BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata modelMetadata)
This constructor should never be used to get a model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PgxFrame
evaluate(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofevaluateAsync(PgxGraph, Iterable)
.PgxFrame
evaluate(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofevaluateAsync(PgxGraph, Iterable, float)
.PgxFuture<PgxFrame>
evaluateAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Evaluates performance statistics for the specified edges.PgxFuture<PgxFrame>
evaluateAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Evaluates performance statistics for the specified vertices.PgxFrame
evaluateLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofevaluateLabelsAsync(PgxGraph, Iterable)
.PgxFrame
evaluateLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofevaluateLabelsAsync(PgxGraph, Iterable, float)
.PgxFuture<PgxFrame>
evaluateLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Evaluates (macro averaged) classification performance statistics for the specified edges.PgxFuture<PgxFrame>
evaluateLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Evaluates (macro averaged) classification performance statistics for the specified vertices.PgxFuture<java.lang.Double>
fitAsync(PgxGraph graph)
Trains the EdgeWise model on the input graph.PgxFuture<java.lang.Double>
fitAsync(PgxGraph trainGraph, PgxGraph valGraph)
Trains the EdgeWise model on the input trainGraph and evaluate on the input valGraph.java.util.Map<?,java.lang.Float>
getClassWeights()
Gets the class weightsjava.lang.String
getEdgeTargetPropertyName()
Gets the edge target property nameLossFunction
getLossFunctionClass()
Gets the loss functionGraphWisePredictionLayerConfig[]
getPredictionLayerConfigs()
Gets the configuration objects for the prediction layersjava.util.List<java.util.Set<java.lang.String>>
getTargetEdgeLabels()
Gets the target vertex labelsPgxFuture<PgxFrame>
getTrainingLogAsync()
Gets the training log that has evaluation results from validation.PgxFrame
infer(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferAsync(PgxGraph, Iterable)
.PgxFrame
infer(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofinferAsync(PgxGraph, Iterable, float)
.PgxFuture<PgxFrame>
inferAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Does inference for the specified edges.PgxFuture<PgxFrame>
inferAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Does the inference for the specified edges.PgxFuture<PgxFrame>
inferEmbeddingsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the embeddings for the specified edges.PgxFrame
inferLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferLabelsAsync(PgxGraph, Iterable)
.PgxFrame
inferLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofinferLabelsAsync(PgxGraph, Iterable, float)
.PgxFuture<PgxFrame>
inferLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the labels for the specified edges.PgxFuture<PgxFrame>
inferLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Infers the labels for the specified edges.PgxFrame
inferLogits(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferLogitsAsync(PgxGraph, Iterable)
.PgxFuture<PgxFrame>
inferLogitsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the prediction logits for the specified edges.void
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 GraphWise model in the specified path, with encryption.PgxFuture<java.lang.Void>
storeAsync(java.lang.String path, java.lang.String key, boolean overwrite)
Stores the GraphWise model in the specified path, with encryption.-
Methods inherited from class oracle.pgx.api.mllib.EdgeWiseModel
destroy, destroyAsync, fit, fit, getBatchSize, getConfig, getConvLayerConfigs, getEdgeCombinationMethod, getEdgeInputFeatureDim, getEdgeInputPropertyNames, getEmbeddingDim, getInputFeatureDim, getLearningRate, getNumEpochs, getSeed, getTrainingLog, getTrainingLoss, getVertexInputPropertyNames, inferEmbeddings, isFitted
-
-
-
-
Field Detail
-
ALGORITHM_NAME
public static final java.lang.String ALGORITHM_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SupervisedEdgeWiseModel
public SupervisedEdgeWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, java.util.function.Supplier<java.lang.String> keystorePathSupplier, java.util.function.Supplier<char[]> keystorePasswordSupplier, java.util.function.BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata modelMetadata)
This constructor should never be used to get a model. UseSupervisedEdgeWiseModelBuilder
instead.- Parameters:
session
- PgxSession to which the model is connectedcore
- Core to which the model is connectedgraphConstructor
- Constructor for a PgxGraphmodelMetadata
- Metadata concerning the different hyper-parameters of the EdgeWise Model- Since:
- 23.1
-
SupervisedEdgeWiseModel
public SupervisedEdgeWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, java.util.function.Supplier<java.lang.String> keystorePathSupplier, java.util.function.Supplier<char[]> keystorePasswordSupplier, java.util.function.BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.ModelMetadata modelMetadata)
-
-
Method Detail
-
fitAsync
public PgxFuture<java.lang.Double> fitAsync(PgxGraph graph)
Trains the EdgeWise model on the input graph.- Specified by:
fitAsync
in classEdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
- Parameters:
graph
- input graph to fit on.- Since:
- 23.1
-
fitAsync
public PgxFuture<java.lang.Double> fitAsync(PgxGraph trainGraph, PgxGraph valGraph)
Trains the EdgeWise model on the input trainGraph and evaluate on the input valGraph.- Specified by:
fitAsync
in classEdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
- Parameters:
trainGraph
- input train graph to fit on.valGraph
- input graph to evaluate on for validation.- Since:
- 24.2
-
getTrainingLogAsync
public PgxFuture<PgxFrame> getTrainingLogAsync()
Gets the training log that has evaluation results from validation. It is available only after the model was trained with validation.- Specified by:
getTrainingLogAsync
in classEdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
- Returns:
- training log
- Since:
- 24.2
-
inferEmbeddingsAsync
public PgxFuture<PgxFrame> inferEmbeddingsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the embeddings for the specified edges.- Specified by:
inferEmbeddingsAsync
in classEdgeWiseModel<SupervisedEdgeWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedEdgeWiseModelMetadata,SupervisedEdgeWiseModel>
- Parameters:
graph
- the input graphedges
- the edges to produce embeddings to- Returns:
- PgxFrame containing the embeddings for each edge.
- Since:
- 23.1
-
inferLogitsAsync
public PgxFuture<PgxFrame> inferLogitsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the prediction logits for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to produce logits for- Returns:
- PgxFrame containing the logits for each edge.
- Since:
- 23.1
-
inferLogits
public PgxFrame inferLogits(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferLogitsAsync(PgxGraph, Iterable)
. Infers the prediction logits for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to produce logits for- Returns:
- PgxFrame containing the logits for each vertex.
- Since:
- 23.1
-
inferLabelsAsync
public PgxFuture<PgxFrame> inferLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Infers the labels for the specified edges.- Parameters:
graph
- the input graphedges
- the vertices to produce labels to- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
inferLabelsAsync
public PgxFuture<PgxFrame> inferLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Infers the labels for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to produce labels forthreshold
- decision threshold for classification (unused for regression)- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
evaluateLabelsAsync
public PgxFuture<PgxFrame> evaluateLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Evaluates (macro averaged) classification performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model on- Returns:
- PgxFrame containing the metrics
- Since:
- 23.1
-
evaluateLabelsAsync
public PgxFuture<PgxFrame> evaluateLabelsAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Evaluates (macro averaged) classification performance statistics for the specified vertices.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model onthreshold
- decision threshold for classification (unused for regression)- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
inferLabels
public PgxFrame inferLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferLabelsAsync(PgxGraph, Iterable)
. Infers the labels for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to produce labels for- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
inferLabels
public PgxFrame inferLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofinferLabelsAsync(PgxGraph, Iterable, float)
. Infers the labels for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to produce labels tothreshold
- decision threshold- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
evaluateLabels
public PgxFrame evaluateLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofevaluateLabelsAsync(PgxGraph, Iterable)
. Evaluates (macro averaged) classification performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model on- Returns:
- PgxFrame containing the metrics
- Since:
- 23.1
-
evaluateLabels
public PgxFrame evaluateLabels(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofevaluateLabelsAsync(PgxGraph, Iterable, float)
. Evaluates (macro averaged) classification performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model onthreshold
- decision threshold- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
inferAsync
public PgxFuture<PgxFrame> inferAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Does inference for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to do inference to- Returns:
- PgxFrame containing the inference for each edge.
- Since:
- 23.1
-
inferAsync
public PgxFuture<PgxFrame> inferAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Does the inference for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to do inference forthreshold
- decision threshold for classification (unused for regression)- Returns:
- PgxFrame containing the inference for each edge.
- Since:
- 23.1
-
evaluateAsync
public PgxFuture<PgxFrame> evaluateAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Evaluates performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model on- Returns:
- PgxFrame containing the metrics
- Since:
- 23.1
-
evaluateAsync
public PgxFuture<PgxFrame> evaluateAsync(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Evaluates performance statistics for the specified vertices.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model onthreshold
- decision threshold for classification (unused for regression)- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
infer
public PgxFrame infer(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofinferAsync(PgxGraph, Iterable)
. Does inference for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to do inference for- Returns:
- PgxFrame containing the inference for each edge.
- Since:
- 23.1
-
infer
public PgxFrame infer(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofinferAsync(PgxGraph, Iterable, float)
. Does inference for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to do inference tothreshold
- decision threshold- Returns:
- PgxFrame containing the inference for each edge.
- Since:
- 23.1
-
evaluate
public PgxFrame evaluate(PgxGraph graph, java.lang.Iterable<PgxEdge> edges)
Blocking version ofevaluateAsync(PgxGraph, Iterable)
. Evaluates performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model on- Returns:
- PgxFrame containing the metrics
- Since:
- 23.1
-
evaluate
public PgxFrame evaluate(PgxGraph graph, java.lang.Iterable<PgxEdge> edges, float threshold)
Blocking version ofevaluateAsync(PgxGraph, Iterable, float)
. Evaluates performance statistics for the specified edges.- Parameters:
graph
- the input graphedges
- the edges to evaluate the model onthreshold
- decision threshold- Returns:
- PgxFrame containing the labels for each edge.
- Since:
- 23.1
-
storeAsync
public PgxFuture<java.lang.Void> storeAsync(java.lang.String path, java.lang.String key) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Stores the GraphWise 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.- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
- Since:
- 23.1
-
storeAsync
public PgxFuture<java.lang.Void> storeAsync(java.lang.String path, java.lang.String key, boolean overwrite)
Stores the GraphWise 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.- Since:
- 23.1
-
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.- Since:
- 23.1
-
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.- Since:
- 23.1
-
getLossFunctionClass
public LossFunction getLossFunctionClass()
Gets the loss function- Returns:
- loss function
- Since:
- 23.1
-
getPredictionLayerConfigs
public GraphWisePredictionLayerConfig[] getPredictionLayerConfigs()
Gets the configuration objects for the prediction layers- Returns:
- configurations
- Since:
- 23.1
-
getClassWeights
public java.util.Map<?,java.lang.Float> getClassWeights()
Gets the class weights- Returns:
- class weights
- Since:
- 23.1
-
getEdgeTargetPropertyName
public java.lang.String getEdgeTargetPropertyName()
Gets the edge target property name- Returns:
- edge target property name
-
getTargetEdgeLabels
public java.util.List<java.util.Set<java.lang.String>> getTargetEdgeLabels()
Gets the target vertex labels- Returns:
- target vertex labels
- Since:
- 23.1
-
-