diff --git a/examples/python-runtime.ipynb b/examples/python-runtime.ipynb new file mode 100644 index 000000000..da2118da3 --- /dev/null +++ b/examples/python-runtime.ipynb @@ -0,0 +1,188 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from graphdatascience import GraphDataScience" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "outputs": [], + "source": [ + "ENVIRONMENT = \"mlruntimedev\"\n", + "DBID = \"e6ba1b5c\"\n", + "PASSWORD = \"l4Co2Qa5GseW0sMropCvJo17laf6ZCq9vuAhiJrVW2c\"" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 3, + "outputs": [], + "source": [ + "gds = GraphDataScience(f\"neo4j+s://{DBID}-{ENVIRONMENT}.databases.neo4j-dev.io/\", auth=(\"neo4j\", PASSWORD))\n", + "gds.set_database(\"neo4j\")" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": "Uploading Nodes: 0%| | 0/2708 [00:00, ?Records/s]", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "2402df2e03544cc4aa950b31cdfc0b47" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": "Uploading Relationships: 0%| | 0/5429 [00:00, ?Records/s]", + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "9df2026182824543a38c5d30a04a3ea0" + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "try:\n", + " gds.graph.load_cora()\n", + "except:\n", + " pass" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "outputs": [], + "source": [ + "train_response = gds.gnn.nodeClassification.train(\n", + " \"cora\", \"myModel\", [\"features\"], \"subject\", [\"CITES\"], target_node_label=\"Paper\", node_labels=[\"Paper\"]\n", + ")" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 6, + "outputs": [], + "source": [ + "train_result = gds.run_cypher(\"RETURN gds.remoteml.getTrainResult('myModel')\");" + ], + "metadata": { + "collapsed": false + } + }, + { + "cell_type": "code", + "execution_count": 7, + "outputs": [ + { + "data": { + "text/plain": " gds.remoteml.getTrainResult('model2')\n0 {'test_acc_mean': 0.8589511513710022, 'test_ac...", + "text/html": "
\n | gds.remoteml.getTrainResult('model2') | \n
---|---|
0 | \n{'test_acc_mean': 0.8589511513710022, 'test_ac... | \n
\n | nodeId | \nfeatures | \nmodel2Predictions | \n
---|---|---|---|
0 | \n31336 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n0 | \n
1 | \n1061127 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, ... | \n1 | \n
2 | \n1106406 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n2 | \n
3 | \n13195 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n2 | \n
4 | \n37879 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n3 | \n
... | \n... | \n... | \n... | \n
2703 | \n1128975 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n5 | \n
2704 | \n1128977 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n5 | \n
2705 | \n1128978 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n5 | \n
2706 | \n117328 | \n[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n6 | \n
2707 | \n24043 | \n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... | \n0 | \n
2708 rows × 3 columns
\n