neo4j-来自neo4j的项目图与GraphDataScience

发布于 2025-01-24 20:06:04 字数 1419 浏览 4 评论 0原文

因此,我有一个节点图 - “论文”和关系 - “引用”。 节点具有属性:“ X”,一个带有0/1条目的列表,与论文中是否存在单词相对应,以及“ y”整数标签(从0-6的类中)。

我想使用GraphDataScience从Neo4J投射图。 我一直在使用此 documentation ,我确实设法投射了节点和顶点图形:

代码

from graphdatascience import GraphDataScience

AURA_CONNECTION_URI = "neo4j+s://xxxx.databases.neo4j.io"
AURA_USERNAME = "neo4j"
AURA_PASSWORD = "my_code:)"

# Client instantiation
gds = GraphDataScience(
    AURA_CONNECTION_URI,
    auth=(AURA_USERNAME, AURA_PASSWORD),
    aura_ds=True
)

#Shorthand projection --works
shorthand_graph, result = gds.graph.project(
    "short-example-graph",
    ["Paper"],
    ["Citation"]
)

当我进行打印时的

(结果)时,它显示nodeprocodmention {'paper':{'label':'paper','properties':{}}}} 关系示威{'citation':{'entirentation':'自然',' 绘画短示例图 Nodecount 2708 关系量10556 ProjectMillis 34 名称:0,dtype:

但是,没有投影节点的属性。然后,我使用文档中所述的扩展语法:

# Project a graph using the extended syntax
extended_form_graph, result = gds.graph.project(
    "Long-form-example-graph",
    {'Paper': {properties: "x"}},
    "Citation"
)

print(result)

#Errors 我得到错误: 名称:名称“属性”不是定义的

,我尝试过有或没有“不”的各种变体,但是没有一个效果(也没有奏效(文档也非常令人困惑,因为其中一个文档总是使用“”看 ” ”)。

另外,请注意,我所有的属性都是Neo4J db(在Aurads)中的整数,因为我曾经有一个错误,即不支持字符串属性。

对投影节点特征(又称属性)的正确方式的一些澄清将非常有用。

谢谢你, 狄娜

So I have a graph of nodes -- "Papers" and relationships -- "Citations".
Nodes have properties: "x", a list with 0/1 entries corresponding to whether a word is present in the paper or not, and "y" an integer label (one of the classes from 0-6).

I want to project the graph from Neo4j using GraphDataScience.
I've been using this documentation and I indeed managed to project the nodes and vertices of the graph:

Code

from graphdatascience import GraphDataScience

AURA_CONNECTION_URI = "neo4j+s://xxxx.databases.neo4j.io"
AURA_USERNAME = "neo4j"
AURA_PASSWORD = "my_code:)"

# Client instantiation
gds = GraphDataScience(
    AURA_CONNECTION_URI,
    auth=(AURA_USERNAME, AURA_PASSWORD),
    aura_ds=True
)

#Shorthand projection --works
shorthand_graph, result = gds.graph.project(
    "short-example-graph",
    ["Paper"],
    ["Citation"]
)

When I do print(result) it shows

nodeProjection {'Paper': {'label': 'Paper', 'properties': {}}}
relationshipProjection {'Citation': {'orientation': 'NATURAL', 'aggre...
graphName short-example-graph
nodeCount 2708
relationshipCount 10556
projectMillis 34
Name: 0, dtype: object

However, no properties of the nodes are projected. I then use the extended syntax as described in the documentation:

# Project a graph using the extended syntax
extended_form_graph, result = gds.graph.project(
    "Long-form-example-graph",
    {'Paper': {properties: "x"}},
    "Citation"
)

print(result)

#Errors
I get the error:
NameError: name 'properties' is not defined

I tried various variations of this, with or without " ", but none have worked so far (also documentation is very confusing because one of the docs always uses " " and in another place I did not see " ").

Also, note that all my properties are integers in the Neo4j db (in AuraDS), as I used to have the error that String properties are not supported.

Some clarification on the correct way of projecting node features (aka properties) would be very useful.

thank you,
Dina

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小耗子 2025-01-31 20:06:04

与GraphDataScience库一起使用的Python字典中的键应包含在引号中。这与Cypher语法不同,其中地图密钥没有带有引号。

这应该对您有用。

extended_form_graph, result = gds.graph.project(
    "Long-form-example-graph",
    {'Paper': {"properties": "x"}},
    "Citation"
)

最良好的祝愿,

内森

The keys in the Python dictionaries that you use with the GraphDataScience library should be enclosed in quotation marks. This is different from Cypher syntax, where map keys are not enclosed with quotation marks.

This should work for you.

extended_form_graph, result = gds.graph.project(
    "Long-form-example-graph",
    {'Paper': {"properties": "x"}},
    "Citation"
)

Best wishes,

Nathan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文