17.2.13.1 Inferring Embeddings for a Model in Another Database

You can infer embeddings on a trained model and store in a different database other than the one used for login.

The following code shows how to infer embeddings and store in a different database:

opg-jshell> var vertexVectors = model.inferEmbeddings(fullGraph, testVertices).flattenAll()
opg-jshell> vertexVectors.write().
     db().
     username("user").                   // DB user to use for storing the model
     password("password").               // password of the DB user
     jdbcUrl("jdbcUrl").                 // jdbc url to the DB
     name("vertex vectors").
     tablename("vertexVectors").         // indicates the name of the table in which the data should be stored
     overwrite(true).                    
     store()
PgxFrame vertexVectors = model.inferEmbeddings(fullGraph,testVertices).flattenAll();
vertexVectors.write()
    .db()
    .username("user")                   // DB user to use for storing the model
    .password("password")               // password of the DB user
    .jdbcUrl("jdbcUrl")                 // jdbc url to the DB
    .name("vertex vectors")
    .tablename("vertexVectors")         // indicates the name of the table in which the data should be stored
    .overwrite(true)                    
    .store();
vertex_vectors = model.infer_embeddings(fullGraph,test_vertices).flattenAll()
vertex_vectors.write().db().username("user") \      
                           .password("password") \  
                           .jdbc_url("jdbcUrl") \
                           .table_name("table_name") \
                           .name("vertex vectors") \ 
                           .overwrite(True) \
                           .store()