http://git-wip-us.apache.org/repos/asf/incubator-predictionio-site/blob/aca0eb85/templates/productranking/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/productranking/quickstart/index.html b/templates/productranking/quickstart/index.html index 3db4977..a6b9483 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-c061eee6-34c2-408b-b840-c0026738de52">REST API</a></li> <li data-lang="python"><a href="#tab-da1a6596-cb8e-4fbe-9ad6-00cc09980575">Python SDK</a></li> <li data-lang="php"><a href="#tab-c160b392-ad5d-45f7-9900-09bd59f23a01">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-731afcc6-bc9c-42ae-be1b-3338f0d7b7b0">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-96834394-4bfa-4f69- 86ad-f724d791630f">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-c061eee6-34c2-408b-b840-c0026738de52"> <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-67d867c6-f4f5-49a7-bc96-8b957a7bef8f">REST API</a></li> <li data-lang="python"><a href="#tab-ef08ba47-93ef-4cfd-88f0-9799bd1aa3ee">Python SDK</a></li> <li data-lang="php"><a href="#tab-d4cd3a84-90b4-4222-96d6-e32299cd559d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-bdb3011e-fc05-45dd-af37-424c84f7c577">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-fb8478d5-da76-4f84- b472-f78a02c8e0de">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-67d867c6-f4f5-49a7-bc96-8b957a7bef8f"> <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-da1a6596-cb8e-4fbe-9ad6-00cc09980575"> <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-ef08ba47-93ef-4cfd-88f0-9799bd1aa3ee"> <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-c160b392-ad5d-45f7-9900-09bd59f23a01"> <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-d4cd3a84-90b4-4222-96d6-e32299cd559d"> <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-731afcc6-bc9c-42ae-be1b-3338f0d7b7b0"> <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-bdb3011e-fc05-45dd-af37-424c84f7c577"> <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-96834394-4bfa-4f69-86ad-f724d791630f"> <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-fb8478d5-da76-4f84-b472-f78a02c8e0de"> <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-58ccbe74-8764-49e2-a7fa-cabd15dbe797">REST API</a></li> <li data-lang="python"><a href="#tab-aa179c50-0bbf-40f6-b4ca-1bc31faa7a61">Python SDK</a></li> <li data-lang="php"><a href="#tab-f87152f6-a00b-4109-92bb-4fe14c05277d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-7e69fb6f-e25b-4f08-8abc-1580f145baeb">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c1628143-52a7-4107-9836-de455330f612">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-58ccbe74-8764-49e2-a7fa-cabd15dbe797"> <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-7276fec8-79aa-4113-9be7-9154016b8e94">REST API</a></li> <li data-lang="python"><a href="#tab-5d8ad547-e667-4a62-9f9f-792c5706f427">Python SDK</a></li> <li data-lang="php"><a href="#tab-2cd27776-9bc9-4f88-a846-b70cdc181be3">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a5b808be-ed38-4186-b11d-f527274e005e">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-697cbf48-bf36-4eeb-82c2-1ba2a00f6523">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-7276fec8-79aa-4113-9be7-9154016b8e94"> <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-aa179c50-0bbf-40f6-b4ca-1bc31faa7a61"> <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-5d8ad547-e667-4a62-9f9f-792c5706f427"> <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-f87152f6-a00b-4109-92bb-4fe14c05277d"> <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-2cd27776-9bc9-4f88-a846-b70cdc181be3"> <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-7e69fb6f-e25b-4f08-8abc-1580f145baeb"> <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-a5b808be-ed38-4186-b11d-f527274e005e"> <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-c1628143-52a7-4107-9836-de455330f612"> <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-697cbf48-bf36-4eeb-82c2-1ba2a00f6523"> <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-d46121c1-4848-4876-baf2-7392d21951f6">REST API</a></li> <li data-lang="python"><a href="#tab-1660fd33-da54-4ef5-9159-e1d6dbe28269">Python SDK</a></li> <li data-lang="php"><a href="#tab-ca3a6882-e5aa-490a-b24c-ad05c9ad4c59">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4fc7cf97-d2d4-40ec-a268-b08f4a60941d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-ceee83b0-d803-4718-8cd7-40184e879ffd">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-d46121c1-4848-4876-baf2-7392d21951f6"> <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-9230b316-836f-4937-a845-14061680d725">REST API</a></li> <li data-lang="python"><a href="#tab-8015e1b3-96bf-49d8-b5f3-317f459ae914">Python SDK</a></li> <li data-lang="php"><a href="#tab-9e7ea0eb-2ed7-4a0e-aedf-6ef4080a739d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-435118f2-ee92-49f4-a1e5-a2a9b94c1c89">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-191e8f56-6555-45cd-8bf1-3521526c6f72">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-9230b316-836f-4937-a845-14061680d725"> <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-1660fd33-da54-4ef5-9159-e1d6dbe28269"> <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-8015e1b3-96bf-49d8-b5f3-317f459ae914"> <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-ca3a6882-e5aa-490a-b24c-ad05c9ad4c59"> <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-9e7ea0eb-2ed7-4a0e-aedf-6ef4080a739d"> <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-4fc7cf97-d2d4-40ec-a268-b08f4a60941d"> <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-435118f2-ee92-49f4-a1e5-a2a9b94c1c89"> <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-ceee83b0-d803-4718-8cd7-40184e879ffd"> <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-191e8f56-6555-45cd-8bf1-3521526c6f72"> <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-84be279c-11a0-4ecf-8f23-46791a9f91d8">REST API</a></li> <li data-lang="python"><a href="#tab-08de79a9-0090-4fbf-a7d7-24d399ded26d">Python SDK</a></li> <li data-lang="php"><a href="#tab-6d44a8d9-46f3-40db-a019-871a9a7ddb2b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-0985b332-a9c3-453b-ae3f-010cd5b0a991">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-3ee8ed17-583c-460b-87d9-35853e28e8f2">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-84be279c-11a0-4ecf-8f23-46791a9f91d8"> <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 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-fa8ac5dc-bb0b-461e-81fe-9282bc04cb02">REST API</a></li> <li data-lang="python"><a href="#tab-75aabc1c-b58a-4297-b3a9-14a0bd6dad60">Python SDK</a></li> <li data-lang="php"><a href="#tab-f6819ab1-6803-4d5a-9691-dad5de8ff914">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-ce8eb0c4-6e04-45f2-8c0a-628cc26c29a9">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-8368959b-d95d-47a2-9af4-e41690e96f2e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-fa8ac5dc-bb0b-461e-81fe-9282bc04cb02"> <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-08de79a9-0090-4fbf-a7d7-24d399ded26d"> <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-75aabc1c-b58a-4297-b3a9-14a0bd6dad60"> <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-6d44a8d9-46f3-40db-a019-871a9a7ddb2b"> <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-f6819ab1-6803-4d5a-9691-dad5de8ff914"> <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-0985b332-a9c3-453b-ae3f-010cd5b0a991"> <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-ce8eb0c4-6e04-45f2-8c0a-628cc26c29a9"> <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-3ee8ed17-583c-460b-87d9-35853e28e8f2"> <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-8368959b-d95d-47a2-9af4-e41690e96f2e"> <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/aca0eb85/templates/productranking/quickstart/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/productranking/quickstart/index.html.gz b/templates/productranking/quickstart/index.html.gz index 069bff5..552cd68 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/aca0eb85/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 1d24a48..67c4fcc 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/aca0eb85/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 54e2407..ab9a81a 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/aca0eb85/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 c443c9f..0629624 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/aca0eb85/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 cf76030..3cfff32 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/aca0eb85/templates/recommendation/dase/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/dase/index.html.gz b/templates/recommendation/dase/index.html.gz index 3a213b0..73fd9ad 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/aca0eb85/templates/recommendation/evaluation/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/evaluation/index.html.gz b/templates/recommendation/evaluation/index.html.gz index f141cfb..9010e84 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/aca0eb85/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 a0cab27..29658c9 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/aca0eb85/templates/recommendation/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/recommendation/quickstart/index.html b/templates/recommendation/quickstart/index.html index 2c6ec13..c4018bc 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-0590d769-9281-4378-a31a-a2967ad4cd04">REST API</a></li> <li data-lang="python"><a href="#tab-675b5ebd-ec0f-4764-b434-c33ad9596592">Python SDK</a></li> <li data-lang="php"><a href="#tab-cc3427ce-7137-41bd-9fa0-0087eea6a325">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-6d356fc2-51dc -46ac-a1cf-78b8aa9516b4">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-b5402e7c-0d59-476f-8244-78d7f2e93996">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-0590d769-9281-4378-a31a-a2967ad4cd04"> <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-153cd2bb-c6b6-4505-a619-92c9fdb8ccbe">REST API</a></li> <li data-lang="python"><a href="#tab-abad68ab-1475-4cb8-b9e5-0f04d72799cb">Python SDK</a></li> <li data-lang="php"><a href="#tab-8ac16069-ee97-4f34-acd7-97888777e73d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-28ddf96c-43b5 -46d2-b7d5-989c9bc4d31c">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-479005f7-6096-4164-9021-f8036a5a5402">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-153cd2bb-c6b6-4505-a619-92c9fdb8ccbe"> <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-675b5ebd-ec0f-4764-b434-c33ad9596592"> <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-abad68ab-1475-4cb8-b9e5-0f04d72799cb"> <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-cc3427ce-7137-41bd-9fa0-0087eea6a325"> <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-8ac16069-ee97-4f34-acd7-97888777e73d"> <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-6d356fc2-51dc-46ac-a1cf-78b8aa9516b4"> <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-28ddf96c-43b5-46d2-b7d5-989c9bc4d31c"> <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-b5402e7c-0d59-476f-8244-78d7f2e93996"> <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-479005f7-6096-4164-9021-f8036a5a5402"> <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-a571d2d4-4d2f-472c-af91-f8b4b214ae86">REST API</a></li> <li data-lang="python"><a href="#tab-7464c1b6-dce5-4533-b6a1-8e372abcf577">Python SDK</a></li> <li data-lang="php"><a href="#tab-7dee77a9-ab62-4fb9-8ed0-8abf57b1f039">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-0b4a8fc9-7a65-4b42-877e-f4f17b7f2c19">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-afb36631-d978-4f98-972c-ba7dfcd98566">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a571d2d4-4d2f-472c-af91-f8b4b214ae86"> <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-be158fbc-08d3-447a-a874-f63b7c9a3069">REST API</a></li> <li data-lang="python"><a href="#tab-9f6956f3-0466-4eed-b51a-2653015dd4a8">Python SDK</a></li> <li data-lang="php"><a href="#tab-b0fa9b18-a9f1-4a03-bebc-46ad088f2ac7">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-fdb6b1ca-d59b-48e2-a43f-5f879b08c64d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e83f2d35-82d3-4be6-b79f-d3414810a01d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-be158fbc-08d3-447a-a874-f63b7c9a3069"> <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-7464c1b6-dce5-4533-b6a1-8e372abcf577"> <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-9f6956f3-0466-4eed-b51a-2653015dd4a8"> <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-7dee77a9-ab62-4fb9-8ed0-8abf57b1f039"> <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-b0fa9b18-a9f1-4a03-bebc-46ad088f2ac7"> <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-0b4a8fc9-7a65-4b42-877e-f4f17b7f2c19"> <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-fdb6b1ca-d59b-48e2-a43f-5f879b08c64d"> <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-afb36631-d978-4f98-972c-ba7dfcd98566"> <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-e83f2d35-82d3-4be6-b79f-d3414810a01d"> <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-8ff937e4-f720-46c8-81c1-72d27c398fb6">REST API</a></li> <li data-lang="python"><a href="#tab-9ae3dab2-4959-4a85-98f1-e38d6b55f199">Python SDK</a></li> <li data-lang="php"><a href="#tab-add2baea-45ef-4ee5-b8d0-51a65e707998">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4f3df731-b24e-4795-9162-f5276dc6f6c1">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-53051880-a6fb-487e-ae75-b03a0f10271a">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-8ff937e4-f720-46c8-81c1-72d27c398fb6"> <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 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-1d3fc904-6884-4de0-8e68-31b899233b56">REST API</a></li> <li data-lang="python"><a href="#tab-a93d178a-afec-4e7a-a298-5af03dcd3573">Python SDK</a></li> <li data-lang="php"><a href="#tab-8bc4f575-4c32-404e-84a7-0457c65fb3ff">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-35aff8ca-76b2-4055-9ae2-c00b5ebeedf3">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-5eb3344f-a88f-4eb1-9861-21f30bbab247">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-1d3fc904-6884-4de0-8e68-31b899233b56"> <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-9ae3dab2-4959-4a85-98f1-e38d6b55f199"> <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-a93d178a-afec-4e7a-a298-5af03dcd3573"> <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-add2baea-45ef-4ee5-b8d0-51a65e707998"> <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-8bc4f575-4c32-404e-84a7-0457c65fb3ff"> <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-4f3df731-b24e-4795-9162-f5276dc6f6c1"> <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-35aff8ca-76b2-4055-9ae2-c00b5ebeedf3"> <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-53051880-a6fb-487e-ae75-b03a0f10271a"> <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-5eb3344f-a88f-4eb1-9861-21f30bbab247"> <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/aca0eb85/templates/recommendation/quickstart/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/recommendation/quickstart/index.html.gz b/templates/recommendation/quickstart/index.html.gz index 46b5c37..67e1ba1 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/aca0eb85/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 3c7fc1e..0ac6fa6 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/aca0eb85/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 8d37906..b927ab2 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/aca0eb85/templates/similarproduct/dase/index.html.gz ---------------------------------------------------------------------- diff --git a/templates/similarproduct/dase/index.html.gz b/templates/similarproduct/dase/index.html.gz index 9af31b0..b00fbf2 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/aca0eb85/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 59b25ee..e9ef395 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/aca0eb85/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 9c0d83b..fef1d3f 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/aca0eb85/templates/similarproduct/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/similarproduct/quickstart/index.html b/templates/similarproduct/quickstart/index.html index 0b3b8d9..c9ca476 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-c26a5360-d152-47e1-b2e2-65c4e392a104">REST API</a></li> <li data-lang="python"><a href="#tab-bd7350c4-b7d 4-4ea0-ad5f-4271399e283e">Python SDK</a></li> <li data-lang="php"><a href="#tab-ce30099d-8588-41cd-ae37-2c1865d90d8c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-a9e3af52-b3a9-4ab5-aff8-5d065487d019">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-f43dfc65-ba32-4e03-9c0f-7f2db776e288">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-c26a5360-d152-47e1-b2e2-65c4e392a104"> <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-b58083cc-9e95-4355-ba7c-79d52ed2a347">REST API</a></li> <li data-lang="python"><a href="#tab-7e84a01b-613 4-49a3-804e-b9f207ac072a">Python SDK</a></li> <li data-lang="php"><a href="#tab-e3ca98f4-820e-485b-96f4-69ed0ec0a99e">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-9f68c8f0-1e63-48fe-8bbb-f6a6935c0541">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-fa32149a-897e-4396-9efd-29d577675283">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-b58083cc-9e95-4355-ba7c-79d52ed2a347"> <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-bd7350c4-b7d4-4ea0-ad5f-4271399e283e"> <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-7e84a01b-6134-49a3-804e-b9f207ac072a"> <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-ce30099d-8588-41cd-ae37-2c1865d90d8c"> <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-e3ca98f4-820e-485b-96f4-69ed0ec0a99e"> <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-a9e3af52-b3a9-4ab5-aff8-5d065487d019"> <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-9f68c8f0-1e63-48fe-8bbb-f6a6935c0541"> <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-f43dfc65-ba32-4e03-9c0f-7f2db776e288"> <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-fa32149a-897e-4396-9efd-29d577675283"> <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-5378effe-78b7-4f8b-bcab-36bbe65e208f">REST API</a></li> <li data-lang="python"><a href="#tab-28de7a65-3325-4ca5-90c3-a8884e91f44b">Python SDK</a></li> <li data-lang="php"><a href="#tab-f0a060eb-0dff-4af1-aeff-1337d6a40b51">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-151a1255-2506-4ebb-ad72-e02b98602e58">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6821e17e-ccc1-4888-a079-d7710b170802">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-5378ef fe-78b7-4f8b-bcab-36bbe65e208f"> <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-85c0be0e-9345-4fb5-8bbf-54c30c6242d6">REST API</a></li> <li data-lang="python"><a href="#tab-2b65fcd4-3694-4619-9da1-5bed11a8c685">Python SDK</a></li> <li data-lang="php"><a href="#tab-15c463c5-87ea-4989-989f-ae16f640e680">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-e5760ace-49a4-4de2-8eac-f83b2ba0593f">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c99edbb3-d788-443c-95bc-f62ad2cf7a8d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-85c0be 0e-9345-4fb5-8bbf-54c30c6242d6"> <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-28de7a65-3325-4ca5-90c3-a8884e91f44b"> <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-2b65fcd4-3694-4619-9da1-5bed11a8c685"> <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-f0a060eb-0dff-4af1-aeff-1337d6a40b51"> <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-15c463c5-87ea-4989-989f-ae16f640e680"> <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-151a1255-2506-4ebb-ad72-e02b98602e58"> <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-e5760ace-49a4-4de2-8eac-f83b2ba0593f"> <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-6821e17e-ccc1-4888-a079-d7710b170802"> <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-c99edbb3-d788-443c-95bc-f62ad2cf7a8d"> <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-a7031f35-1dda-4d66-b07c-741af8badec2">REST API</a></li> <li data-lang="python"><a href="#tab-a422366b-be86-429d-beea-4f73fec99fbd">Python SDK</a></li> <li data-lang="php"><a href="#tab-d21778de-b660-4d38-9125-8f35d53fca6d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-aa727219-46e8-4fcd-8469-521390ffd8b5">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c057e491-ee69-4f5d-b333-7966b7aa70fc">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a7031f35-1dda-4d66-b07c-741af8badec2"> <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-a6aaf593-7e58-4921-9186-6b6a11e01c10">REST API</a></li> <li data-lang="python"><a href="#tab-a187206d-63ed-4a56-a5e5-da5e5f608fdb">Python SDK</a></li> <li data-lang="php"><a href="#tab-8c6a154e-3395-4aa6-83ed-ca8ad4134a7b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-256491dd-19e5-408d-87b9-7f9babeed1fa">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e800b099-629b-41fe-9914-68d2469fbb4d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-a6aaf593-7e58-4921-9186-6b6a11e01c10"> <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-a422366b-be86-429d-beea-4f73fec99fbd"> <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-a187206d-63ed-4a56-a5e5-da5e5f608fdb"> <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-d21778de-b660-4d38-9125-8f35d53fca6d"> <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-8c6a154e-3395-4aa6-83ed-ca8ad4134a7b"> <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-aa727219-46e8-4fcd-8469-521390ffd8b5"> <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-256491dd-19e5-408d-87b9-7f9babeed1fa"> <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-c057e491-ee69-4f5d-b333-7966b7aa70fc"> <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-e800b099-629b-41fe-9914-68d2469fbb4d"> <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-111df85e-d428-46f5-b1fe-213058e09259">REST API</a></li> <li data-lang="python"><a href="#tab-c1072756-ceba-4897-b0c2-d6c7a3e553d3">Python SDK</a></li> <li data-lang="php"><a href="#tab-f4d7967c-bd73-40a3-ad3e-c9daed09270f">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-e2639894-f6dd-4f39-bc2d-c777471e43a0">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-69ff0e58-83e5-4361-89ed-79176368cd6d">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-111df85e-d428-46f5-b1fe-213058e09259"> <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 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-8b8a06aa-1f2d-4a1a-aeee-ff553944ce7d">REST API</a></li> <li data-lang="python"><a href="#tab-f19c533a-4721-48b5-8956-ae824d201bbf">Python SDK</a></li> <li data-lang="php"><a href="#tab-c0592bc1-fb3b-4cf8-984d-852ee076165e">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-51b4bb1c-24ef-431a-9f58-a06e915765d1">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-171ea2e1-ccd0-4cc1-bab4-3953155d9b03">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-8b8a06aa-1f2d-4a1a-aeee-ff553944ce7d"> <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-c1072756-ceba-4897-b0c2-d6c7a3e553d3"> <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-f19c533a-4721-48b5-8956-ae824d201bbf"> <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-f4d7967c-bd73-40a3-ad3e-c9daed09270f"> <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-c0592bc1-fb3b-4cf8-984d-852ee076165e"> <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-e2639894-f6dd-4f39-bc2d-c777471e43a0"> <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-51b4bb1c-24ef-431a-9f58-a06e915765d1"> <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-69ff0e58-83e5-4361-89ed-79176368cd6d"> <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-171ea2e1-ccd0-4cc1-bab4-3953155d9b03"> <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
