Class SupervisedGraphWiseModel

java.lang.Object
oracle.pgx.api.mllib.Model<ModelType>
oracle.pgx.api.mllib.GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
oracle.pgx.api.mllib.SupervisedGraphWiseModel
All Implemented Interfaces:
AutoCloseable

public class SupervisedGraphWiseModel extends GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
A variant of GraphSAGE. See SupervisedGraphWiseModelBuilder for documentation of the hyperparameters.
Since:
19.4
  • Field Details

  • Constructor Details

    • SupervisedGraphWiseModel

      public SupervisedGraphWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, Supplier<String> keystorePathSupplier, Supplier<char[]> keystorePasswordSupplier, BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata modelMetadata)
      This constructor should never be used to get a model. Use SupervisedGraphWiseModelBuilder instead.
      Parameters:
      session - PgxSession to which the model is connected
      core - Core to which the model is connected
      graphConstructor - Constructor for a PgxGraph
      modelMetadata - Metadata concerning the different hyper-parameters of the GraphWise Model
      Since:
      19.4
    • SupervisedGraphWiseModel

      public SupervisedGraphWiseModel(PgxSession session, oracle.pgx.api.internal.Core core, Supplier<String> keystorePathSupplier, Supplier<char[]> keystorePasswordSupplier, BiFunction<PgxSession,oracle.pgx.api.internal.Graph,PgxGraph> graphConstructor, oracle.pgx.api.internal.mllib.ModelMetadata modelMetadata)
  • Method Details

    • fitAsync

      public PgxFuture<Double> fitAsync(PgxGraph graph)
      Trains the GraphWise model on the input graph.
      Specified by:
      fitAsync in class GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
      Parameters:
      graph - input graph to fit on.
      Since:
      19.4
    • fitAsync

      public PgxFuture<Double> fitAsync(PgxGraph trainGraph, PgxGraph valGraph)
      Trains the GraphWise model on the input trainGraph and evaluate on the input valGraph.
      Specified by:
      fitAsync in class GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
      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 class GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
      Returns:
      training log
      Since:
      24.2
    • inferEmbeddingsAsync

      public <ID> PgxFuture<PgxFrame> inferEmbeddingsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Infers the embeddings for the specified vertices.
      Specified by:
      inferEmbeddingsAsync in class GraphWiseModel<SupervisedGraphWiseModelConfig,oracle.pgx.api.internal.mllib.SupervisedGraphWiseModelMetadata,SupervisedGraphWiseModel>
      Parameters:
      graph - the input graph
      vertices - the vertices to produce embeddings to
      Returns:
      PgxFrame containing the embeddings for each vertex.
      Since:
      19.4
    • inferLogitsAsync

      public <ID> PgxFuture<PgxFrame> inferLogitsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Infers the prediction logits for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce logits to
      Returns:
      PgxFrame containing the logits for each vertex.
      Since:
      19.4
    • inferLogits

      public <ID> PgxFrame inferLogits(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Blocking version of inferLogitsAsync(PgxGraph, Iterable). Infers the prediction logits for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce logits to
      Returns:
      PgxFrame containing the logits for each vertex.
      Since:
      19.4
    • inferLabelsAsync

      public <ID> PgxFuture<PgxFrame> inferLabelsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Infers the labels for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce labels to
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      19.4
    • inferLabelsAsync

      public <ID> PgxFuture<PgxFrame> inferLabelsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Infers the labels for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce labels to
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      21.4
    • evaluateLabelsAsync

      public <ID> PgxFuture<PgxFrame> evaluateLabelsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      Returns:
      PgxFrame containing the metrics
      Since:
      19.4
    • evaluateLabelsAsync

      public <ID> PgxFuture<PgxFrame> evaluateLabelsAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      threshold - the decision threshold
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      21.4
    • inferLabels

      public <ID> PgxFrame inferLabels(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Blocking version of inferLabelsAsync(PgxGraph, Iterable). Infers the labels for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce labels to
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      19.4
    • inferLabels

      public <ID> PgxFrame inferLabels(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Blocking version of inferLabelsAsync(PgxGraph, Iterable, float). Infers the labels for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to produce labels to
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      21.4
    • evaluateLabels

      public <ID> PgxFrame evaluateLabels(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Blocking version of evaluateLabelsAsync(PgxGraph, Iterable). Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      Returns:
      PgxFrame containing the metrics
      Since:
      19.4
    • evaluateLabels

      public <ID> PgxFrame evaluateLabels(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Blocking version of evaluateLabelsAsync(PgxGraph, Iterable, float). Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the labels for each vertex.
      Since:
      21.4
    • inferAsync

      public <ID> PgxFuture<PgxFrame> inferAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Does inference for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to do inference on
      Returns:
      PgxFrame containing the inference results for each vertex.
      Since:
      23.1
    • inferAsync

      public <ID> PgxFuture<PgxFrame> inferAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Does inference for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to do inference on
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the inference results for each vertex.
      Since:
      23.1
    • evaluateAsync

      public <ID> PgxFuture<PgxFrame> evaluateAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      Returns:
      PgxFrame containing the scores for each vertex.
      Since:
      23.1
    • evaluateAsync

      public <ID> PgxFuture<PgxFrame> evaluateAsync(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      threshold - decision threshold
      Returns:
      PgxFrame containing the scores for each vertex.
      Since:
      23.1
    • infer

      public <ID> PgxFrame infer(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Blocking version of inferAsync(PgxGraph, Iterable). Does inference for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to do inference on
      Returns:
      PgxFrame containing the inference results for each vertex.
      Since:
      23.1
    • infer

      public <ID> PgxFrame infer(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Blocking version of inferAsync(PgxGraph, Iterable). Does inference for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to do inference on
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the inference results for each vertex.
      Since:
      23.1
    • evaluate

      public <ID> PgxFrame evaluate(PgxGraph graph, Iterable<PgxVertex<ID>> vertices)
      Blocking version of evaluateAsync(PgxGraph, Iterable). Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      Returns:
      PgxFrame containing the metrics
      Since:
      23.1
    • evaluate

      public <ID> PgxFrame evaluate(PgxGraph graph, Iterable<PgxVertex<ID>> vertices, float threshold)
      Blocking version of evaluateAsync(PgxGraph, Iterable). Evaluates (macro averaged) classification performance statistics for the specified vertices.
      Parameters:
      graph - the input graph
      vertices - the vertices to evaluate the model on
      threshold - decision threshold for classification (unused for regression)
      Returns:
      PgxFrame containing the metrics
      Since:
      23.1
    • storeAsync

      public PgxFuture<Void> storeAsync(String path, String key) throws ExecutionException, InterruptedException
      Stores the GraphWise 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.
      Throws:
      ExecutionException
      InterruptedException
      Since:
      19.4
    • storeAsync

      public PgxFuture<Void> storeAsync(String path, String key, boolean overwrite)
      Stores the GraphWise 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.
      Since:
      21.1
    • store

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

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

      public LossFunction getLossFunctionClass()
      Gets the loss function
      Returns:
      loss function
      Since:
      21.4
    • getPredictionLayerConfigs

      public GraphWisePredictionLayerConfig[] getPredictionLayerConfigs()
      Gets the configuration objects for the prediction layers
      Returns:
      configurations
      Since:
      19.4
    • getClassWeights

      public Map<?,Float> getClassWeights()
      Gets the class weights
      Returns:
      class weights
      Since:
      19.4
    • getVertexTargetPropertyName

      public String getVertexTargetPropertyName()
      Gets the target property name
      Returns:
      target property name
      Since:
      19.4
    • gnnExplainer

      public SupervisedGnnExplainer gnnExplainer()
      Get a GnnExplainer object that can explain this model's predictions.
      Returns:
      SupervisedGnnExplainer object
      Since:
      22.2
    • getTargetVertexLabels

      public List<Set<String>> getTargetVertexLabels()
      Gets the target vertex labels
      Returns:
      target vertex labels
      Since:
      22.2