8.2.1 Loading a Graph
The following describes the steps for loading a graph:
- Create a Session and an Analyst.
cd /opt/oracle/graph/ ./bin/opg4j // starting the shell will create an implicit session and analyst opg4j> import oracle.pgx.config.mllib.ActivationFunction opg4j> import oracle.pgx.config.mllib.WeightInitScheme opg4j> PgxSession session = Pgx.createSession("my-session") opg4j> Analyst analyst = session.createAnalyst()
import oracle.pgx.api.*; import oracle.pgx.api.mllib.SupervisedGraphWiseModel; import oracle.pgx.api.frames.*; import oracle.pgx.config.mllib.ActivationFunction; import oracle.pgx.config.mllib.GraphWiseConvLayerConfig; import oracle.pgx.config.mllib.GraphWisePredictionLayerConfig; import oracle.pgx.config.mllib.SupervisedGraphWiseModelConfig; import oracle.pgx.config.mllib.WeightInitScheme; PgxSession session = Pgx.createSession("my-session"); Analyst analyst = session.createAnalyst();
session = pypgx.get_session(session_name="my-session") analyst = session.create_analyst()
- Load the graph.
opg4j> var fullGraph = session.readGraphWithProperties("<path>/<full_graph.json>") opg4j> var trainGraph = session.readGraphWithProperties("<path>/<train_graph.json>") opg4j> var testVertices = fullGraph.getVertices() .stream() .filter(v -> !trainGraph.hasVertex(v.getId())) .collect(Collectors.toList())
PgxGraph fullGraph = session.readGraphWithProperties("<path>/<full_graph.json>"); PgxGraph trainGraph = session.readGraphWithProperties("<path>/<train_graph.json>"); List<PgxVertex> testVertices = fullGraph.getVertices() .stream() .filter(v->!trainGraph.hasVertex(v.getId())) .collect(Collectors.toList());
full_graph = session.read_graph_with_properties("<path>/<full_graph.json>") train_graph = session.read_graph_with_properties("<path>/<train_graph.json>") test_vertices = [] train_vertices = train_graph.get_vertices() for v in full_graph.get_vertices(): if(not train_vertices.contains(v)): test_vertices.append(v)
Parent topic: Using the Supervised GraphWise Algorithm