http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/ea42f27e/templates/productranking/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/productranking/quickstart/index.html b/templates/productranking/quickstart/index.html index 0aa27c5..fade441 100644 --- a/templates/productranking/quickstart/index.html +++ b/templates/productranking/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 Product Ranking Engine Template supports 2 types of entities: <strong>user</strong> and <strong>item</strong>, and event <strong>view</strong>. A user can view an item. This template requires '$set' user event, '$set' item event and user-view-item events.</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 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-bdea6d67-f185-4c47-8df8-cda46ff3e4c4">REST API</a></li> <li data-lang="python"><a href="#tab-fff77a11-db7b-4cbb-a875-09b57ace4d10">Python SDK</a></li> <li data-lang="php"><a href="#tab-6331613f-a25e-4e24-8b3e-367d61c466e5">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7154fff4-f002-4bbf-b5cf-c29d7b477a2d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-00a59fc4-308c-488e -87b7-e00d02ae79c4">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-bdea6d67-f185-4c47-8df8-cda46ff3e4c4"> <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 Product Ranking Engine Template supports 2 types of entities: <strong>user</strong> and <strong>item</strong>, and event <strong>view</strong>. A user can view an item. This template requires '$set' user event, '$set' item event and user-view-item events.</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 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-a6f605dc-6c08-4f39-b14b-069bbbaa6320">REST API</a></li> <li data-lang="python"><a href="#tab-cf530b1c-2cef-44d0-9bc9-2521f6ebdaa3">Python SDK</a></li> <li data-lang="php"><a href="#tab-835cccfb-984a-43c2-845e-4c473e6d2384">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-9fb553ec-fe3d-4384-82fd-e4ee05b4d831">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-17c1a1b7-b698-4900 -86ad-4aa69f27036d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a6f605dc-6c08-4f39-b14b-069bbbaa6320"> <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-fff77a11-db7b-4cbb-a875-09b57ace4d10"> <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-cf530b1c-2cef-44d0-9bc9-2521f6ebdaa3"> <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-6331613f-a25e-4e24-8b3e-367d61c466e5"> <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-835cccfb-984a-43c2-845e-4c473e6d2384"> <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 @@ -103,7 +103,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-7154fff4-f002-4bbf-b5cf-c29d7b477a2d"> <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-9fb553ec-fe3d-4384-82fd-e4ee05b4d831"> <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 @@ -120,7 +120,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-00a59fc4-308c-488e-87b7-e00d02ae79c4"> <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-17c1a1b7-b698-4900-86ad-4aa69f27036d"> <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 @@ -145,7 +145,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. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-49a249af-5d97-4448-ab54-aae631219ea8">REST API</a></li> <li data-lang="python"><a href="#tab-52ea3a40-c794-4807-8101-aea6dd67fc60">Python SDK</a></li> <li data-lang="php"><a href="#tab-3c4896ea-005a-4ddb-a007-0517159650f9">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-bb8955be-bb83-41f5-94e4-de29ef227c56">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-39c0fc47-d4e2-4804-b7a1-b10614d3dbc3">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-49a249af-5d97-4448-ab54-aae631219ea8"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td cla ss="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. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-4fba13f4-b5b8-4e24-af66-e587ae87a31f">REST API</a></li> <li data-lang="python"><a href="#tab-c7f24985-9373-4a9a-a47c-4076ebacf9cb">Python SDK</a></li> <li data-lang="php"><a href="#tab-64c5b107-84b3-401b-b4e2-788f60e9739b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-175a2a4d-6ffc-4c62-be4b-cd64d0c7cdff">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6229cfb6-8d28-4c0c-8e2b-c9a46a483895">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-4fba13f4-b5b8-4e24-af66-e587ae87a31f"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td cla ss="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -160,7 +160,7 @@ Your system is all ready to go. "entityId" : "i0", "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-52ea3a40-c794-4807-8101-aea6dd67fc60"> <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-c7f24985-9373-4a9a-a47c-4076ebacf9cb"> <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 @@ -173,7 +173,7 @@ Your system is all ready to go. <span class="n">entity_type</span><span class="o">=</span><span class="s">"item"</span><span class="p">,</span> <span class="n">entity_id</span><span class="o">=<</span><span class="n">ITEM_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-3c4896ea-005a-4ddb-a007-0517159650f9"> <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-64c5b107-84b3-401b-b4e2-788f60e9739b"> <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 @@ -190,7 +190,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-bb8955be-bb83-41f5-94e4-de29ef227c56"> <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-175a2a4d-6ffc-4c62-be4b-cd64d0c7cdff"> <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 @@ -203,7 +203,7 @@ Your system is all ready to go. <span class="o"><</span><span class="no">ITEM</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-39c0fc47-d4e2-4804-b7a1-b10614d3dbc3"> <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-6229cfb6-8d28-4c0c-8e2b-c9a46a483895"> <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 @@ -214,7 +214,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">entityType</span><span class="o">(</span><span class="s">"item"</span><span class="o">)</span> <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="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-3d7d10ae-9f30-4664-8a0f-4485ab9c4214">REST API</a></li> <li data-lang="python"><a href="#tab-db849450-970c-4b5d-94a7-44411d2c939e">Python SDK</a></li> <li data-lang="php"><a href="#tab-98c934ce-74dc-49c1-bd7c-f40aa7a614e0">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-aaa11a32-804e-4b28-97ef-bcab4e02c045">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-9f7e9c5f-eadf-4ff3-9168-f12a810bad8c">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-3d7d10ae-9f30-4664-8a0f-4485ab9c4214"> <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-fce6418f-2a1f-4b65-999a-056236a3f7af">REST API</a></li> <li data-lang="python"><a href="#tab-92cde62d-cdf0-4a2c-86fa-c1e44ee015c7">Python SDK</a></li> <li data-lang="php"><a href="#tab-dcf5dce4-e284-496d-a854-9f848fb1e395">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a14846fc-db03-4adb-9391-daf84177b300">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-dfa306a9-e711-4ba9-9c72-fbdc3fc49a39">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-fce6418f-2a1f-4b65-999a-056236a3f7af"> <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 @@ -233,7 +233,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-db849450-970c-4b5d-94a7-44411d2c939e"> <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-92cde62d-cdf0-4a2c-86fa-c1e44ee015c7"> <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 @@ -250,7 +250,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-98c934ce-74dc-49c1-bd7c-f40aa7a614e0"> <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-dcf5dce4-e284-496d-a854-9f848fb1e395"> <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 @@ -269,7 +269,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-aaa11a32-804e-4b28-97ef-bcab4e02c045"> <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-a14846fc-db03-4adb-9391-daf84177b300"> <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 @@ -286,7 +286,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-9f7e9c5f-eadf-4ff3-9168-f12a810bad8c"> <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-dfa306a9-e711-4ba9-9c72-fbdc3fc49a39"> <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 @@ -344,14 +344,14 @@ User u10 views item i7 </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 rank items with IDs "i1", "i3", "i10", "i2", "i5", "i31", "i9" for user "u2". You send this JSON <code>{ "user": "u2", "items": ["i1", "i3", "i10", "i2", "i5", "i31", "i9"] }</code> to the deployed engine and it will return a JSON of the ranked items. Simply send a query by making a HTTP request or through the <code>EngineCl ient</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-a436c259-d3cb-4b62-b951-1397f431dd6d">REST API</a></li> <li data-lang="python"><a href="#tab-ba373b6f-4d20-4b66-bb10-c01b93c3b683">Python SDK</a></li> <li data-lang="php"><a href="#tab-641ecfc4-4674-4335-aea7-4c45bc05dd4d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-2e62f4fc-a74a-48b8-b337-5811055a19ec">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-60ed0760-e8d0-433d-8af1-720b239acdc6">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a436c259-d3cb-4b62-b951-1397f431dd6d"> <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 rank items with IDs "i1", "i3", "i10", "i2", "i5", "i31", "i9" for user "u2". You send this JSON <code>{ "user": "u2", "items": ["i1", "i3", "i10", "i2", "i5", "i31", "i9"] }</code> to the deployed engine and it will return a JSON of the ranked items. Simply send a query by making a HTTP request or through the <code>EngineCl ient</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-5e6fa503-446c-4ea4-b071-403d96e2a873">REST API</a></li> <li data-lang="python"><a href="#tab-0b20ed74-c00e-4121-98f0-7f95a8bfa9c3">Python SDK</a></li> <li data-lang="php"><a href="#tab-ba41a481-553d-45c5-86fd-3434ba5e3ce1">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-ab177e95-1377-4218-98bd-d8b2c9d92b56">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-d8feadbf-a5ca-412c-8cc0-8aef5bb2f718">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-5e6fa503-446c-4ea4-b071-403d96e2a873"> <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">'{ "user": "u2", "items": ["i1", "i3", "i10", "i2", "i5", "i31", "i9"]}'</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-ba373b6f-4d20-4b66-bb10-c01b93c3b683"> <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-0b20ed74-c00e-4121-98f0-7f95a8bfa9c3"> <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 @@ -362,7 +362,7 @@ http://localhost:8000/queries.json <span class="s">"user"</span><span class="p">:</span> <span class="s">"u2"</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">"i3"</span><span class="p">,</span> <span class="s">"i10"</span><span class="p">,</span> <span class="s">"i2"</span><span class="p">,</span> <span class="s">"i5"</span><span class="p">,</span> <span class="s">"i31"</span><span class="p">,</span> <span class="s">"i9"</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-641ecfc4-4674-4335-aea7-4c45bc05dd4d"> <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-ba41a481-553d-45c5-86fd-3434ba5e3ce1"> <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 @@ -385,7 +385,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-2e62f4fc-a74a-48b8-b337-5811055a19ec"> <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-ab177e95-1377-4218-98bd-d8b2c9d92b56"> <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 @@ -402,7 +402,7 @@ http://localhost:8000/queries.json <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">'i3'</span><span class="p">,</span> <span class="s1">'i10'</span><span class="p">,</span> <span class="s1">'i2'</span><span class="p">,</span> <span class="s1">'i5'</span><span class="p">,</span> <span class="s1">'i31'</span><span class="p">,</span> <span class="s1">'i9'</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-60ed0760-e8d0-433d-8af1-720b239acdc6"> <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-d8feadbf-a5ca-412c-8cc0-8aef5bb2f718"> <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/ea42f27e/templates/recommendation/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/recommendation/quickstart/index.html b/templates/recommendation/quickstart/index.html index a2ff51a..3075364 100644 --- a/templates/recommendation/quickstart/index.html +++ b/templates/recommendation/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. By default, the Recommendation Engine Template supports 2 types of events: <strong>rate</strong> and <strong>buy</strong>. A user can give a rating score to an item or buy an item. This template requires user-view-item and user-buy-item events.</p><div class="alert-message info"><p>This template can easily be customized to consider more user events such as <em>like</em>, <em>dislike</em> etc.</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> <h3 id='example-<strong>rate</strong>-event' class='header-anchors' >Example <strong>rate</strong> event</h3><p>A user (ID "u0") gives an item (ID "i0") a rating of 5 at <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified)</p><p>Run the following <code>curl</code> command to send the <code>rate</code> event:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-a723f572-e813-4213-8447-1a4542c8ed0f">REST API</a></li> <li data-lang="python"><a href="#tab-2ffaf21e-742f-41a4-983b-4dbcae8cb60f">Python SDK</a></li> <li data-lang="php"><a href="#tab-d798ec7f-2153-4a03-a3d1-5256df4733e2">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-cb7f3ea7-b38b-438a-93a7-79875dab360a">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-3255ee72-9024-42e5-b919-97c70bf0a7ab">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a723f572-e813-4213-8447-1a4542c8ed0f"> <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. By default, the Recommendation Engine Template supports 2 types of events: <strong>rate</strong> and <strong>buy</strong>. A user can give a rating score to an item or buy an item. This template requires user-view-item and user-buy-item events.</p><div class="alert-message info"><p>This template can easily be customized to consider more user events such as <em>like</em>, <em>dislike</em> etc.</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> <h3 id='example-<strong>rate</strong>-event' class='header-anchors' >Example <strong>rate</strong> event</h3><p>A user (ID "u0") gives an item (ID "i0") a rating of 5 at <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified)</p><p>Run the following <code>curl</code> command to send the <code>rate</code> event:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-be567590-9f70-4257-8f14-26313b90ad29">REST API</a></li> <li data-lang="python"><a href="#tab-5607e760-5309-4b64-9969-f8b8edb7c2e8">Python SDK</a></li> <li data-lang="php"><a href="#tab-2c79bf37-3c0b-4854-b8b0-afe3bc0585f0">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-79464fa1-5306-4469-bb77-519e163e8316">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-deb15f10-b66e-467a-aac1-00faf9ac3d13">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-be567590-9f70-4257-8f14-26313b90ad29"> <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 @@ -57,7 +57,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-2ffaf21e-742f-41a4-983b-4dbcae8cb60f"> <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-5607e760-5309-4b64-9969-f8b8edb7c2e8"> <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 @@ -92,7 +92,7 @@ Your system is all ready to go. <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> <span class="n">properties</span><span class="o">=</span> <span class="p">{</span> <span class="s">"rating"</span> <span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="o"><</span><span class="n">RATING</span><span class="o">></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-d798ec7f-2153-4a03-a3d1-5256df4733e2"> <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-2c79bf37-3c0b-4854-b8b0-afe3bc0585f0"> <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 @@ -123,7 +123,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">'rating'</span><span class="o">=></span> <span class="o"><</span><span class="nx">RATING</span><span class="o">></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-cb7f3ea7-b38b-438a-93a7-79875dab360a"> <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-79464fa1-5306-4469-bb77-519e163e8316"> <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 @@ -150,7 +150,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-3255ee72-9024-42e5-b919-97c70bf0a7ab"> <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-deb15f10-b66e-467a-aac1-00faf9ac3d13"> <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 @@ -179,7 +179,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"rating"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Float</span><span class="o">(<</span><span class="n">RATING</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">rateEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <h3 id='example-<strong>buy</strong>-event' class='header-anchors' >Example <strong>buy</strong> event</h3><p>A user (ID "u1") buys an item (ID "i2") at <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified)</p><p>Run the following <code>curl</code> command to send the <code>buy</code> event:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-aaaa0473-7dc5-4039-a6e4-a54dcc0aa643">REST API</a></li> <li data-lang="python"><a href="#tab-115012fd-14af-4254-acf1-6a2a996bf94e">Python SDK</a></li> <li data-lang="php"><a href="#tab-cbdb93d7-523a-40f0-a962-94e80fcdbbf5">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-62a6132e-c678-40f6-b559-cfa3df833f7a">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-29d216d7-06ee-4a66-a17a-be97ff6df4ad">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-aaaa0473-7dc5-4039-a6e4-a5 4dcc0aa643"> <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> <h3 id='example-<strong>buy</strong>-event' class='header-anchors' >Example <strong>buy</strong> event</h3><p>A user (ID "u1") buys an item (ID "i2") at <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified)</p><p>Run the following <code>curl</code> command to send the <code>buy</code> event:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-180be234-4f79-49ba-8e4c-a504362dd36c">REST API</a></li> <li data-lang="python"><a href="#tab-04ad3f0d-25c2-458b-b99e-4f755c36ec62">Python SDK</a></li> <li data-lang="php"><a href="#tab-53c09919-9e7b-4179-9968-5c6118a886a8">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-d90b14fa-eb03-42e1-8297-11cff42cb07d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-d5b43b6f-7d96-40fa-8afc-17e07898a0ac">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-180be234-4f79-49ba-8e4c-a5 04362dd36c"> <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 @@ -198,7 +198,7 @@ Your system is all ready to go. "targetEntityId" : "i2", "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-115012fd-14af-4254-acf1-6a2a996bf94e"> <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-04ad3f0d-25c2-458b-b99e-4f755c36ec62"> <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 @@ -213,7 +213,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-cbdb93d7-523a-40f0-a962-94e80fcdbbf5"> <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-53c09919-9e7b-4179-9968-5c6118a886a8"> <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 @@ -232,7 +232,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-62a6132e-c678-40f6-b559-cfa3df833f7a"> <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-d90b14fa-eb03-42e1-8297-11cff42cb07d"> <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 @@ -249,7 +249,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-29d216d7-06ee-4a66-a17a-be97ff6df4ad"> <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-d5b43b6f-7d96-40fa-8afc-17e07898a0ac"> <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 @@ -297,17 +297,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. To recommend 4 movies to user whose id is 1, you send this JSON <code>{ "user": "1", "num": 4 }</code> to the deployed engine and it will return a JSON of the recommended movies. 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-94dbf955-6b4d-44b6-8624-b15159178dfb">REST API</a></li> <li data-lang="python"><a href="#tab-02364be3-19e6-4aa5-82ee-82e57120cd53">Python SDK</a></li> <li data-lang="php"><a href="#tab-d89d5f35-d906-471e-ae0a-f70570851369">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-81d5274a-2181-45cd-a963-a882152bcefa">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-04794adc-2884-443f-aa29-1114344dbd9f">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-94dbf955-6b4d-44b6-8624-b15159178dfb"> <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. To recommend 4 movies to user whose id is 1, you send this JSON <code>{ "user": "1", "num": 4 }</code> to the deployed engine and it will return a JSON of the recommended movies. 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-687c5331-b15c-460c-b0fc-cc0fbbf9b6f7">REST API</a></li> <li data-lang="python"><a href="#tab-737e5c40-c8c7-4a20-b202-b898a51f1e5d">Python SDK</a></li> <li data-lang="php"><a href="#tab-a58476c8-cf59-4f0f-9ad0-8f3fd6e18760">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-d269ceab-08bc-46c8-88c1-ca9ade9c4478">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-48461b9b-70f7-49f5-a7d5-9e219a41b5a8">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-687c5331-b15c-460c-b0fc-cc0fbbf9b6f7"> <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">'{ "user": "1", "num": 4 }'</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-02364be3-19e6-4aa5-82ee-82e57120cd53"> <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-737e5c40-c8c7-4a20-b202-b898a51f1e5d"> <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">"user"</span><span class="p">:</span> <span class="s">"1"</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-d89d5f35-d906-471e-ae0a-f70570851369"> <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-a58476c8-cf59-4f0f-9ad0-8f3fd6e18760"> <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 @@ -326,7 +326,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-81d5274a-2181-45cd-a963-a882152bcefa"> <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-d269ceab-08bc-46c8-88c1-ca9ade9c4478"> <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 @@ -339,7 +339,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">'user'</span> <span class="o">=></span> <span class="o"><</span><span class="no">USER</span> <span class="no">ID</span><span class="o">></span><span class="p">,</span> <span class="s1">'num'</span> <span class="o">=></span> <span class="o"><</span><span class="no">NUMBER</span> <span class="p">(</span><span class="n">integer</span><span class="p">)</span><span class="o">></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-04794adc-2884-443f-aa29-1114344dbd9f"> <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-48461b9b-70f7-49f5-a7d5-9e219a41b5a8"> <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/ea42f27e/templates/similarproduct/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/similarproduct/quickstart/index.html b/templates/similarproduct/quickstart/index.html index 5cdbebe..0b06678 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-f40019d7-4bd0-4934-b277-58da1c6f8078">REST API</a></li> <li data-lang="python"><a href="#tab-7132b3a4-bc a9-434c-86f2-b05ce425d189">Python SDK</a></li> <li data-lang="php"><a href="#tab-13b31100-7616-4d25-90a0-a493c77131ff">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-3ec31518-25a3-4d66-8abc-f88b399ab709">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6c259fbd-760b-4a68-bcf0-e58eec684635">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-f40019d7-4bd0-4934-b277-58da1c6f8078"> <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-342dddb8-5991-4845-908c-639f9961184f">REST API</a></li> <li data-lang="python"><a href="#tab-d84a36ca-48 4a-4ca5-952b-6adbc4b5d4b8">Python SDK</a></li> <li data-lang="php"><a href="#tab-db7c78fd-2185-42f7-bed3-9b965f1b1baf">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-040b3679-f1dd-4c36-8f53-f839a7abd75d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-b2ef4fb1-bac9-4224-a3c1-87a17a10ab35">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-342dddb8-5991-4845-908c-639f9961184f"> <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-7132b3a4-bca9-434c-86f2-b05ce425d189"> <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-d84a36ca-484a-4ca5-952b-6adbc4b5d4b8"> <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-13b31100-7616-4d25-90a0-a493c77131ff"> <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-db7c78fd-2185-42f7-bed3-9b965f1b1baf"> <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-3ec31518-25a3-4d66-8abc-f88b399ab709"> <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-040b3679-f1dd-4c36-8f53-f839a7abd75d"> <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-6c259fbd-760b-4a68-bcf0-e58eec684635"> <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-b2ef4fb1-bac9-4224-a3c1-87a17a10ab35"> <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-f7399256-dc2e-496f-827f-ce5c459fd084">REST API</a></li> <li data-lang="python"><a href="#tab-cbdc8c75-a266-4b8f-a631-d1e3cc7cdd57">Python SDK</a></li> <li data-lang="php"><a href="#tab-9a753496-bb07-4392-8334-1a43333b7469">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-8f439849-9f6f-4529-a459-d5e8add1a367">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-ac6276f3-02e8-4d8f-8424-4df43cd1d862">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-f73992 56-dc2e-496f-827f-ce5c459fd084"> <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-8e55b0f0-5e83-4024-a3ab-087b12099f22">REST API</a></li> <li data-lang="python"><a href="#tab-bc95e648-ebfd-4ade-8b99-b439749078a1">Python SDK</a></li> <li data-lang="php"><a href="#tab-f500c76c-fd4e-4bfb-b4cf-62cee92acd5f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-d18adff4-080d-4afe-8436-8994d21bee1c">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c35c8143-ddf0-40bc-9dff-8867385d348c">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-8e55b0 f0-5e83-4024-a3ab-087b12099f22"> <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-cbdc8c75-a266-4b8f-a631-d1e3cc7cdd57"> <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-bc95e648-ebfd-4ade-8b99-b439749078a1"> <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-9a753496-bb07-4392-8334-1a43333b7469"> <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-f500c76c-fd4e-4bfb-b4cf-62cee92acd5f"> <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-8f439849-9f6f-4529-a459-d5e8add1a367"> <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-d18adff4-080d-4afe-8436-8994d21bee1c"> <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-ac6276f3-02e8-4d8f-8424-4df43cd1d862"> <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-c35c8143-ddf0-40bc-9dff-8867385d348c"> <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-65058cd7-c162-43b6-b5de-e2b7a510baf6">REST API</a></li> <li data-lang="python"><a href="#tab-8e08951b-3315-40a1-9339-f6508cb07de7">Python SDK</a></li> <li data-lang="php"><a href="#tab-350e4432-a180-4165-96ca-95414663a780">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-e77a8023-31c5-427d-979c-179475b4a2fc">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-469fdfd8-48cc-4752-82b4-d768bb84e075">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-65058cd7-c162-43b6-b5de-e2b7a510baf6"> <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-3ae9a84d-79dd-4fe9-8c74-d1472c0d61af">REST API</a></li> <li data-lang="python"><a href="#tab-740de5fa-e2d5-4757-b8b0-7a385c566e8e">Python SDK</a></li> <li data-lang="php"><a href="#tab-2acd5be5-5a7b-4487-aa93-158e4729a16f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-625e17c5-938b-4c3d-a8c3-8470e36e96e2">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-9ac4d826-ef7b-459a-b684-2d65ce9cbfce">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-3ae9a84d-79dd-4fe9-8c74-d1472c0d61af"> <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-8e08951b-3315-40a1-9339-f6508cb07de7"> <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-740de5fa-e2d5-4757-b8b0-7a385c566e8e"> <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-350e4432-a180-4165-96ca-95414663a780"> <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-2acd5be5-5a7b-4487-aa93-158e4729a16f"> <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-e77a8023-31c5-427d-979c-179475b4a2fc"> <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-625e17c5-938b-4c3d-a8c3-8470e36e96e2"> <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-469fdfd8-48cc-4752-82b4-d768bb84e075"> <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-9ac4d826-ef7b-459a-b684-2d65ce9cbfce"> <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-04ac38b7-0758-4aa7-8ec3-46416d9728b4">REST API</a></li> <li data-lang="python"><a href="#tab-28c3166f-7819-4c32-bbb4-b73340219be1">Python SDK</a></li> <li data-lang="php"><a href="#tab-d0b35d64-152d-4bae-bc5b-0e6e56ea187f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7cfac49e-fd9b-4c96-b6a3-6f0945f33ecb">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-bfcbc7db-11b6-4643-a622-06cbaf36d3d2">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-04ac38b7-0758-4aa7-8ec3-46416d9728b4"> <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-9afe3f91-7b28-4c9e-9a58-9fa0019c5dc4">REST API</a></li> <li data-lang="python"><a href="#tab-422120a6-c6e5-4cd7-8c0d-bb5acdbf1ef3">Python SDK</a></li> <li data-lang="php"><a href="#tab-c889c1fd-355a-400f-af57-2ee97392215b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-be27b122-55e8-46ab-9f4a-ee67266fcb4d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-adcd4d52-c107-4534-bb69-fbb17400f822">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-9afe3f91-7b28-4c9e-9a58-9fa0019c5dc4"> <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-28c3166f-7819-4c32-bbb4-b73340219be1"> <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-422120a6-c6e5-4cd7-8c0d-bb5acdbf1ef3"> <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-d0b35d64-152d-4bae-bc5b-0e6e56ea187f"> <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-c889c1fd-355a-400f-af57-2ee97392215b"> <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-7cfac49e-fd9b-4c96-b6a3-6f0945f33ecb"> <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-be27b122-55e8-46ab-9f4a-ee67266fcb4d"> <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-bfcbc7db-11b6-4643-a622-06cbaf36d3d2"> <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-adcd4d52-c107-4534-bb69-fbb17400f822"> <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