17.3.9 Training a Supervised EdgeWise Model
SupervisedEdgeWiseModel on a graph as
            shown:
               opg4j> model.fit(trainGraph)model.fit(trainGraph);model.fit(train_graph)You can also add a validation step to the training. When training a
                model, the optimal number of training epochs is not known in advance and it is one
                of the key parameters that determines the model quality. Being able to monitor the
                training and validation losses helps you to identify a good value for the model
                parameters and gain visibility in the training process. The evaluation frequency can
                be specified in terms of epoch or step. To configure a validation step, create a
                    GraphWiseValidationConfig and pass it to the model builder as
                shown:
                  
opg4j> import oracle.pgx.config.mllib.EvaluationFrequencyScale;
opg4j> var validationConfig = analyst.graphWiseValidationConfigBuilder().
         setEvaluationFrequency(2).                                    // set the evaluation frequency (default: 1)
         setEvaluationFrequencyScale(EvaluationFrequencyScale.EPOCH).  // available options: EPOCH, STEP (default: EPOCH)
         build()
opg4j> var model = analyst.supervisedEdgeWiseModelBuilder().
         setVertexInputPropertyNames("vertex_features").
         setEdgeInputPropertyNames("edge_features").
         setEdgeTargetPropertyName("labels").
         setValidationConfig(validationConfig).  // configuring the validation to be executed every 2 epochs
         build()import oracle.pgx.config.mllib.GraphWiseValidationConfig;
import oracle.pgx.config.mllib.EvaluationFrequencyScale;
GraphWiseValidationConfig validationConfig = analyst.graphWiseValidationConfigBuilder()
    .setEvaluationFrequency(2)                                    // set the evaluation frequency (default: 1)
    .setEvaluationFrequencyScale(EvaluationFrequencyScale.EPOCH)  // available options: EPOCH, STEP (default: EPOCH)
    .build();
SupervisedEdgeWiseModel model = analyst.supervisedEdgeWiseModelBuilder()
    .setVertexInputPropertyNames("vertex_features")
    .setEdgeInputPropertyNames("edge_features")
    .setEdgeTargetPropertyName("labels")
    .setValidationConfig(validationConfig)  // configuring the validation to be executed every 2 epochs
    .build();validation_config = analyst.graphwise_validation_config(
    evaluation_frequency=2,              # set the evaluation frequency (default: 1)
    evaluation_frequency_scale="epoch",  # available options: "epoch", "step" (default: "epoch")
)
params = dict(edge_target_property_name="labels",
              vertex_input_property_names=["vertex_features"],
              edge_input_property_names=["edge_features"],
              validation_config=validation_config,  # configuring the validation to be executed every 2 epochs
              seed=17)
model = analyst.supervised_edgewise_builder(**params)After configuring a validation step, you can then pass a graph for validation to the
                    fit method together with the graph for training:
                  
opg4j> model.fit(trainGraph, valGraph)model.fit(trainGraph,valGraph);model.fit(train_graph,valGraph)