17.5.10 Inferring Embeddings for an Unsupervised EdgeWise Model
You can use a trained model to infer embeddings for unseen nodes and store them in the database as described in the following code:
opg4j> var edgeVectors = model.inferEmbeddings(fullGraph, testEdges).flattenAll()
opg4j> edgeVectors.write().
db().
name("edge vectors").
tablename("edgeVectors").
overwrite(true).
store()PgxFrame edgeVectors = model.inferEmbeddings(fullGraph, testEdges).flattenAll();
edgeVectors.write()
.db()
.name("edge vectors")
.tablename("edgeVectors")
.overwrite(true)
.store();edge_vectors = model.infer_embeddings(full_Graph, test_edges).flatten_all()
edge_vectors.write().db().table_name("table_name").name("edge_vectors").overwrite(True).store()The schema for the
edgeVectors will be as follows
without flattening (flattenAll splits the vector column into
separate double-valued
columns):+---------------------------------------------------------------+
| edgeId | embedding |
+---------------------------------------------------------------+All the preceding examples assume that you are inferring the embeddings
for a model in the current logged in database. If you must infer embeddings for the
model in a different database, then you must additionally provide the database
credentials such as username, password, and
jdbcUrl to the inferEmbeddings method. Refer
to Inferring Embeddings for a Model in Another Database for an example.
Parent topic: Using the Unsupervised EdgeWise Algorithm