Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id AA773200C32 for ; Thu, 9 Mar 2017 13:35:45 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A8FE9160B67; Thu, 9 Mar 2017 12:35:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F044E160B64 for ; Thu, 9 Mar 2017 13:35:44 +0100 (CET) Received: (qmail 84793 invoked by uid 500); 9 Mar 2017 12:35:44 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 84784 invoked by uid 99); 9 Mar 2017 12:35:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Mar 2017 12:35:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F0F31DFF47; Thu, 9 Mar 2017 12:35:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: spmallette@apache.org To: commits@tinkerpop.apache.org Message-Id: <5f896cf9e04b4ffe8fef3c98bf069cdf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: tinkerpop git commit: Added some notes on sampling to recommendation recipe CTR Date: Thu, 9 Mar 2017 12:35:43 +0000 (UTC) archived-at: Thu, 09 Mar 2017 12:35:45 -0000 Repository: tinkerpop Updated Branches: refs/heads/tp32 df285d380 -> 3fe223bdc Added some notes on sampling to recommendation recipe CTR Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3fe223bd Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3fe223bd Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3fe223bd Branch: refs/heads/tp32 Commit: 3fe223bdcbf0695529aa9f5fd58b3bff573845b6 Parents: df285d3 Author: Stephen Mallette Authored: Thu Mar 9 07:34:23 2017 -0500 Committer: Stephen Mallette Committed: Thu Mar 9 07:34:23 2017 -0500 ---------------------------------------------------------------------- docs/src/recipes/recommendation.asciidoc | 45 ++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3fe223bd/docs/src/recipes/recommendation.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/recipes/recommendation.asciidoc b/docs/src/recipes/recommendation.asciidoc index 8d5f1ec..0aaa7e4 100644 --- a/docs/src/recipes/recommendation.asciidoc +++ b/docs/src/recipes/recommendation.asciidoc @@ -245,4 +245,47 @@ g.V().has("person","name","alice").as("alice"). by(values, decr). by(select(keys).values("name")). unfold().select(keys).values("name") ----- \ No newline at end of file +---- + +In considering the practical applications of this recipe, it is worth revisiting the earlier "basic" version of the +reccomendation algorithm: + +[gremlin-groovy,existing] +---- +g.V().has('person','name','alice').as('her'). + out('bought').aggregate('self'). + in('bought').where(neq('her')). + out('bought').where(without('self')). + groupCount(). + order(local). + by(values, decr) +---- + +The above traversal performs a full ranking of items based on all the connected data. That could be a time consuming +operation depending on the number of paths being traversed. As it turns out, recommendations don't need to have perfect +knowledge of all data to provide a "pretty good" approximation of a recommendation. It can therefore make sense to +place additional limits on the traversal to have it better return more quickly at the expense of examining less data. + + +Gremlin provides a number of steps that can help with these limits like: +link:http://tinkerpop.apache.org/docs/x.y.z/reference/#coin-step[coin()], +link:http://tinkerpop.apache.org/docs/x.y.z/reference/#sample-step[sample()], and +link:http://tinkerpop.apache.org/docs/current/reference/#timelimit-step[timeLimit()]. For example, to have the +traversal sample the data for no longer than one second, the previous "basic" recommendation could be changed to: + +[gremlin-groovy,existing] +---- +g.V().has('person','name','alice').as('her'). + out('bought').aggregate('self'). + in('bought').where(neq('her')). + out('bought').where(without('self')).timeLimit(1000). + groupCount(). + order(local). + by(values, decr) +---- + +In using sampling methods, it is important to consider that the natural ordering of edges in the graph may not produce +an ideal sample for the recommendation. For example, if the edges end up being returned oldest first, then the +recommendation will be based on the oldest data, which would not be ideal. As with any traversal, it is important to +understand the nature of the graph being traversed and the behavior of the underlying graph database to properly +achieve the desired outcome. \ No newline at end of file