Training an Unsupervised GraphWise Model
You can train an Unsupervised GraphWise model 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(100). // set the evaluation frequency (default: 1)
setEvaluationFrequencyScale(EvaluationFrequencyScale.STEP). // available options: EPOCH, STEP (default: EPOCH)
build()
opg4j> var model = analyst.unsupervisedGraphWiseModelBuilder().
setVertexInputPropertyNames("vertex_features").
setValidationConfig(validationConfig). // configuring the validation to be executed every 100 steps
build()
import oracle.pgx.config.mllib.GraphWiseValidationConfig;
import oracle.pgx.config.mllib.EvaluationFrequencyScale;
GraphWiseValidationConfig validationConfig = analyst.graphWiseValidationConfigBuilder()
.setEvaluationFrequency(100) // set the evaluation frequency (default: 1)
.setEvaluationFrequencyScale(EvaluationFrequencyScale.STEP) // available options: EPOCH, STEP (default: EPOCH)
.build();
UnsupervisedGraphWiseModel model = analyst.unsupervisedGraphWiseModelBuilder()
.setVertexInputPropertyNames("vertex_features")
.setValidationConfig(validationConfig) // configuring the validation to be executed every 100 steps
.build();
validation_config = analyst.graphwise_validation_config(
evaluation_frequency=100, # set the evaluation frequency (default: 1)
evaluation_frequency_scale="step", # available options: "epoch", "step" (default: "epoch")
)
params = dict(vertex_input_property_names=["vertex_features"],
validation_config=validation_config, # configuring the validation to be executed every 100 steps
seed=17)
model = analyst.unsupervised_graphwise_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)