8.2.8 Supervised GraphWiseモデルの埋込みの推測

トレーニング済モデルを使用すると、次のコードに示すように、表示されないノードの埋込みを推測してデータベースに格納できます。

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();
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();
Pythonを使用した埋込みの推測
vertex_vectors = model.infer_embeddings(full_graph, full_graph.get_vertices()).flatten_all()
vertexVectors.write().db(name="vertex vectors", "tablename", overwrite=True)
vertexVectorsのスキーマは、フラット化せずに次のようになります(flattenAllはベクトル列を個別のdouble値列に分割します)。

+---------------------------------------------------------------+
| vertexId                                | embedding           |
+---------------------------------------------------------------+

ノート:

前述のすべての例では、現在ログインしているデータベースでモデルの埋込みを推測することを前提としています。別のデータベースでモデルの埋込みを推測する必要がある場合は、別のデータベースでのモデルの埋込みの推測の例を参照してください。