Gremlin edge regression queries in Neptune ML - Amazon Neptune
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Gremlin edge regression queries in Neptune ML

Edge regression is similar to edge classification, except that the value inferred from the ML model is numeric. For edge regression, Neptune ML supports the same queries as for classification.

Key points to note are:

  • You need to use the ML predicate "Neptune#ml.regression" to configure the properties() step for this use-case.

  • The "Neptune#ml.limit" and "Neptune#ml.threshold" predicates are not applicable in this use-case.

  • For filtering on the value, you need to specify the value as numerical.

Syntax of a Gremlin edge regression query

For a simple graph where User is the head node, Movie is the tail node, and Rated is the edge that connects them, here is an example edge regression query that finds the numeric rating value, referred to as score here, for the edge Rated:

g.with("Neptune#ml.endpoint","edge-regression-movie-lens-endpoint") .with("Neptune#ml.iamRoleArn","arn:aws:iam::0123456789:role/sagemaker-role") .E("rating_1","rating_2","rating_3") .properties("score").with("Neptune#ml.regression")

You can also filter on a value inferred from the ML regression model. For the existing Rated edges (from User to Movie) identified by "rating_1", "rating_2", and "rating_3", where the edge property Score is not present for these ratings, you can use a query like following to infer Score for the edges where it is greater than or equal to 9:

g.with("Neptune#ml.endpoint","edge-regression-movie-lens-endpoint") .with("Neptune#ml.iamRoleArn","arn:aws:iam::0123456789:role/sagemaker-role") .E("rating_1","rating_2","rating_3") .properties("score").with("Neptune#ml.regression") .value().is(P.gte(9))