http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/0b09b57d/templates/javaecommercerecommendation/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/javaecommercerecommendation/quickstart/index.html b/templates/javaecommercerecommendation/quickstart/index.html index bf52354..b826675 100644 --- a/templates/javaecommercerecommendation/quickstart/index.html +++ b/templates/javaecommercerecommendation/quickstart/index.html @@ -32,7 +32,7 @@ Your system is all ready to go. <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp1 | 1 | 3mZWDzci2D5YsqAnqNnXH9SB6Rg3dsTBs8iHkK6X2i54IQsIZI1eEeQQyMfs7b3F | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp2 | 2 | io5lz6Eg4m3Xe4JZTBFE13GMAf1dhFl6ZteuJfrO84XpdOz9wRCrDU44EUaYuXq5 | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> Finished listing 2 app<span class="o">(</span>s<span class="o">)</span>. -</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, the E-Commerce Recommendation Engine Template supports 2 types of entities and 2 events: <strong>user</strong> and <strong>item</strong>; events <strong>view</strong> and <strong>buy</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view and buy an item. The specical <strong>constraint</strong> entiy with entityId <strong>unavailableItems</strong> defines a list of unavailable items and is taken into account in realtime during serving.</p><p>In summary, this template requires '$set' user event, '$set' item event, user-view-item events, user-buy-item event and '$set' constraint event.</p><div class="alert-message info"><p>This template can easily be customized to consider other user-to-it em events.</p></div> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when a new user with id "u0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for this user. To send this event, run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-9b8c531d-f1d4-4ee5-b6ee-accb4c80a156">REST API</a></li> <li data-lang="python"><a href="#tab-2f76c73d-9421-48f4-85b6-bfe7e7945ac4">Python SDK</a></li> <li data-lang="php"><a href="#tab-81cc496b-0f36-464c-bd03-06db01e15a17">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7c747d89-17ba-4c33-8fa6-e22fc888e9ba">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6b6fe27e-4e9a-4dac-8225-c7aac830182e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-9b8c531d-f1d4-4ee5-b6ee-accb4c80a156"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, the E-Commerce Recommendation Engine Template supports 2 types of entities and 2 events: <strong>user</strong> and <strong>item</strong>; events <strong>view</strong> and <strong>buy</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view and buy an item. The specical <strong>constraint</strong> entiy with entityId <strong>unavailableItems</strong> defines a list of unavailable items and is taken into account in realtime during serving.</p><p>In summary, this template requires '$set' user event, '$set' item event, user-view-item events, user-buy-item event and '$set' constraint event.</p><div class="alert-message info"><p>This template can easily be customized to consider other user-to-it em events.</p></div> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when a new user with id "u0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for this user. To send this event, run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-f2c0c497-f8bd-4487-be43-a10fe4e1cc4b">REST API</a></li> <li data-lang="python"><a href="#tab-a5db0129-0913-411e-8893-5fa3c759b46e">Python SDK</a></li> <li data-lang="php"><a href="#tab-d6692edb-ad6d-4cb8-8523-f2a2f3bc3ec6">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-f442678c-6f9f-4f82-b6d8-473ffcbe877f">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-762bdfe5-007e-4673-8b96-d0693925ce7d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-f2c0c497-f8bd-4487-be43-a10fe4e1cc4b"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -47,7 +47,7 @@ Your system is all ready to go. "entityId" : "u0", "eventTime" : "2014-11-02T09:39:45.618-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-2f76c73d-9421-48f4-85b6-bfe7e7945ac4"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-a5db0129-0913-411e-8893-5fa3c759b46e"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -78,7 +78,7 @@ Your system is all ready to go. <span class="n">entity_type</span><span class="o">=</span><span class="s">"user"</span><span class="p">,</span> <span class="n">entity_id</span><span class="o">=<</span><span class="n">USER_ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-81cc496b-0f36-464c-bd03-06db01e15a17"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-d6692edb-ad6d-4cb8-8523-f2a2f3bc3ec6"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -119,7 +119,7 @@ Your system is all ready to go. <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'categories'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<CATEGORY_1>'</span><span class="p">,</span> <span class="s1">'<CATEGORY_2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-7c747d89-17ba-4c33-8fa6-e22fc888e9ba"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-f442678c-6f9f-4f82-b6d8-473ffcbe877f"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -136,7 +136,7 @@ Your system is all ready to go. <span class="s1">'user'</span><span class="p">,</span> <span class="o"><</span><span class="no">USER</span> <span class="no">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-6b6fe27e-4e9a-4dac-8225-c7aac830182e"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-762bdfe5-007e-4673-8b96-d0693925ce7d"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -161,7 +161,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">entityType</span><span class="o">(</span><span class="s">"user"</span><span class="o">)</span> <span class="o">.</span><span class="na">entityId</span><span class="o">(<</span><span class="n">USER_ID</span><span class="o">>);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">userEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>When a new item "i0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for the item. Note that the item is set with categories properties: <code>"c1"</code> and <code>"c2"</code>. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-e55b8856-50aa-4b87-8b55-0abbf3ea8442">REST API</a></li> <li data-lang="python"><a href="#tab-76884aaf-b06a-4a1e-ba71-e1279354ed6f">Python SDK</a></li> <li data-lang="php"><a href="#tab-2c1f9fc1-6e01-4eda-ada1-36177d168a92">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-5d8e10dc-b1f5-49a3-8aca-84afb68b9c98">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-64d7ba7a-6d80-4bdc-809e-2714d3e5d164">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-e55b88 56-50aa-4b87-8b55-0abbf3ea8442"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>When a new item "i0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for the item. Note that the item is set with categories properties: <code>"c1"</code> and <code>"c2"</code>. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-6da326ff-2ef1-4b6f-be50-79e544cf059e">REST API</a></li> <li data-lang="python"><a href="#tab-88bdea17-5603-4895-8fd9-0e6530dccdb1">Python SDK</a></li> <li data-lang="php"><a href="#tab-2bfc3b06-5af4-46c7-a7d0-160163a53aee">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-8dbbf899-cf2a-4530-bc9a-bc248bfb2f86">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-b4e2a23f-a903-414c-88c5-d5ef1a474b84">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-6da326 ff-2ef1-4b6f-be50-79e544cf059e"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -182,7 +182,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:39:45.618-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-76884aaf-b06a-4a1e-ba71-e1279354ed6f"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-88bdea17-5603-4895-8fd9-0e6530dccdb1"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -201,7 +201,7 @@ Your system is all ready to go. <span class="s">"categories"</span> <span class="p">:</span> <span class="p">[</span><span class="s">"<CATEGORY_1>"</span><span class="p">,</span> <span class="s">"<CATEGORY_2>"</span><span class="p">]</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-2c1f9fc1-6e01-4eda-ada1-36177d168a92"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-2bfc3b06-5af4-46c7-a7d0-160163a53aee"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -218,7 +218,7 @@ Your system is all ready to go. <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'categories'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<CATEGORY_1>'</span><span class="p">,</span> <span class="s1">'<CATEGORY_2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-5d8e10dc-b1f5-49a3-8aca-84afb68b9c98"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-8dbbf899-cf2a-4530-bc9a-bc248bfb2f86"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -235,7 +235,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-64d7ba7a-6d80-4bdc-809e-2714d3e5d164"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-b4e2a23f-a903-414c-88c5-d5ef1a474b84"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -248,7 +248,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">entityId</span><span class="o">(<</span><span class="n">ITEM_ID</span><span class="o">>)</span> <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"categories"</span><span class="o">,</span> <span class="n">ImmutableList</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"<CATEGORY_1>"</span><span class="o">,</span> <span class="s">"<CATEGORY_2>"</span><span class="o">));</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">itemEvent</span><span class="o">)</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>The properties of the <code>user</code> and <code>item</code> can be set, unset, or delete by special events <strong>$set</strong>, <strong>$unset</strong> and <strong>$delete</strong>. Please refer to <a href="/datacollection/eventapi/#note-about-properties">Event API</a> for more details of using these events.</p><p>When the user "u0" view item "i0" on time <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-8e798e11-2fc4-4aea-b361-0c272425497f">REST API</a></li> <li data-lang="python"><a href="#tab-06cfd842-95e4-4f5b-8e56-d818806cfe81">Python SDK</a></li> <li data-lang="php"><a href="#tab-7c654868-e2a4-41a0-8ba4-83b8ee396834">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a10da1ec-7cbf-4d8b-8426-43fab1 ab000b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-89e67b80-d189-4e40-a469-0ef79a3ce420">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-8e798e11-2fc4-4aea-b361-0c272425497f"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>The properties of the <code>user</code> and <code>item</code> can be set, unset, or delete by special events <strong>$set</strong>, <strong>$unset</strong> and <strong>$delete</strong>. Please refer to <a href="/datacollection/eventapi/#note-about-properties">Event API</a> for more details of using these events.</p><p>When the user "u0" view item "i0" on time <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-76aa6e11-6b03-4862-8d1a-2861dc81a3f1">REST API</a></li> <li data-lang="python"><a href="#tab-a90c1ec5-c0ee-41b3-9276-28a9df0824dc">Python SDK</a></li> <li data-lang="php"><a href="#tab-773a7156-4400-45d1-a74e-c82fef1ad3ec">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a30f3fab-7556-4063-a292-df3de7 25999b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-dfa2d1c5-f5bf-4c8c-9a58-71ec4eb54f1d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-76aa6e11-6b03-4862-8d1a-2861dc81a3f1"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -267,7 +267,7 @@ Your system is all ready to go. "targetEntityId" : "i0", "eventTime" : "2014-11-10T12:34:56.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-06cfd842-95e4-4f5b-8e56-d818806cfe81"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-a90c1ec5-c0ee-41b3-9276-28a9df0824dc"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -284,7 +284,7 @@ Your system is all ready to go. <span class="n">target_entity_type</span><span class="o">=</span><span class="s">"item"</span><span class="p">,</span> <span class="n">target_entity_id</span><span class="o">=<</span><span class="n">ITEM</span> <span class="n">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-7c654868-e2a4-41a0-8ba4-83b8ee396834"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-773a7156-4400-45d1-a74e-c82fef1ad3ec"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -303,7 +303,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="nx">ITEM</span> <span class="nx">ID</span><span class="o">></span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-a10da1ec-7cbf-4d8b-8426-43fab1ab000b"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-a30f3fab-7556-4063-a292-df3de725999b"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -322,7 +322,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-89e67b80-d189-4e40-a469-0ef79a3ce420"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-dfa2d1c5-f5bf-4c8c-9a58-71ec4eb54f1d"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -337,7 +337,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">targetEntityType</span><span class="o">(</span><span class="s">"item"</span><span class="o">)</span> <span class="o">.</span><span class="na">targetEntityId</span><span class="o">(<</span><span class="n">ITEM_ID</span><span class="o">>);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">viewEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>When the user "u0" buy item "i0" on time <code>2014-11-10T13:00:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-c0b78339-23e8-46ac-a7ec-ce8a08bef21c">REST API</a></li> <li data-lang="python"><a href="#tab-2b3d1e23-587c-49ff-9b7b-2559142d3b3f">Python SDK</a></li> <li data-lang="php"><a href="#tab-5ff5fd35-f248-41fa-ae3c-b56b6984e9b8">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-35bf8756-b577-4562-9cfd-b32e815b55f2">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-d712c992-80e1-4e27-9e54-809b8a2bab84">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-c0b78339-23e8-46ac-a7ec-ce8a08bef21c"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text- align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>When the user "u0" buy item "i0" on time <code>2014-11-10T13:00:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-ce441f13-c6c4-480c-a347-8549b8bb5bf0">REST API</a></li> <li data-lang="python"><a href="#tab-6910fb10-7283-4c33-a4cb-9a2acb883dd7">Python SDK</a></li> <li data-lang="php"><a href="#tab-4c41e52d-4edd-4558-8b3c-0bb52cdee440">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-ce55929b-1a92-467b-95f6-8b30f45f94ce">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-50d8c8ac-9fab-4f84-942c-a3efbe3e969e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-ce441f13-c6c4-480c-a347-8549b8bb5bf0"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text- align: right"><pre class="lineno">1 2 3 4 @@ -356,7 +356,7 @@ Your system is all ready to go. "targetEntityId" : "i0", "eventTime" : "2014-11-10T13:00:00.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-2b3d1e23-587c-49ff-9b7b-2559142d3b3f"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-6910fb10-7283-4c33-a4cb-9a2acb883dd7"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -373,7 +373,7 @@ Your system is all ready to go. <span class="n">target_entity_type</span><span class="o">=</span><span class="s">"item"</span><span class="p">,</span> <span class="n">target_entity_id</span><span class="o">=<</span><span class="n">ITEM</span> <span class="n">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-5ff5fd35-f248-41fa-ae3c-b56b6984e9b8"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-4c41e52d-4edd-4558-8b3c-0bb52cdee440"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -392,7 +392,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="nx">ITEM</span> <span class="nx">ID</span><span class="o">></span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-35bf8756-b577-4562-9cfd-b32e815b55f2"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-ce55929b-1a92-467b-95f6-8b30f45f94ce"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -409,7 +409,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="no">ITEM</span> <span class="no">ID</span><span class="o">></span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-d712c992-80e1-4e27-9e54-809b8a2bab84"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-50d8c8ac-9fab-4f84-942c-a3efbe3e969e"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -490,19 +490,19 @@ User u10 buys item i40 </pre></td></tr></tbody></table> </div> <p>When the engine is deployed successfully and running, you should see a console message similar to the following:</p><div class="highlight shell"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1 2</pre></td><td class="code"><pre><span class="o">[</span>INFO] <span class="o">[</span>HttpListener] Bound to /0.0.0.0:8000 <span class="o">[</span>INFO] <span class="o">[</span>MasterActor] Bind successful. Ready to serve. -</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve predicted results. To recommend 4 items to user ID "u1". You send this JSON <code>{ "userEntityId": "u1", "number": 4 }</code> to the deployed engine and it will return a JSON of the recommended items. Simply send a query by making a HTTP request or through the <code>EngineClient</code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li da ta-lang="json"><a href="#tab-f885c29d-7fab-4517-bcad-0cb74397f1fd">REST API</a></li> <li data-lang="python"><a href="#tab-8444dc2c-2bb8-433f-876d-817d29583673">Python SDK</a></li> <li data-lang="php"><a href="#tab-d51448ff-f2d4-49c5-a253-19a9926a0693">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4c77ffa1-800f-4981-8e4c-c83cb8277373">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-93000ba7-5722-47cc-b085-cc44e8994c0d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-f885c29d-7fab-4517-bcad-0cb74397f1fd"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve predicted results. To recommend 4 items to user ID "u1". You send this JSON <code>{ "userEntityId": "u1", "number": 4 }</code> to the deployed engine and it will return a JSON of the recommended items. Simply send a query by making a HTTP request or through the <code>EngineClient</code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li da ta-lang="json"><a href="#tab-ac957b45-1ec9-44b2-8557-6d68c040896b">REST API</a></li> <li data-lang="python"><a href="#tab-7b894272-b55e-4e2f-9d3e-df5278e9f88b">Python SDK</a></li> <li data-lang="php"><a href="#tab-1a64e410-7773-4364-bd2a-fa6200cb6b50">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-737d5efa-24a7-4a74-8d99-0973f5b3c4a9">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-037c91e3-3908-45b3-b2fc-74b1b9d84827">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-ac957b45-1ec9-44b2-8557-6d68c040896b"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4</pre></td> <td class="code"><pre><span class="gp">$ </span>curl -H <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span> -d <span class="s1">'{ "userEntityId": "u1", "number": 4 }'</span> <span class="se">\</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-8444dc2c-2bb8-433f-876d-817d29583673"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-7b894272-b55e-4e2f-9d3e-df5278e9f88b"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3</pre></td> <td class="code"><pre><span class="kn">import</span> <span class="nn">predictionio</span> <span class="n">engine_client</span> <span class="o">=</span> <span class="n">predictionio</span><span class="o">.</span><span class="n">EngineClient</span><span class="p">(</span><span class="n">url</span><span class="o">=</span><span class="s">"http://localhost:8000"</span><span class="p">)</span> <span class="k">print</span> <span class="n">engine_client</span><span class="o">.</span><span class="n">send_query</span><span class="p">({</span><span class="s">"userEntityId"</span><span class="p">:</span> <span class="s">"u1"</span><span class="p">,</span> <span class="s">"number"</span><span class="p">:</span> <span class="mi">4</span><span class="p">})</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-d51448ff-f2d4-49c5-a253-19a9926a0693"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-1a64e410-7773-4364-bd2a-fa6200cb6b50"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -521,7 +521,7 @@ http://localhost:8000/queries.json <span class="nb">print_r</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-4c77ffa1-800f-4981-8e4c-c83cb8277373"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-737d5efa-24a7-4a74-8d99-0973f5b3c4a9"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -534,7 +534,7 @@ http://localhost:8000/queries.json <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="nf">send_query</span><span class="p">(</span><span class="s1">'userEntityId'</span> <span class="o">=></span> <span class="s1">'i1'</span><span class="p">,</span> <span class="s1">'number'</span> <span class="o">=></span> <span class="mi">4</span><span class="p">)</span> <span class="nb">puts</span> <span class="n">response</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-93000ba7-5722-47cc-b085-cc44e8994c0d"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-037c91e3-3908-45b3-b2fc-74b1b9d84827"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -578,7 +578,7 @@ http://localhost:8000/queries.json <span class="o">{</span><span class="s2">"itemEntityId"</span>:<span class="s2">"i3"</span>,<span class="s2">"score"</span>:0.003007015026561692<span class="o">}</span> <span class="o">]</span> <span class="o">}</span> -</pre></td></tr></tbody></table> </div> <p><em>MyECommerceRecommendation</em> is now running.</p> <div class="alert-message info"><p>To update the model periodically with new data, simply set up a cron job to call <code>pio train</code> and <code>pio deploy</code>. The engine will continue to serve prediction results during the re-train process. After the training is completed, <code>pio deploy</code> will automatically shutdown the existing engine server and bring up a new process on the same port.</p></div><div class="alert-message info"><p><strong>Note that if you import a <em>large</em> data set</strong> and the training seems to be taking forever or getting stuck, it's likely that there is not enough executor memory. It's recommended to setup a Spark standalone cluster, you'll need to specify more driver and executor memory when training with a large data set. Please see <a href="/resources/faq/#engine-training">FAQ here</a> for instructions.</p></div> <h2 id='setti ng-constraint-"unavailableitems"' class='header-anchors'>Setting constraint "unavailableItems"</h2><p>Now let's send an item constraint "unavailableItems" (replace accessKey with your Access Key):</p><div class="alert-message note"><p>You can also use SDK to send this event as described in the SDK sample above.</p></div><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-40d72da8-d3c6-4558-a98d-f43c2a9c7038">REST API</a></li> <li data-lang="python"><a href="#tab-4e8282e0-5d60-499f-bf74-b40e289134d9">Python SDK</a></li> <li data-lang="php"><a href="#tab-893fa5f4-46d3-4c95-9789-1191a704f66c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-cf29d3c3-800d-4deb-8f2d-4433cb1eeab9">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-464f10a1-f29a-4f00-87ed-d95d2716179a">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-40d72da8-d3c6-4558-a98d-f43c2a9c7038"> <div class="highlight shell"> <table style="borde r-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><em>MyECommerceRecommendation</em> is now running.</p> <div class="alert-message info"><p>To update the model periodically with new data, simply set up a cron job to call <code>pio train</code> and <code>pio deploy</code>. The engine will continue to serve prediction results during the re-train process. After the training is completed, <code>pio deploy</code> will automatically shutdown the existing engine server and bring up a new process on the same port.</p></div><div class="alert-message info"><p><strong>Note that if you import a <em>large</em> data set</strong> and the training seems to be taking forever or getting stuck, it's likely that there is not enough executor memory. It's recommended to setup a Spark standalone cluster, you'll need to specify more driver and executor memory when training with a large data set. Please see <a href="/resources/faq/#engine-training">FAQ here</a> for instructions.</p></div> <h2 id='setti ng-constraint-"unavailableitems"' class='header-anchors'>Setting constraint "unavailableItems"</h2><p>Now let's send an item constraint "unavailableItems" (replace accessKey with your Access Key):</p><div class="alert-message note"><p>You can also use SDK to send this event as described in the SDK sample above.</p></div><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-d2d60dc7-34ac-403a-8a3d-b073c6e5b84f">REST API</a></li> <li data-lang="python"><a href="#tab-976aae3b-00df-4141-8a82-e7446ce6f443">Python SDK</a></li> <li data-lang="php"><a href="#tab-2e3c4d7a-b35d-41bd-8967-8fe26b1c2259">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a80970a1-3921-4553-9d97-02f192f66977">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e4ed2ce2-6f84-4c85-ba40-4955f5433147">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-d2d60dc7-34ac-403a-8a3d-b073c6e5b84f"> <div class="highlight shell"> <table style="borde r-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -599,7 +599,7 @@ http://localhost:8000/queries.json } "eventTime" : "2015-02-17T02:11:21.934Z" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-4e8282e0-5d60-499f-bf74-b40e289134d9"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-976aae3b-00df-4141-8a82-e7446ce6f443"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -618,7 +618,7 @@ http://localhost:8000/queries.json <span class="s">"items"</span> <span class="p">:</span> <span class="p">[</span><span class="s">"<ITEM ID1>"</span><span class="p">,</span> <span class="s">"<ITEM ID2>"</span><span class="p">]</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-893fa5f4-46d3-4c95-9789-1191a704f66c"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-2e3c4d7a-b35d-41bd-8967-8fe26b1c2259"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -635,7 +635,7 @@ http://localhost:8000/queries.json <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'items'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<ITEM ID1>'</span><span class="p">,</span> <span class="s1">'<ITEM ID2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-cf29d3c3-800d-4deb-8f2d-4433cb1eeab9"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-a80970a1-3921-4553-9d97-02f192f66977"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -650,7 +650,7 @@ http://localhost:8000/queries.json <span class="s1">'properties'</span> <span class="o">=></span> <span class="p">{</span> <span class="s1">'items'</span> <span class="o">=></span> <span class="p">[</span><span class="s1">'<ITEM ID1>'</span><span class="p">,</span> <span class="s1">'<ITEM ID2>'</span><span class="p">]</span> <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-464f10a1-f29a-4f00-87ed-d95d2716179a"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-e4ed2ce2-6f84-4c85-ba40-4955f5433147"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4
http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/0b09b57d/templates/leadscoring/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/leadscoring/quickstart/index.html b/templates/leadscoring/quickstart/index.html index d01882a..30caf24 100644 --- a/templates/leadscoring/quickstart/index.html +++ b/templates/leadscoring/quickstart/index.html @@ -32,7 +32,7 @@ Your system is all ready to go. <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp1 | 1 | 3mZWDzci2D5YsqAnqNnXH9SB6Rg3dsTBs8iHkK6X2i54IQsIZI1eEeQQyMfs7b3F | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp2 | 2 | io5lz6Eg4m3Xe4JZTBFE13GMAf1dhFl6ZteuJfrO84XpdOz9wRCrDU44EUaYuXq5 | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> Finished listing 2 app<span class="o">(</span>s<span class="o">)</span>. -</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, Lead Scoring Engine Template supports the following entities: <strong>user</strong>, <strong>page</strong>, and <strong>item</strong>. An user views a page, and buys an item.</p><p>Note that a "sessionId" property is required to indicate these events happen in the same session. In the first visit of a user, you should specify the optional "referrral ID" and "browser" information. These are used to determine where the user comes from and the browser information.</p><p>In summary, this template requires user-view-page event and user-buy-item events with the session ID, referrer ID and browser properties.</p> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when an user with ID u0 views a URL page "example.com/page0" on time <code>2014-11-02T09:39:45.618-08:00</code>, with session ID "akdj230fj8ass" (current time will be used if eventTime is not specified) you can send the event to Event Server. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-fcd5e1c3-7987-46e7- b45f-6eeb83453eb6">REST API</a></li> <li data-lang="python"><a href="#tab-0741702d-241f-4de1-a99f-fdb26b883893">Python SDK</a></li> <li data-lang="php"><a href="#tab-95f04c4e-9357-4a59-845a-1f24800ebac9">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-fad1bf2c-c5f1-44b5-8153-cf5d0c314830">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-4f8d0bfe-4719-4270-950e-25b5d3eaf76b">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-fcd5e1c3-7987-46e7-b45f-6eeb83453eb6"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, Lead Scoring Engine Template supports the following entities: <strong>user</strong>, <strong>page</strong>, and <strong>item</strong>. An user views a page, and buys an item.</p><p>Note that a "sessionId" property is required to indicate these events happen in the same session. In the first visit of a user, you should specify the optional "referrral ID" and "browser" information. These are used to determine where the user comes from and the browser information.</p><p>In summary, this template requires user-view-page event and user-buy-item events with the session ID, referrer ID and browser properties.</p> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when an user with ID u0 views a URL page "example.com/page0" on time <code>2014-11-02T09:39:45.618-08:00</code>, with session ID "akdj230fj8ass" (current time will be used if eventTime is not specified) you can send the event to Event Server. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-816862ec-a2c3-4f25- 8c9e-dca6551f2ca0">REST API</a></li> <li data-lang="python"><a href="#tab-df5742ac-010a-43ee-baaf-38aa40d4c971">Python SDK</a></li> <li data-lang="php"><a href="#tab-77f615c0-a797-4ba0-9ce4-987818d2379d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-89e415fa-b961-4404-81db-b957e6dac5b3">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-81e14241-c952-4125-aa30-559ba85cd8fe">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-816862ec-a2c3-4f25-8c9e-dca6551f2ca0"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -61,7 +61,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:39:45.618-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-0741702d-241f-4de1-a99f-fdb26b883893"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-df5742ac-010a-43ee-baaf-38aa40d4c971"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -106,7 +106,7 @@ Your system is all ready to go. <span class="s">"browser"</span><span class="p">:</span> <span class="o"><</span><span class="n">BROWSER</span><span class="o">></span> <span class="c"># optinal. but should specify this if you have this information when user views the landing page</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-95f04c4e-9357-4a59-845a-1f24800ebac9"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-77f615c0-a797-4ba0-9ce4-987818d2379d"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -145,7 +145,7 @@ Your system is all ready to go. <span class="p">)</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-fad1bf2c-c5f1-44b5-8153-cf5d0c314830"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-89e415fa-b961-4404-81db-b957e6dac5b3"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -178,7 +178,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-4f8d0bfe-4719-4270-950e-25b5d3eaf76b"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-81e14241-c952-4125-aa30-559ba85cd8fe"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -213,7 +213,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"referrerId"</span><span class="o">,</span> <span class="s">"<REFERRER ID>"</span><span class="o">)</span> <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"browser"</span><span class="o">,</span> <span class="s">"<BROWSER>"</span><span class="o">);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">viewEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>In the same browing session "akdj230fj8ass", the user with ID u0 buys an item i0 on time <code>2014-11-02T09:42:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send the following buy event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-db78173a-a00f-42ef-9ad4-72f858fccba4">REST API</a></li> <li data-lang="python"><a href="#tab-5ab8c391-8a20-4a1d-90a7-c8a0cb5192b0">Python SDK</a></li> <li data-lang="php"><a href="#tab-65fee2d7-4ce7-475b-b778-9e06b37fbd4d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-504a127e-fff1-423b-b004-e5af98df7f6b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-3f315edf-3e07-467f-b12a-3b9bf8271266">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-db78173a-a00f-42ef-9ad4-72f858fccba4"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>In the same browing session "akdj230fj8ass", the user with ID u0 buys an item i0 on time <code>2014-11-02T09:42:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send the following buy event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-c0ee3dd0-6b2d-4bb5-8c9f-505d0c56f12d">REST API</a></li> <li data-lang="python"><a href="#tab-5ca1ad9a-9f5d-4c2d-95cb-6ced000c15ed">Python SDK</a></li> <li data-lang="php"><a href="#tab-7793d2e0-654e-4561-85a9-16d781ca3f9e">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-88fd8335-c787-463b-8f4d-869be75ca54e">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-f858827b-2e13-46ce-9ab6-b80c6c4ab74a">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-c0ee3dd0-6b2d-4bb5-8c9f-505d0c56f12d"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -238,7 +238,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:42:00.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-5ab8c391-8a20-4a1d-90a7-c8a0cb5192b0"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-5ca1ad9a-9f5d-4c2d-95cb-6ced000c15ed"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -261,7 +261,7 @@ Your system is all ready to go. <span class="s">"sessionId"</span><span class="p">:</span> <span class="o"><</span><span class="n">SESSION</span> <span class="n">ID</span><span class="o">></span><span class="p">,</span> <span class="c"># required</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-65fee2d7-4ce7-475b-b778-9e06b37fbd4d"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-7793d2e0-654e-4561-85a9-16d781ca3f9e"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -288,7 +288,7 @@ Your system is all ready to go. <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-504a127e-fff1-423b-b004-e5af98df7f6b"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-88fd8335-c787-463b-8f4d-869be75ca54e"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -311,7 +311,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-3f315edf-3e07-467f-b12a-3b9bf8271266"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-f858827b-2e13-46ce-9ab6-b80c6c4ab74a"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -371,7 +371,7 @@ User u5 buys item i5 </pre></td></tr></tbody></table> </div> <p>When the engine is deployed successfully and running, you should see a console message similar to the following:</p><div class="highlight shell"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1 2</pre></td><td class="code"><pre><span class="o">[</span>INFO] <span class="o">[</span>HttpListener] Bound to /0.0.0.0:8000 <span class="o">[</span>INFO] <span class="o">[</span>MasterActor] Bind successful. Ready to serve. -</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve the results. When a user lands on your page "example.com/page9", with referrer "referrer10.com" and browser "Firefox", you can get the predicted lead score by sending this JSON '{ "landingPageId" : "example.com/page9", "referrerId" : "referrer10.com", "browser": "Firefox" }' to the deployed engine. The engine will return a JSON with the score.</p><p>Simply send a query by making a HTTP request or through the <code>EngineClient </code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-e9d11c57-9b97-4d7a-aeef-48da508150e8">REST API</a></li> <li data-lang="python"><a href="#tab-5fbfa154-d0a5-4b9b-9499-00244e647923">Python SDK</a></li> <li data-lang="php"><a href="#tab-b51547c8-7257-4d52-9b7d-1ceaa68a0060">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-0ddfbdb6-1f2a-4603-a794-326a75c473b7">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-386534e3-6b07-4fc3-b7a4-8c6c19804dbb">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-e9d11c57-9b97-4d7a-aeef-48da508150e8"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve the results. When a user lands on your page "example.com/page9", with referrer "referrer10.com" and browser "Firefox", you can get the predicted lead score by sending this JSON '{ "landingPageId" : "example.com/page9", "referrerId" : "referrer10.com", "browser": "Firefox" }' to the deployed engine. The engine will return a JSON with the score.</p><p>Simply send a query by making a HTTP request or through the <code>EngineClient </code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-6fce22da-c8c9-48b2-ad9b-a29e5f8b8374">REST API</a></li> <li data-lang="python"><a href="#tab-7141ef5b-dd70-45c9-a79c-92869c21d4bf">Python SDK</a></li> <li data-lang="php"><a href="#tab-42827bf0-b420-4799-bc21-88bd886cbe61">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-ab9e6fab-b122-459e-a814-523103cef3c5">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-caa94668-3d00-41af-ac04-fc6a311aaf28">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-6fce22da-c8c9-48b2-ad9b-a29e5f8b8374"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -384,7 +384,7 @@ User u5 buys item i5 "browser": "Firefox" }'</span> <span class="se">\</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-5fbfa154-d0a5-4b9b-9499-00244e647923"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-7141ef5b-dd70-45c9-a79c-92869c21d4bf"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -397,7 +397,7 @@ http://localhost:8000/queries.json <span class="s">"referrerId"</span> <span class="p">:</span> <span class="s">"referrer10.com"</span><span class="p">,</span> <span class="s">"browser"</span><span class="p">:</span> <span class="s">"Firefox"</span> <span class="p">})</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-b51547c8-7257-4d52-9b7d-1ceaa68a0060"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-42827bf0-b420-4799-bc21-88bd886cbe61"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -426,7 +426,7 @@ http://localhost:8000/queries.json <span class="nb">print_r</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-0ddfbdb6-1f2a-4603-a794-326a75c473b7"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-ab9e6fab-b122-459e-a814-523103cef3c5"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -447,7 +447,7 @@ http://localhost:8000/queries.json <span class="p">)</span> <span class="nb">puts</span> <span class="n">response</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-386534e3-6b07-4fc3-b7a4-8c6c19804dbb"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-caa94668-3d00-41af-ac04-fc6a311aaf28"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4