http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/productranking/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/productranking/quickstart/index.html b/templates/productranking/quickstart/index.html index ef5e451..7261713 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. N ote 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-e1b268c8-f333-4ba0-b9ab-a5004a777f78">REST API</a></li> <li data-lang="python"><a href="#tab-3c5b9925-83d1-4b10-ad44-0f3d5fe3e970">Python SDK</a></li> <li data-lang="php"><a href="#tab-d21c862b-b400-496f-8f1c-78a3968ccdd7">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-590dd119-cabe-4a58-8618-1403f9682659">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-5223e50e-28e7-4374- 8236-0388f688e1be">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-e1b268c8-f333-4ba0-b9ab-a5004a777f78"> <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. N ote 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-cbd9eb52-e816-4c5d-b7fd-f2d44ff6d09a">REST API</a></li> <li data-lang="python"><a href="#tab-9ec46afa-91df-46b9-8108-ebd88d5aac0d">Python SDK</a></li> <li data-lang="php"><a href="#tab-3224df18-bdd4-42e8-9d09-447127a0550c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4111f617-f810-419f-ab9a-538c0307a4e9">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-dbeddeff-6afe-4a8d- 97a3-4f30d5eed5d2">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-cbd9eb52-e816-4c5d-b7fd-f2d44ff6d09a"> <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-3c5b9925-83d1-4b10-ad44-0f3d5fe3e970"> <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-9ec46afa-91df-46b9-8108-ebd88d5aac0d"> <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-d21c862b-b400-496f-8f1c-78a3968ccdd7"> <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-3224df18-bdd4-42e8-9d09-447127a0550c"> <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-590dd119-cabe-4a58-8618-1403f9682659"> <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-4111f617-f810-419f-ab9a-538c0307a4e9"> <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-5223e50e-28e7-4374-8236-0388f688e1be"> <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-dbeddeff-6afe-4a8d-97a3-4f30d5eed5d2"> <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-63884e30-ec8e-4bea-bcad-3a87675d7a62">REST API</a></li> <li data-lang="python"><a href="#tab-0d2724aa-fb67-44da-814f-9a2acebfc13d">Python SDK</a></li> <li data-lang="php"><a href="#tab-746ace06-3a0f-42cb-9497-d89b35605797">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-79374629-0135-4fcc-97f9-dd0b5113c7a4">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-953d1978-7674-4c1a-a6f6-66ebc9ea9f6c">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-63884e30-ec8e-4bea-bcad-3a87675d7a62"> <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-7299e18b-4eef-4f64-91d1-eb96993557b0">REST API</a></li> <li data-lang="python"><a href="#tab-1a06814e-c92d-40d4-a2aa-595afa8fef09">Python SDK</a></li> <li data-lang="php"><a href="#tab-53f40bcc-b61b-45e3-862c-dca76a5719d8">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-b47e2495-7c5e-4e1b-9366-7c3242e74abc">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-2d4a73c3-7a3d-4437-b542-27964b7523fa">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-7299e18b-4eef-4f64-91d1-eb96993557b0"> <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-0d2724aa-fb67-44da-814f-9a2acebfc13d"> <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-1a06814e-c92d-40d4-a2aa-595afa8fef09"> <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-746ace06-3a0f-42cb-9497-d89b35605797"> <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-53f40bcc-b61b-45e3-862c-dca76a5719d8"> <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-79374629-0135-4fcc-97f9-dd0b5113c7a4"> <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-b47e2495-7c5e-4e1b-9366-7c3242e74abc"> <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-953d1978-7674-4c1a-a6f6-66ebc9ea9f6c"> <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-2d4a73c3-7a3d-4437-b542-27964b7523fa"> <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-9108ad62-613a-4484-8dfd-452de33853ad">REST API</a></li> <li data-lang="python"><a href="#tab-a6094cb5-8e4b-48c8-82d8-5a5d99736255">Python SDK</a></li> <li data-lang="php"><a href="#tab-76efbd97-a19b-425a-a31f-6578e195adbc">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-0d836bff-9679-427a-8b62-acc62156ad2b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-420e00b1-31cb-4adb-a7ca-a91ef71a447a">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-9108ad62-613a-4484-8dfd-452de33853ad"> <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-27696aee-cffc-46d8-a1cc-dab880233b18">REST API</a></li> <li data-lang="python"><a href="#tab-3c3303ad-34ad-403e-aa62-52be8557fd2c">Python SDK</a></li> <li data-lang="php"><a href="#tab-f608061e-e2ca-4e0b-ad13-ba374d95f549">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-5238274a-763e-48a6-a483-7ca720fd2da2">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-10189b0e-c7ee-4449-94f7-39b744267c66">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-27696aee-cffc-46d8-a1cc-dab880233b18"> <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-a6094cb5-8e4b-48c8-82d8-5a5d99736255"> <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-3c3303ad-34ad-403e-aa62-52be8557fd2c"> <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-76efbd97-a19b-425a-a31f-6578e195adbc"> <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-f608061e-e2ca-4e0b-ad13-ba374d95f549"> <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-0d836bff-9679-427a-8b62-acc62156ad2b"> <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-5238274a-763e-48a6-a483-7ca720fd2da2"> <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-420e00b1-31cb-4adb-a7ca-a91ef71a447a"> <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-10189b0e-c7ee-4449-94f7-39b744267c66"> <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 temrinal 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-02dcd127-b8c0-4f0e-a79d-2f19a339c5a3">REST API</a></li> <li data-lang="python"><a href="#tab-4908b358-3d2e-41dd-95ca-dd19bc7ba31f">Python SDK</a></li> <li data-lang="php"><a href="#tab-1b5f9972-fbc5-4aa9-acd9-88a7cb578e76">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-f0151a3f-b8f3-4564-ae9f-341850e7ffbf">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-58406885-6298-44bd-9e53-87061688b7cf">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-02dcd127-b8c0-4f0e-a79d-2f19a339c5a3"> <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-b6e7d99b-a09f-4e12-8225-cc821f88f490">REST API</a></li> <li data-lang="python"><a href="#tab-25676a07-01b7-4f55-99ec-aad6d26d1343">Python SDK</a></li> <li data-lang="php"><a href="#tab-2aace1bb-a650-4ae7-85fa-04bcc142efef">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-22ce89f5-d6df-4a03-b2b8-24a63326a368">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-11599dea-9d17-4aa0-b19d-640ce9725abf">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-b6e7d99b-a09f-4e12-8225-cc821f88f490"> <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-4908b358-3d2e-41dd-95ca-dd19bc7ba31f"> <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-25676a07-01b7-4f55-99ec-aad6d26d1343"> <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-1b5f9972-fbc5-4aa9-acd9-88a7cb578e76"> <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-2aace1bb-a650-4ae7-85fa-04bcc142efef"> <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-f0151a3f-b8f3-4564-ae9f-341850e7ffbf"> <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-22ce89f5-d6df-4a03-b2b8-24a63326a368"> <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-58406885-6298-44bd-9e53-87061688b7cf"> <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-11599dea-9d17-4aa0-b19d-640ce9725abf"> <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/incubator-predictionio-site/blob/c5d52816/templates/productranking/quickstart/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/productranking/quickstart/index.html.gz b/templates/productranking/quickstart/index.html.gz index 6e8d5e4..b335882 100644 Binary files a/templates/productranking/quickstart/index.html.gz and b/templates/productranking/quickstart/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/batch-evaluator/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/batch-evaluator/index.html.gz b/templates/recommendation/batch-evaluator/index.html.gz index 121fe02..2d18ac8 100644 Binary files a/templates/recommendation/batch-evaluator/index.html.gz and b/templates/recommendation/batch-evaluator/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/blacklist-items/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/blacklist-items/index.html.gz b/templates/recommendation/blacklist-items/index.html.gz index 25a1044..61d1a33 100644 Binary files a/templates/recommendation/blacklist-items/index.html.gz and b/templates/recommendation/blacklist-items/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/customize-data-prep/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/customize-data-prep/index.html.gz b/templates/recommendation/customize-data-prep/index.html.gz index a0821a1..cab52b8 100644 Binary files a/templates/recommendation/customize-data-prep/index.html.gz and b/templates/recommendation/customize-data-prep/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/customize-serving/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/customize-serving/index.html.gz b/templates/recommendation/customize-serving/index.html.gz index 2e665c3..0ee9460 100644 Binary files a/templates/recommendation/customize-serving/index.html.gz and b/templates/recommendation/customize-serving/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/dase/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/dase/index.html.gz b/templates/recommendation/dase/index.html.gz index 708f59c..1cf52d8 100644 Binary files a/templates/recommendation/dase/index.html.gz and b/templates/recommendation/dase/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/evaluation/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/evaluation/index.html.gz b/templates/recommendation/evaluation/index.html.gz index 955e179..3ea56b7 100644 Binary files a/templates/recommendation/evaluation/index.html.gz and b/templates/recommendation/evaluation/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/how-to/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/how-to/index.html.gz b/templates/recommendation/how-to/index.html.gz index 89c5deb..7ccf5c8 100644 Binary files a/templates/recommendation/how-to/index.html.gz and b/templates/recommendation/how-to/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/recommendation/quickstart/index.html b/templates/recommendation/quickstart/index.html index 376c3d0..b80b5ef 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 he can 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> <p>For example, when a user with ID "u0" rate an item with ID "i0" with rating of 5 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 the following "rate" event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-6148228e-3db3-4780-8169-b0801d80de8c">REST API</a></li> <li data-lang="python"><a href="#tab-280f76b8-08ed-4da2-8540-db61106db997">Python SDK</a></li> <li data-lang="php"><a href="#tab-fbd0741d-dbfa-4e8d-ae3d-cacee69e6524">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-67c1b16f-5b2e -4000-b543-7e20370937be">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6a9df278-bd61-4fa0-b8c5-4266e70dcd7c">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-6148228e-3db3-4780-8169-b0801d80de8c"> <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 he can 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> <p>For example, when a user with ID "u0" rate an item with ID "i0" with rating of 5 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 the following "rate" event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-025c049b-a3b7-414f-8935-13670eb398ca">REST API</a></li> <li data-lang="python"><a href="#tab-171f764a-0470-4cc9-b641-7fd5c92a39a2">Python SDK</a></li> <li data-lang="php"><a href="#tab-5ab2fd10-7a66-4c1b-9007-1ff0e3907608">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-34650ba6-e253 -499a-86c7-9c931d1b0f4c">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-82ff9c16-96d2-41c5-9dc3-2358776e43b9">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-025c049b-a3b7-414f-8935-13670eb398ca"> <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-280f76b8-08ed-4da2-8540-db61106db997"> <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-171f764a-0470-4cc9-b641-7fd5c92a39a2"> <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-fbd0741d-dbfa-4e8d-ae3d-cacee69e6524"> <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-5ab2fd10-7a66-4c1b-9007-1ff0e3907608"> <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-67c1b16f-5b2e-4000-b543-7e20370937be"> <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-34650ba6-e253-499a-86c7-9c931d1b0f4c"> <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-6a9df278-bd61-4fa0-b8c5-4266e70dcd7c"> <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-82ff9c16-96d2-41c5-9dc3-2358776e43b9"> <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> <p>When a user with ID "u1" buy an item with ID "i2" 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 the following "rate" event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-fd77cfc6-b426-4554-adc6-c76a81296811">REST API</a></li> <li data-lang="python"><a href="#tab-2fa9146d-7241-46b9-aa43-03d671f8fadb">Python SDK</a></li> <li data-lang="php"><a href="#tab-3928f96d-011e-4923-8ab1-4a45320d630c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-b98ab2d2-9e22-4cb8-b7bf-ddf4a6dfcf70">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-094eb681-2839-4825-95f7-dcd410840a10">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-fd77cfc6-b426-4554-adc6-c76a81296811"> <div class="highlight shell"> <table style="border-spacing: 0"><tbod y><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>When a user with ID "u1" buy an item with ID "i2" 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 the following "rate" event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-248fbb70-497c-47dd-9ebb-c8369bde00e0">REST API</a></li> <li data-lang="python"><a href="#tab-e5ed8375-8cdc-4b14-b018-54e8b330369c">Python SDK</a></li> <li data-lang="php"><a href="#tab-d2f96a61-58d1-4d35-99fc-336fa40b01d4">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-9b1e1e5c-0824-4682-9b92-9374f800f86c">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-1e994ba9-f25c-4ae6-9999-47293fa041f3">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-248fbb70-497c-47dd-9ebb-c8369bde00e0"> <div class="highlight shell"> <table style="border-spacing: 0"><tbod y><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-2fa9146d-7241-46b9-aa43-03d671f8fadb"> <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-e5ed8375-8cdc-4b14-b018-54e8b330369c"> <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-3928f96d-011e-4923-8ab1-4a45320d630c"> <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-d2f96a61-58d1-4d35-99fc-336fa40b01d4"> <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-b98ab2d2-9e22-4cb8-b7bf-ddf4a6dfcf70"> <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-9b1e1e5c-0824-4682-9b92-9374f800f86c"> <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-094eb681-2839-4825-95f7-dcd410840a10"> <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-1e994ba9-f25c-4ae6-9999-47293fa041f3"> <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 temrinal 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-eed5ad1b-21e7-46ea-95ff-9ca17e9bc773">REST API</a></li> <li data-lang="python"><a href="#tab-5b5e5a16-817a-4e43-966b-aff58d0b5867">Python SDK</a></li> <li data-lang="php"><a href="#tab-8bcdfb63-31e7-42e6-8193-df15640cd848">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-2852e9b8-abf0-4c7e-ad14-28c7525dcf2c">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-a9ff2239-5ddc-4e65-97f8-91e10cb4fbbf">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-eed5ad1b-21e7-46ea-95ff-9ca17e9bc773"> <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-536c56e5-b9e1-450f-a71e-7cbe24094b24">REST API</a></li> <li data-lang="python"><a href="#tab-9dcdcb36-6f27-458e-a3c2-0717bd35e279">Python SDK</a></li> <li data-lang="php"><a href="#tab-62093f86-925d-45ef-a6c1-e344bd28baff">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-c7503fc4-b08c-49c1-9a6c-535b41222257">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-9c80788c-d3e7-49e5-9ae8-9c91240be7fe">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-536c56e5-b9e1-450f-a71e-7cbe24094b24"> <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-5b5e5a16-817a-4e43-966b-aff58d0b5867"> <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-9dcdcb36-6f27-458e-a3c2-0717bd35e279"> <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-8bcdfb63-31e7-42e6-8193-df15640cd848"> <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-62093f86-925d-45ef-a6c1-e344bd28baff"> <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-2852e9b8-abf0-4c7e-ad14-28c7525dcf2c"> <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-c7503fc4-b08c-49c1-9a6c-535b41222257"> <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-a9ff2239-5ddc-4e65-97f8-91e10cb4fbbf"> <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-9c80788c-d3e7-49e5-9ae8-9c91240be7fe"> <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/incubator-predictionio-site/blob/c5d52816/templates/recommendation/quickstart/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/quickstart/index.html.gz b/templates/recommendation/quickstart/index.html.gz index 50e6bc1..73f304b 100644 Binary files a/templates/recommendation/quickstart/index.html.gz and b/templates/recommendation/quickstart/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/reading-custom-events/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/reading-custom-events/index.html.gz b/templates/recommendation/reading-custom-events/index.html.gz index d54b361..967d2f5 100644 Binary files a/templates/recommendation/reading-custom-events/index.html.gz and b/templates/recommendation/reading-custom-events/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/recommendation/training-with-implicit-preference/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/training-with-implicit-preference/index.html.gz b/templates/recommendation/training-with-implicit-preference/index.html.gz index 4f9ae16..7d94829 100644 Binary files a/templates/recommendation/training-with-implicit-preference/index.html.gz and b/templates/recommendation/training-with-implicit-preference/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/similarproduct/dase/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/similarproduct/dase/index.html.gz b/templates/similarproduct/dase/index.html.gz index 7ef45c8..6559ee4 100644 Binary files a/templates/similarproduct/dase/index.html.gz and b/templates/similarproduct/dase/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/similarproduct/how-to/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/similarproduct/how-to/index.html.gz b/templates/similarproduct/how-to/index.html.gz index 9f6da6b..dcc2a2b 100644 Binary files a/templates/similarproduct/how-to/index.html.gz and b/templates/similarproduct/how-to/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/similarproduct/multi-events-multi-algos/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/similarproduct/multi-events-multi-algos/index.html.gz b/templates/similarproduct/multi-events-multi-algos/index.html.gz index b7472b7..c3166aa 100644 Binary files a/templates/similarproduct/multi-events-multi-algos/index.html.gz and b/templates/similarproduct/multi-events-multi-algos/index.html.gz differ http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/c5d52816/templates/similarproduct/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/similarproduct/quickstart/index.html b/templates/similarproduct/quickstart/index.html index 36dac61..2062564 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 detail s 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-6a58d15e-4b1f-4e44-be8f-70cda2c605c7">REST API</a></li> <li data-lang="python"><a href="#tab-61400147-946 b-45bf-8354-395d36f757b6">Python SDK</a></li> <li data-lang="php"><a href="#tab-e91a7f42-6f78-43a2-826a-7b06d5aa1642">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7f877e80-9645-49f0-be40-534e67229014">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-75012a48-8a2f-4e91-94cb-bce4cda7e4ff">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-6a58d15e-4b1f-4e44-be8f-70cda2c605c7"> <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 detail s 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-de08a042-2a8a-4583-bca0-fb2df4ae31c5">REST API</a></li> <li data-lang="python"><a href="#tab-7c88b244-609 b-4ec0-82f6-aa7d9ed3f3ed">Python SDK</a></li> <li data-lang="php"><a href="#tab-6debdfce-94ce-488c-b497-bf670dcb2f48">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-2d408349-7de7-4774-900d-53c63d57a4b3">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-fc634b64-8dbe-494a-a984-0c4be8c96c43">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-de08a042-2a8a-4583-bca0-fb2df4ae31c5"> <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-61400147-946b-45bf-8354-395d36f757b6"> <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-7c88b244-609b-4ec0-82f6-aa7d9ed3f3ed"> <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-e91a7f42-6f78-43a2-826a-7b06d5aa1642"> <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-6debdfce-94ce-488c-b497-bf670dcb2f48"> <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-7f877e80-9645-49f0-be40-534e67229014"> <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-2d408349-7de7-4774-900d-53c63d57a4b3"> <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-75012a48-8a2f-4e91-94cb-bce4cda7e4ff"> <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-fc634b64-8dbe-494a-a984-0c4be8c96c43"> <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-5a45f152-7c07-4253-9977-6aeec2cbf09c">REST API</a></li> <li data-lang="python"><a href="#tab-3afe83e9-6e08-48ee-a458-331c01596eb6">Python SDK</a></li> <li data-lang="php"><a href="#tab-c7626d91-7bc1-4b57-86e8-8669030e62d3">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7b939375-1c97-49bf-ace0-be506d083db9">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-f9570a60-9b3f-4e4a-8c39-b3261e364802">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-5a45f1 52-7c07-4253-9977-6aeec2cbf09c"> <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-c763cd17-6277-4603-ba96-fb477314f658">REST API</a></li> <li data-lang="python"><a href="#tab-ba753782-b1c5-4bb2-b3db-5d9e20d11c37">Python SDK</a></li> <li data-lang="php"><a href="#tab-a1be1575-76d6-4f8c-a928-e9f8d7d1ca83">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7eefc5f4-5337-4d9a-ac97-2c5772ec2f16">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-97134bf5-379d-4f34-b0bd-c1d59e48be42">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-c763cd 17-6277-4603-ba96-fb477314f658"> <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-3afe83e9-6e08-48ee-a458-331c01596eb6"> <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-ba753782-b1c5-4bb2-b3db-5d9e20d11c37"> <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-c7626d91-7bc1-4b57-86e8-8669030e62d3"> <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-a1be1575-76d6-4f8c-a928-e9f8d7d1ca83"> <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-7b939375-1c97-49bf-ace0-be506d083db9"> <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-7eefc5f4-5337-4d9a-ac97-2c5772ec2f16"> <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-f9570a60-9b3f-4e4a-8c39-b3261e364802"> <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-97134bf5-379d-4f34-b0bd-c1d59e48be42"> <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-8be39fac-9ac7-4d4a-a569-7388f9dafba1">REST API</a></li> <li data-lang="python"><a href="#tab-d8f37b57-4e07-438d-bdba-37c312972104">Python SDK</a></li> <li data-lang="php"><a href="#tab-b88fd9b3-469a-42a8-9365-9cf363be92db">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a03c93ea-188c-4c11-a6c2-e3bbfdb4c267">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-a1ca145e-f90c-44e0-b948-9cfc75ab50ea">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-8be39fac-9ac7-4d4a-a569-7388f9dafba1"> <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-28513053-9393-431b-b2b8-1ce66ae9f6a0">REST API</a></li> <li data-lang="python"><a href="#tab-83144550-db77-4375-a515-62d7feaee763">Python SDK</a></li> <li data-lang="php"><a href="#tab-6e903d01-f421-4d1e-9f9b-dc282f0b205d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-f1b90b6d-873d-4c63-9ff5-6a0f7fce9347">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-27a5086b-b2eb-4c67-ba82-28edc863c889">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-28513053-9393-431b-b2b8-1ce66ae9f6a0"> <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-d8f37b57-4e07-438d-bdba-37c312972104"> <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-83144550-db77-4375-a515-62d7feaee763"> <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-b88fd9b3-469a-42a8-9365-9cf363be92db"> <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-6e903d01-f421-4d1e-9f9b-dc282f0b205d"> <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-a03c93ea-188c-4c11-a6c2-e3bbfdb4c267"> <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-f1b90b6d-873d-4c63-9ff5-6a0f7fce9347"> <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-a1ca145e-f90c-44e0-b948-9cfc75ab50ea"> <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-27a5086b-b2eb-4c67-ba82-28edc863c889"> <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 temrinal 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-7c11763c-e6f3-454b-9daf-bfec51881beb">REST API</a></li> <li data-lang="python"><a href="#tab-5847c634-ddf6-4025-8136-50f88b5a3c58">Python SDK</a></li> <li data-lang="php"><a href="#tab-030e9b04-9154-4fae-9bb0-5648f0b9da6f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-cb74cbe7-9035-49d0-959e-d60d35fb8ace">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-2b9d199d-2204-4db5-8894-c275ce874b2f">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-7c11763c-e6f3-454b-9daf-bfec51881beb"> <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-418614f8-aa5b-4afc-9041-299fd61bfa3f">REST API</a></li> <li data-lang="python"><a href="#tab-3d85e95e-25c0-4cdf-8dc0-4563d76e2d4d">Python SDK</a></li> <li data-lang="php"><a href="#tab-ea4257e3-4439-4066-8327-ec63d467cc3b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-902aebe5-e5f2-45da-83b9-9adaec7c2f9b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-f44c73c3-bb2c-4973-be3e-2fb79dbdf7aa">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-418614f8-aa5b-4afc-9041-299fd61bfa3f"> <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-5847c634-ddf6-4025-8136-50f88b5a3c58"> <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-3d85e95e-25c0-4cdf-8dc0-4563d76e2d4d"> <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-030e9b04-9154-4fae-9bb0-5648f0b9da6f"> <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-ea4257e3-4439-4066-8327-ec63d467cc3b"> <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-cb74cbe7-9035-49d0-959e-d60d35fb8ace"> <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-902aebe5-e5f2-45da-83b9-9adaec7c2f9b"> <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-2b9d199d-2204-4db5-8894-c275ce874b2f"> <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-f44c73c3-bb2c-4973-be3e-2fb79dbdf7aa"> <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