Repository: predictionio-site Updated Branches: refs/heads/asf-site 0b09b57d7 -> 9fe018b6a
http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/9fe018b6/templates/similarproduct/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/similarproduct/quickstart/index.html b/templates/similarproduct/quickstart/index.html index 532b26a..7240ee3 100644 --- a/templates/similarproduct/quickstart/index.html +++ b/templates/similarproduct/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 some training data for the app of this Engine. By default, the Similar Product Engine Template supports 2 types of entities: <strong>user</strong> and <strong>item</strong>, and event <strong>view</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view an item. Respectively, this template requires '$set' user event, '$set' item event, and user-view-item events.</p><div class="alert-message info"><p>This template can easily be customized to consider more user events such as <em>buy</em>, <em>rate</em> and <em>like</em>.</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 detai ls 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-2b39b33f-4b82-4819-9c47-74b1bfe2ad18">REST API</a></li> <li data-lang="python"><a href="#tab-2d51424a-7b c8-4d3a-a82d-0c1425cec395">Python SDK</a></li> <li data-lang="php"><a href="#tab-a4f5839b-6273-4215-aeb8-e6050fca6ccb">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-06c6ead6-b0a7-42fb-b6e5-a90edde17766">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-cec5669a-e265-4141-bf08-2e44821d71f9">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-2b39b33f-4b82-4819-9c47-74b1bfe2ad18"> <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 some training data for the app of this Engine. By default, the Similar Product Engine Template supports 2 types of entities: <strong>user</strong> and <strong>item</strong>, and event <strong>view</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view an item. Respectively, this template requires '$set' user event, '$set' item event, and user-view-item events.</p><div class="alert-message info"><p>This template can easily be customized to consider more user events such as <em>buy</em>, <em>rate</em> and <em>like</em>.</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 detai ls 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-7dd3f7e3-1863-4fe6-ab7b-918c32b5f71c">REST API</a></li> <li data-lang="python"><a href="#tab-0737729a-00 3f-40e2-8434-2b8b684ebd8a">Python SDK</a></li> <li data-lang="php"><a href="#tab-e31430b3-81b5-4e0e-894e-9bf65895bd9f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-268f02b7-3e99-4a3a-8f55-b52f8c0e9976">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-5009de1f-f5e2-4e7d-9d1c-845aaa8b28e6">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-7dd3f7e3-1863-4fe6-ab7b-918c32b5f71c"> <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-2d51424a-7bc8-4d3a-a82d-0c1425cec395"> <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-0737729a-003f-40e2-8434-2b8b684ebd8a"> <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 @@ -86,7 +86,7 @@ Your system is all ready to go. <span class="n">event_time</span><span class="o">=</span><span class="n">datetime</span><span class="p">(</span> <span class="mi">2014</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mo">02</span><span class="p">,</span> <span class="mi">09</span><span class="p">,</span> <span class="mi">39</span><span class="p">,</span> <span class="mi">45</span><span class="p">,</span> <span class="mi">618000</span><span class="p">,</span> <span class="n">pytz</span><span class="o">.</span><span class="n">timezone</span><span class="p">(</span><span class="s">'US/Pacific'</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-a4f5839b-6273-4215-aeb8-e6050fca6ccb"> <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-e31430b3-81b5-4e0e-894e-9bf65895bd9f"> <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 @@ -111,7 +111,7 @@ Your system is all ready to go. <span class="s1">'entityId'</span> <span class="o">=></span> <span class="o"><</span><span class="nx">USER</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-06c6ead6-b0a7-42fb-b6e5-a90edde17766"> <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-268f02b7-3e99-4a3a-8f55-b52f8c0e9976"> <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 @@ -128,7 +128,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-cec5669a-e265-4141-bf08-2e44821d71f9"> <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-5009de1f-f5e2-4e7d-9d1c-845aaa8b28e6"> <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 @@ -153,7 +153,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-3ab5cc25-371f-4db8-bbce-ff5b3a686268">REST API</a></li> <li data-lang="python"><a href="#tab-cc262c56-91cd-48b1-851d-a55a729cf594">Python SDK</a></li> <li data-lang="php"><a href="#tab-4f6d39d0-c138-4b0a-b150-e945ba62015a">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-c064a30b-cf9c-444f-bb9c-1f7550cf2e46">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-891c46b1-d783-4fc1-a7f7-b714dd42a5df">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-3ab5cc 25-371f-4db8-bbce-ff5b3a686268"> <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-b8b08c24-3861-4c68-8196-dd349d933463">REST API</a></li> <li data-lang="python"><a href="#tab-dc2baea2-f472-4170-8867-bf9234e56d22">Python SDK</a></li> <li data-lang="php"><a href="#tab-d25e7708-ba78-4d45-8ceb-92184396d202">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a205da60-2975-44fa-b692-371483a90653">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-a6f492e3-03c6-4627-8567-772c31632118">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-b8b08c 24-3861-4c68-8196-dd349d933463"> <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 @@ -174,7 +174,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-cc262c56-91cd-48b1-851d-a55a729cf594"> <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-dc2baea2-f472-4170-8867-bf9234e56d22"> <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 @@ -193,7 +193,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-4f6d39d0-c138-4b0a-b150-e945ba62015a"> <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-d25e7708-ba78-4d45-8ceb-92184396d202"> <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 @@ -214,7 +214,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-c064a30b-cf9c-444f-bb9c-1f7550cf2e46"> <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-a205da60-2975-44fa-b692-371483a90653"> <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 @@ -231,7 +231,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-891c46b1-d783-4fc1-a7f7-b714dd42a5df"> <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-a6f492e3-03c6-4627-8567-772c31632118"> <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 @@ -244,7 +244,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>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-ae6bea39-bb41-46ad-93a0-0a91a5322cfa">REST API</a></li> <li data-lang="python"><a href="#tab-57018aca-91b3-469e-b1d0-0ea3fe3c7588">Python SDK</a></li> <li data-lang="php"><a href="#tab-f2c17f6f-b4b2-4a37-a63a-dc10996bae27">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-42b5229d-61f6-4440-8e73-131b2a58da8d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-51e23cd3-96e3-4a77-ac07-98c4bb31cf1e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-ae6bea39-bb41-46ad-93a0-0a91a5322cfa"> <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" 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-daaf6f75-8c9f-4a74-bd94-06c562bf6684">REST API</a></li> <li data-lang="python"><a href="#tab-88053ad4-1118-43e6-b536-1d7c6a90100a">Python SDK</a></li> <li data-lang="php"><a href="#tab-fd46d144-b7d0-4f02-923a-307656ee0ca1">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-e7b32bd1-d6e8-4154-8ef7-5275bd89dc70">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-5b5548bb-c6f5-4f1a-955a-b93b8a69bbc4">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-daaf6f75-8c9f-4a74-bd94-06c562bf6684"> <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 @@ -263,7 +263,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-57018aca-91b3-469e-b1d0-0ea3fe3c7588"> <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-88053ad4-1118-43e6-b536-1d7c6a90100a"> <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 @@ -280,7 +280,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-f2c17f6f-b4b2-4a37-a63a-dc10996bae27"> <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-fd46d144-b7d0-4f02-923a-307656ee0ca1"> <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 @@ -299,7 +299,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-42b5229d-61f6-4440-8e73-131b2a58da8d"> <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-e7b32bd1-d6e8-4154-8ef7-5275bd89dc70"> <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 @@ -316,7 +316,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-51e23cd3-96e3-4a77-ac07-98c4bb31cf1e"> <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-5b5548bb-c6f5-4f1a-955a-b93b8a69bbc4"> <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 @@ -376,19 +376,19 @@ User u10 views item i29 </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 retrieve 4 items which are similar to item ID "i1". You send this JSON <code>{ "items": ["i1"], "num": 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 data-lang="json"><a href="#tab-efdbd9f9-1fb2-4257-9bfa-df3b07111253">REST API</a></li> <li data-lang="python"><a href="#tab-053feaef-7d60-4309-a48b-601ee8fb308d">Python SDK</a></li> <li data-lang="php"><a href="#tab-f1171e80-8503-4912-ab4e-3d8193e638a0">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-0bc54bd3-13af-48e5-9f47-e1531d5d8249">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-45cca626-f6a3-4f06-92d0-7e6a832dc6d0">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-efdbd9f9-1fb2-4257-9bfa-df3b07111253"> <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 retrieve 4 items which are similar to item ID "i1". You send this JSON <code>{ "items": ["i1"], "num": 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 data-lang="json"><a href="#tab-6743571a-3044-413c-84de-3f7f484a831c">REST API</a></li> <li data-lang="python"><a href="#tab-14e6ac0f-0c4f-4f9e-b656-a6dba1cebbb4">Python SDK</a></li> <li data-lang="php"><a href="#tab-7d52fac7-992f-4332-87d0-821adb786d19">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-6f4f7902-5320-41a1-8968-25fdf05011b5">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-75c190e6-4d32-4949-8b7a-c5e597bd78cb">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-6743571a-3044-413c-84de-3f7f484a831c"> <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">'{ "items": ["i1"], "num": 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-053feaef-7d60-4309-a48b-601ee8fb308d"> <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-14e6ac0f-0c4f-4f9e-b656-a6dba1cebbb4"> <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">"items"</span><span class="p">:</span> <span class="p">[</span><span class="s">"i1"</span><span class="p">],</span> <span class="s">"num"</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-f1171e80-8503-4912-ab4e-3d8193e638a0"> <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-7d52fac7-992f-4332-87d0-821adb786d19"> <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 @@ -407,7 +407,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-0bc54bd3-13af-48e5-9f47-e1531d5d8249"> <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-6f4f7902-5320-41a1-8968-25fdf05011b5"> <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 @@ -420,7 +420,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">'items'</span> <span class="o">=></span> <span class="p">[</span><span class="s1">'i1'</span><span class="p">],</span> <span class="s1">'num'</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-45cca626-f6a3-4f06-92d0-7e6a832dc6d0"> <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-75c190e6-4d32-4949-8b7a-c5e597bd78cb"> <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/9fe018b6/templates/vanilla/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/vanilla/quickstart/index.html b/templates/vanilla/quickstart/index.html index edf8ea8..bc2198b 100644 --- a/templates/vanilla/quickstart/index.html +++ b/templates/vanilla/quickstart/index.html @@ -54,17 +54,17 @@ Your system is all ready to go. </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 try to retrieve predicted results. The engine accepts JSON query with the field 'q': <code>{ "q" : "foo" }</code>. A prefix is added to the query data and return as PredictedResult.</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-86ef6c53-812c-45d2-94cc-9690c479484c">REST API</a></li> <li data-lang="python"><a href="#tab-0b2c30c6-0474-4b b5-bb7d-7ad80e1724b7">Python SDK</a></li> <li data-lang="php"><a href="#tab-9470e6dc-c764-4031-bcc7-21afbc44b562">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4b6f44de-84dd-4dee-9a44-2a3d8bd98ea5">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c1d32e81-a3c9-4b8b-bc7b-90972f853e68">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-86ef6c53-812c-45d2-94cc-9690c479484c"> <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 try to retrieve predicted results. The engine accepts JSON query with the field 'q': <code>{ "q" : "foo" }</code>. A prefix is added to the query data and return as PredictedResult.</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-90119395-7e3b-4af2-918c-f66562180720">REST API</a></li> <li data-lang="python"><a href="#tab-50f262a5-bb22-4f 64-8b59-052759cb612f">Python SDK</a></li> <li data-lang="php"><a href="#tab-72bb10e5-4abe-4276-9e0f-3da6c529143e">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-de256802-2103-4726-9cea-f729ee2e1fc4">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-faa41ae9-68ea-46c8-8775-cdf452c23153">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-90119395-7e3b-4af2-918c-f66562180720"> <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</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">'{ "q": "foo" }'</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-0b2c30c6-0474-4bb5-bb7d-7ad80e1724b7"> <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-50f262a5-bb22-4f64-8b59-052759cb612f"> <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">"q"</span><span class="p">:</span> <span class="s">"foo"</span> <span class="p">})</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-9470e6dc-c764-4031-bcc7-21afbc44b562"> <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-72bb10e5-4abe-4276-9e0f-3da6c529143e"> <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 @@ -83,7 +83,7 @@ Your system is all ready to go. <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-4b6f44de-84dd-4dee-9a44-2a3d8bd98ea5"> <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-de256802-2103-4726-9cea-f729ee2e1fc4"> <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 @@ -96,7 +96,7 @@ Your system is all ready to go. <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">'q'</span> <span class="o">=></span> <span class="s1">'foo'</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-c1d32e81-a3c9-4b8b-bc7b-90972f853e68"> <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-faa41ae9-68ea-46c8-8775-cdf452c23153"> <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