本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Neptune ML 中的 Gremlin 边缘分类查询
对于 Neptune ML 中的 Gremlin 边缘分类:
模型是在边的一个属性上训练的。此属性的唯一值集称为一组类。
可以从边缘分类模型中推断出边的类或类别属性值,当此属性尚未附加到边缘时,这将非常有用。
要从边缘分类模型中获取一个或多个类,您需要使用
with()
跟上谓词一步,"Neptune#ml.classification"
要配置properties()
Step。如果这些是边缘属性,输出格式与您期望的格式相似。
边缘分类仅适用于字符串属性值。这意味着数字属性值,例如0
要么1
不支持,尽管字符串等效"0"
和"1"
是。同样,布尔值属性值true
和false
不起作用,但"true"
和"false"
执行该操作
以下是一个边缘分类查询的示例,该查询使用Neptune#ml.score
谓词:
g.with("Neptune#ml.endpoint","edge-classification-movie-lens-endpoint") .with("Neptune#ml.iamRoleArn","arn:aws:iam::0123456789:role/sagemaker-role") .E("relationship_1","relationship_2","relationship_3") .properties("knows_by", "Neptune#ml.score").with("Neptune#ml.classification")
该回应将如下所示:
==>p[knows_by->"Family"] ==>p[Neptune#ml.score->0.01234567] ==>p[knows_by->"Friends"] ==>p[Neptune#ml.score->0.543210] ==>p[knows_by->"Colleagues"] ==>p[Neptune#ml.score->0.10101]
Gremlin 边缘分类查询的语法
对于简单的图表User
是头和尾节点,Relationship
是连接它们的边缘,一个示例边缘分类查询是:
g.with("Neptune#ml.endpoint","edge-classification-social-endpoint") .with("Neptune#ml.iamRoleArn","arn:aws:iam::0123456789:role/sagemaker-role") .E("relationship_1","relationship_2","relationship_3") .properties("knows_by").with("Neptune#ml.classification")
此查询的输出将类似于下面这样:
==>p[knows_by->"Family"] ==>p[knows_by->"Friends"] ==>p[knows_by->"Colleagues"]
在上面的查询中,E()
和properties()
步骤的使用方法如下:
-
这些区域有:
E()
step 包含要从边缘分类模型中获取类的一组边:.E("relationship_1","relationship_2","relationship_3")
-
这些区域有:
properties()
step 包含模型训练的关键,并且具有.with("Neptune#ml.classification")
表明这是边缘分类 ML 推理查询。
目前不支持多个属性键properties().with("Neptune#ml.classification")
Step。例如,以下查询导致引发异常:
g.with("Neptune#ml.endpoint","edge-classification-social-endpoint") .with("Neptune#ml.iamRoleArn","arn:aws:iam::0123456789:role/sagemaker-role") .E("relationship_1","relationship_2","relationship_3") .properties("knows_by", "other_label").with("Neptune#ml.classification")
有关特定错误消息,请参阅Neptune ML Gremlin 推理查询的例外清单.
一个properties().with("Neptune#ml.classification")
step 可以与以下任何步骤结合使用:
value()
value().is()
hasValue()
has(value,"")
key()
key().is()
hasKey()
has(key,"")
path()