Skip to content

Commit 5e31fbb

Browse files
authored
Merge pull request #1 from orazve/kge-predict-add-write-notebook-api
Add write mode demonstration
2 parents bb62bf7 + b195392 commit 5e31fbb

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

examples/kge-predict-transe-pyg-train.ipynb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,57 @@
577577
"print(result)"
578578
]
579579
},
580+
{
581+
"cell_type": "markdown",
582+
"metadata": {
583+
"collapsed": false
584+
},
585+
"source": [
586+
"## Using Write Mode\n",
587+
"\n",
588+
"Write mode allows you to write results directly to the database as a new relationship type. This approach helps to avoid mapping from `nodeId` to `id`."
589+
]
590+
},
591+
{
592+
"cell_type": "code",
593+
"execution_count": null,
594+
"metadata": {},
595+
"outputs": [],
596+
"source": [
597+
"write_relationship_type = \"PREDICTED_\" + rel_label_to_predict\n",
598+
"result_write = transe_model.predict_write(\n",
599+
" source_node_filter=source_ids_df.nodeId,\n",
600+
" target_node_filter=\"Entity\",\n",
601+
" relationship_type=rel_label_to_predict,\n",
602+
" write_relationship_type=write_relationship_type,\n",
603+
" write_property=\"transe_score\",\n",
604+
" top_k=3,\n",
605+
" concurrency=4,\n",
606+
")"
607+
]
608+
},
609+
{
610+
"cell_type": "markdown",
611+
"metadata": {
612+
"collapsed": false
613+
},
614+
"source": [
615+
"Extract the result from the database."
616+
]
617+
},
618+
{
619+
"cell_type": "code",
620+
"execution_count": null,
621+
"metadata": {},
622+
"outputs": [],
623+
"source": [
624+
"gds.run_cypher(\n",
625+
" \"MATCH (n)-[r:\"\n",
626+
" + write_relationship_type\n",
627+
" + \"]->(m) RETURN n.id AS sourceId, n.text AS sourceTag, m.id AS targetId, m.text AS targetTag, r.transe_score AS score\"\n",
628+
")"
629+
]
630+
},
580631
{
581632
"cell_type": "code",
582633
"execution_count": null,

0 commit comments

Comments
 (0)