8.3.6 Inferring Embeddings for a Unsupervised GraphWise Model

You can use a trained model to infer embeddings for unseen nodes and store them in the database as described in the following step:

  1. Infer embeddings for a Unsupervised GraphWise Model as shown in following code:
    Inferring Embeddings Using JShell
    opg4j> var vertexVectors = model.inferEmbeddings(fullGraph, fullGraph.getVertices()).flattenAll();
    opg4j> vertexVectors.write().
        db().
        name("vertex vectors").
        tablename("vertexVectors").  // indicate the name of the table in which the data should be stored
        overwrite(true).             // indicate that if there is a table with the same name, it will be overwritten (truncated)
        store();
    Inferring Embeddings Using Java
    PgxFrame vertexVectors = model.inferEmbeddings(fullGraph,fullGraph.getVertices()).flattenAll();
    vertexVectors.write()
        .db()
        .name("vertex vectors")
        .tablename("vertexVectors") // indicate the name of the table in which the data should be stored
        .overwrite(true)            // indicate that if there is a table with the same name, it will be overwritten (truncated)
        .store();
    Inferring Embeddings Using Python
    vertexVectors = model.infer_embeddings(fullGraph,fullGraph.getVertices()).flattenAll()
    vertexVectors.write().db(name="vertex vectors", "tablename", overwrite=True)
    The schema for the vertexVectors will be as follows without flattening (flattenAll splits the vector column into separate double-valued columns):
    
    +---------------------------------------------------------------+
    | vertexId                                | embedding           |
    +---------------------------------------------------------------+

    Note:

    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 refer to the examples in Inferring Embeddings for a Model in Another Database.