|
577 | 577 | "print(result)"
|
578 | 578 | ]
|
579 | 579 | },
|
| 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 | + }, |
580 | 631 | {
|
581 | 632 | "cell_type": "code",
|
582 | 633 | "execution_count": null,
|
|
0 commit comments