http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/52ba9b45/templates/javaecommercerecommendation/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/javaecommercerecommendation/quickstart/index.html b/templates/javaecommercerecommendation/quickstart/index.html index 035dfd5..4412884 100644 --- a/templates/javaecommercerecommendation/quickstart/index.html +++ b/templates/javaecommercerecommendation/quickstart/index.html @@ -32,7 +32,7 @@ Your system is all ready to go. <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp1 | 1 | 3mZWDzci2D5YsqAnqNnXH9SB6Rg3dsTBs8iHkK6X2i54IQsIZI1eEeQQyMfs7b3F | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp2 | 2 | io5lz6Eg4m3Xe4JZTBFE13GMAf1dhFl6ZteuJfrO84XpdOz9wRCrDU44EUaYuXq5 | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> Finished listing 2 app<span class="o">(</span>s<span class="o">)</span>. -</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, the E-Commerce Recommendation Engine Template supports 2 types of entities and 2 events: <strong>user</strong> and <strong>item</strong>; events <strong>view</strong> and <strong>buy</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view and buy an item. The specical <strong>constraint</strong> entiy with entityId <strong>unavailableItems</strong> defines a list of unavailable items and is taken into account in realtime during serving.</p><p>In summary, this template requires '$set' user event, '$set' item event, user-view-item events, user-buy-item event and '$set' constraint event.</p><div class="alert-message info"><p>This template can easily be customized to consider other user-to-it em events.</p></div> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when a new user with id "u0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for this user. To send this event, run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-dedec4b6-e18f-4db2-b673-9d39dd05fbbb">REST API</a></li> <li data-lang="python"><a href="#tab-7336189b-713f-440d-966e-2e8e1517ed4a">Python SDK</a></li> <li data-lang="php"><a href="#tab-df1d13f5-facc-4a6e-8252-651d6609a273">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-66d8f25f-dd18-43e4-985a-5287899f26d7">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-14c34c60-2e9d-411b-8d2f-18df3ee24547">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-dedec4b6-e18f-4db2-b673-9d39dd05fbbb"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, the E-Commerce Recommendation Engine Template supports 2 types of entities and 2 events: <strong>user</strong> and <strong>item</strong>; events <strong>view</strong> and <strong>buy</strong>. An item has the <strong>categories</strong> property, which is a list of category names (String). A user can view and buy an item. The specical <strong>constraint</strong> entiy with entityId <strong>unavailableItems</strong> defines a list of unavailable items and is taken into account in realtime during serving.</p><p>In summary, this template requires '$set' user event, '$set' item event, user-view-item events, user-buy-item event and '$set' constraint event.</p><div class="alert-message info"><p>This template can easily be customized to consider other user-to-it em events.</p></div> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when a new user with id "u0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for this user. To send this event, run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-0d4a3f1a-3753-476b-82fd-75546cf66ecc">REST API</a></li> <li data-lang="python"><a href="#tab-922f8b62-ddd2-406f-8337-fb754bccc7d6">Python SDK</a></li> <li data-lang="php"><a href="#tab-f847af1b-4855-4056-9707-52c37ab7633d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-250fdc58-05e4-4f11-a32b-023daa093159">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-9d46ef67-4798-422a-a9de-37bc604b1bf4">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-0d4a3f1a-3753-476b-82fd-75546cf66ecc"> <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-7336189b-713f-440d-966e-2e8e1517ed4a"> <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-922f8b62-ddd2-406f-8337-fb754bccc7d6"> <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-df1d13f5-facc-4a6e-8252-651d6609a273"> <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-f847af1b-4855-4056-9707-52c37ab7633d"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -119,7 +119,7 @@ Your system is all ready to go. <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'categories'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<CATEGORY_1>'</span><span class="p">,</span> <span class="s1">'<CATEGORY_2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-66d8f25f-dd18-43e4-985a-5287899f26d7"> <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-250fdc58-05e4-4f11-a32b-023daa093159"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -136,7 +136,7 @@ Your system is all ready to go. <span class="s1">'user'</span><span class="p">,</span> <span class="o"><</span><span class="no">USER</span> <span class="no">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-14c34c60-2e9d-411b-8d2f-18df3ee24547"> <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-9d46ef67-4798-422a-a9de-37bc604b1bf4"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -161,7 +161,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">entityType</span><span class="o">(</span><span class="s">"user"</span><span class="o">)</span> <span class="o">.</span><span class="na">entityId</span><span class="o">(<</span><span class="n">USER_ID</span><span class="o">>);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">userEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>When a new item "i0" is created in your app on time <code>2014-11-02T09:39:45.618-08:00</code> (current time will be used if eventTime is not specified), you can send a <code>$set</code> event for the item. Note that the item is set with categories properties: <code>"c1"</code> and <code>"c2"</code>. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-474398d3-0473-44bf-803e-1871c168998c">REST API</a></li> <li data-lang="python"><a href="#tab-e0dc15a9-4005-401d-afbe-cde77a1ccb8e">Python SDK</a></li> <li data-lang="php"><a href="#tab-794e862c-c640-4660-8c16-591fe7f999a4">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-24175a07-5245-4a44-89b6-418999d7d82a">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-7f8b8c24-f2eb-4f77-b578-e1b3304f63b1">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-474398 d3-0473-44bf-803e-1871c168998c"> <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-ea0ab5e3-0bb7-42a2-9ca2-909509f2fbe3">REST API</a></li> <li data-lang="python"><a href="#tab-927fd69e-65c9-4814-a4cf-04be00d03cdc">Python SDK</a></li> <li data-lang="php"><a href="#tab-b3c8b8e2-3a6e-471a-8f9b-9e147e782656">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-4e158aac-3d45-449f-895e-e3839419cf14">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-c1cf84b5-b427-4e7f-adb8-1efa310d04fc">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-ea0ab5 e3-0bb7-42a2-9ca2-909509f2fbe3"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -182,7 +182,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:39:45.618-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-e0dc15a9-4005-401d-afbe-cde77a1ccb8e"> <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-927fd69e-65c9-4814-a4cf-04be00d03cdc"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -201,7 +201,7 @@ Your system is all ready to go. <span class="s">"categories"</span> <span class="p">:</span> <span class="p">[</span><span class="s">"<CATEGORY_1>"</span><span class="p">,</span> <span class="s">"<CATEGORY_2>"</span><span class="p">]</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-794e862c-c640-4660-8c16-591fe7f999a4"> <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-b3c8b8e2-3a6e-471a-8f9b-9e147e782656"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -218,7 +218,7 @@ Your system is all ready to go. <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'categories'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<CATEGORY_1>'</span><span class="p">,</span> <span class="s1">'<CATEGORY_2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-24175a07-5245-4a44-89b6-418999d7d82a"> <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-4e158aac-3d45-449f-895e-e3839419cf14"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -235,7 +235,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-7f8b8c24-f2eb-4f77-b578-e1b3304f63b1"> <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-c1cf84b5-b427-4e7f-adb8-1efa310d04fc"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -248,7 +248,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">entityId</span><span class="o">(<</span><span class="n">ITEM_ID</span><span class="o">>)</span> <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"categories"</span><span class="o">,</span> <span class="n">ImmutableList</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"<CATEGORY_1>"</span><span class="o">,</span> <span class="s">"<CATEGORY_2>"</span><span class="o">));</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">itemEvent</span><span class="o">)</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>The properties of the <code>user</code> and <code>item</code> can be set, unset, or delete by special events <strong>$set</strong>, <strong>$unset</strong> and <strong>$delete</strong>. Please refer to <a href="/datacollection/eventapi/#note-about-properties">Event API</a> for more details of using these events.</p><p>When the user "u0" view item "i0" on time <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-69820576-4ad7-401e-9ff9-ae3d8fb57d85">REST API</a></li> <li data-lang="python"><a href="#tab-a7683dd7-7584-4bad-aaaf-52d3e9064bef">Python SDK</a></li> <li data-lang="php"><a href="#tab-9381b452-dbf7-4154-a57c-314a093fc348">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-9850a3e3-289b-4c37-8c48-6383d2 0bd981">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e6a3fb2a-403e-4e95-807e-0b723fe2803c">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-69820576-4ad7-401e-9ff9-ae3d8fb57d85"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>The properties of the <code>user</code> and <code>item</code> can be set, unset, or delete by special events <strong>$set</strong>, <strong>$unset</strong> and <strong>$delete</strong>. Please refer to <a href="/datacollection/eventapi/#note-about-properties">Event API</a> for more details of using these events.</p><p>When the user "u0" view item "i0" on time <code>2014-11-10T12:34:56.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-436f01fb-3793-4fd6-86f9-5e61c1e74808">REST API</a></li> <li data-lang="python"><a href="#tab-be7399ca-a752-4fd3-99c0-c1a201ff06b0">Python SDK</a></li> <li data-lang="php"><a href="#tab-645ba32d-884a-4190-a196-2092cbc3578d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-5afd44c7-8ea2-4867-ab38-19e2da 992ff2">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e297d7db-c758-4655-87b2-7267ba485e9e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-436f01fb-3793-4fd6-86f9-5e61c1e74808"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -267,7 +267,7 @@ Your system is all ready to go. "targetEntityId" : "i0", "eventTime" : "2014-11-10T12:34:56.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-a7683dd7-7584-4bad-aaaf-52d3e9064bef"> <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-be7399ca-a752-4fd3-99c0-c1a201ff06b0"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -284,7 +284,7 @@ Your system is all ready to go. <span class="n">target_entity_type</span><span class="o">=</span><span class="s">"item"</span><span class="p">,</span> <span class="n">target_entity_id</span><span class="o">=<</span><span class="n">ITEM</span> <span class="n">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-9381b452-dbf7-4154-a57c-314a093fc348"> <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-645ba32d-884a-4190-a196-2092cbc3578d"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -303,7 +303,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="nx">ITEM</span> <span class="nx">ID</span><span class="o">></span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-9850a3e3-289b-4c37-8c48-6383d20bd981"> <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-5afd44c7-8ea2-4867-ab38-19e2da992ff2"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -322,7 +322,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-e6a3fb2a-403e-4e95-807e-0b723fe2803c"> <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-e297d7db-c758-4655-87b2-7267ba485e9e"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -337,7 +337,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">targetEntityType</span><span class="o">(</span><span class="s">"item"</span><span class="o">)</span> <span class="o">.</span><span class="na">targetEntityId</span><span class="o">(<</span><span class="n">ITEM_ID</span><span class="o">>);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">viewEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>When the user "u0" buy item "i0" on time <code>2014-11-10T13:00:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-46dc16eb-a7fe-4674-be31-254b08fcb576">REST API</a></li> <li data-lang="python"><a href="#tab-963154e0-95f8-40fe-beca-122ca8e6bb6d">Python SDK</a></li> <li data-lang="php"><a href="#tab-38029df5-5e08-438c-8983-82f0e2334f9e">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-80ad8dae-bf04-4439-8971-d59c6778a6ee">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-6549ef3a-d387-452a-99a7-ebb04c7783c7">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-46dc16eb-a7fe-4674-be31-254b08fcb576"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text- align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>When the user "u0" buy item "i0" on time <code>2014-11-10T13:00:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send a view event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-fe5292e2-76ad-4619-8f97-a88ae434a0f4">REST API</a></li> <li data-lang="python"><a href="#tab-174cd57d-15e4-4550-8254-b72d4f3e3d2c">Python SDK</a></li> <li data-lang="php"><a href="#tab-f64daaea-b35d-4993-970d-40903d2c0c7b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-74dd5b7f-18e0-4ab5-b8bb-d9c998036311">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-bf52c88f-df2a-4cfe-9556-5f25583523e5">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-fe5292e2-76ad-4619-8f97-a88ae434a0f4"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text- align: right"><pre class="lineno">1 2 3 4 @@ -356,7 +356,7 @@ Your system is all ready to go. "targetEntityId" : "i0", "eventTime" : "2014-11-10T13:00:00.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-963154e0-95f8-40fe-beca-122ca8e6bb6d"> <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-174cd57d-15e4-4550-8254-b72d4f3e3d2c"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -373,7 +373,7 @@ Your system is all ready to go. <span class="n">target_entity_type</span><span class="o">=</span><span class="s">"item"</span><span class="p">,</span> <span class="n">target_entity_id</span><span class="o">=<</span><span class="n">ITEM</span> <span class="n">ID</span><span class="o">></span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-38029df5-5e08-438c-8983-82f0e2334f9e"> <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-f64daaea-b35d-4993-970d-40903d2c0c7b"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -392,7 +392,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="nx">ITEM</span> <span class="nx">ID</span><span class="o">></span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-80ad8dae-bf04-4439-8971-d59c6778a6ee"> <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-74dd5b7f-18e0-4ab5-b8bb-d9c998036311"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -409,7 +409,7 @@ Your system is all ready to go. <span class="s1">'targetEntityId'</span> <span class="o">=></span> <span class="o"><</span><span class="no">ITEM</span> <span class="no">ID</span><span class="o">></span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-6549ef3a-d387-452a-99a7-ebb04c7783c7"> <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-bf52c88f-df2a-4cfe-9556-5f25583523e5"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -490,19 +490,19 @@ User u10 buys item i40 </pre></td></tr></tbody></table> </div> <p>When the engine is deployed successfully and running, you should see a console message similar to the following:</p><div class="highlight shell"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1 2</pre></td><td class="code"><pre><span class="o">[</span>INFO] <span class="o">[</span>HttpListener] Bound to /0.0.0.0:8000 <span class="o">[</span>INFO] <span class="o">[</span>MasterActor] Bind successful. Ready to serve. -</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve predicted results. To recommend 4 items to user ID "u1". You send this JSON <code>{ "userEntityId": "u1", "number": 4 }</code> to the deployed engine and it will return a JSON of the recommended items. Simply send a query by making a HTTP request or through the <code>EngineClient</code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li da ta-lang="json"><a href="#tab-f887a204-65fa-49e6-a082-0651c63355d8">REST API</a></li> <li data-lang="python"><a href="#tab-d045d7ef-5e6e-4f84-9c0e-03b0cd01fe7d">Python SDK</a></li> <li data-lang="php"><a href="#tab-e4baab4a-a6da-42e5-8268-dfe95142f353">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-2b4a836f-ebf4-49f2-bf9f-092956a140f7">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-f8e05c14-0fd1-4d16-829e-523e50d05715">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-f887a204-65fa-49e6-a082-0651c63355d8"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve predicted results. To recommend 4 items to user ID "u1". You send this JSON <code>{ "userEntityId": "u1", "number": 4 }</code> to the deployed engine and it will return a JSON of the recommended items. Simply send a query by making a HTTP request or through the <code>EngineClient</code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li da ta-lang="json"><a href="#tab-cfa36e28-6c17-420a-bf11-b6d882b2259f">REST API</a></li> <li data-lang="python"><a href="#tab-f8305eda-4e75-4d13-8f2b-3992e9a04bb9">Python SDK</a></li> <li data-lang="php"><a href="#tab-b937b05e-0f17-447f-8977-5096b5849d3d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-27e2dad0-100b-4b75-a47d-e4079514045b">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-a19f7250-1f6a-4a01-9123-7d09e528d171">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-cfa36e28-6c17-420a-bf11-b6d882b2259f"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4</pre></td> <td class="code"><pre><span class="gp">$ </span>curl -H <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span> -d <span class="s1">'{ "userEntityId": "u1", "number": 4 }'</span> <span class="se">\</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-d045d7ef-5e6e-4f84-9c0e-03b0cd01fe7d"> <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-f8305eda-4e75-4d13-8f2b-3992e9a04bb9"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3</pre></td> <td class="code"><pre><span class="kn">import</span> <span class="nn">predictionio</span> <span class="n">engine_client</span> <span class="o">=</span> <span class="n">predictionio</span><span class="o">.</span><span class="n">EngineClient</span><span class="p">(</span><span class="n">url</span><span class="o">=</span><span class="s">"http://localhost:8000"</span><span class="p">)</span> <span class="k">print</span> <span class="n">engine_client</span><span class="o">.</span><span class="n">send_query</span><span class="p">({</span><span class="s">"userEntityId"</span><span class="p">:</span> <span class="s">"u1"</span><span class="p">,</span> <span class="s">"number"</span><span class="p">:</span> <span class="mi">4</span><span class="p">})</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-e4baab4a-a6da-42e5-8268-dfe95142f353"> <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-b937b05e-0f17-447f-8977-5096b5849d3d"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -521,7 +521,7 @@ http://localhost:8000/queries.json <span class="nb">print_r</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-2b4a836f-ebf4-49f2-bf9f-092956a140f7"> <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-27e2dad0-100b-4b75-a47d-e4079514045b"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -534,7 +534,7 @@ http://localhost:8000/queries.json <span class="n">response</span> <span class="o">=</span> <span class="n">client</span><span class="p">.</span><span class="nf">send_query</span><span class="p">(</span><span class="s1">'userEntityId'</span> <span class="o">=></span> <span class="s1">'i1'</span><span class="p">,</span> <span class="s1">'number'</span> <span class="o">=></span> <span class="mi">4</span><span class="p">)</span> <span class="nb">puts</span> <span class="n">response</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-f8e05c14-0fd1-4d16-829e-523e50d05715"> <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-a19f7250-1f6a-4a01-9123-7d09e528d171"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -578,7 +578,7 @@ http://localhost:8000/queries.json <span class="o">{</span><span class="s2">"itemEntityId"</span>:<span class="s2">"i3"</span>,<span class="s2">"score"</span>:0.003007015026561692<span class="o">}</span> <span class="o">]</span> <span class="o">}</span> -</pre></td></tr></tbody></table> </div> <p><em>MyECommerceRecommendation</em> is now running.</p> <div class="alert-message info"><p>To update the model periodically with new data, simply set up a cron job to call <code>pio train</code> and <code>pio deploy</code>. The engine will continue to serve prediction results during the re-train process. After the training is completed, <code>pio deploy</code> will automatically shutdown the existing engine server and bring up a new process on the same port.</p></div><div class="alert-message info"><p><strong>Note that if you import a <em>large</em> data set</strong> and the training seems to be taking forever or getting stuck, it's likely that there is not enough executor memory. It's recommended to setup a Spark standalone cluster, you'll need to specify more driver and executor memory when training with a large data set. Please see <a href="/resources/faq/#engine-training">FAQ here</a> for instructions.</p></div> <h2 id='setti ng-constraint-"unavailableitems"' class='header-anchors'>Setting constraint "unavailableItems"</h2><p>Now let's send an item constraint "unavailableItems" (replace accessKey with your Access Key):</p><div class="alert-message note"><p>You can also use SDK to send this event as described in the SDK sample above.</p></div><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-97e7796f-ab5b-45ca-80bf-adbe8c2c1b0a">REST API</a></li> <li data-lang="python"><a href="#tab-b9d0d355-3998-4bb6-81df-02130e5aa069">Python SDK</a></li> <li data-lang="php"><a href="#tab-737e0909-f713-4ab4-8332-b84c9cccfa1d">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-dd4d117e-5073-4494-ab16-3127e8035f6a">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-7ba9b34f-09fd-4162-aa48-a7c3b5feec1b">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-97e7796f-ab5b-45ca-80bf-adbe8c2c1b0a"> <div class="highlight shell"> <table style="borde r-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><em>MyECommerceRecommendation</em> is now running.</p> <div class="alert-message info"><p>To update the model periodically with new data, simply set up a cron job to call <code>pio train</code> and <code>pio deploy</code>. The engine will continue to serve prediction results during the re-train process. After the training is completed, <code>pio deploy</code> will automatically shutdown the existing engine server and bring up a new process on the same port.</p></div><div class="alert-message info"><p><strong>Note that if you import a <em>large</em> data set</strong> and the training seems to be taking forever or getting stuck, it's likely that there is not enough executor memory. It's recommended to setup a Spark standalone cluster, you'll need to specify more driver and executor memory when training with a large data set. Please see <a href="/resources/faq/#engine-training">FAQ here</a> for instructions.</p></div> <h2 id='setti ng-constraint-"unavailableitems"' class='header-anchors'>Setting constraint "unavailableItems"</h2><p>Now let's send an item constraint "unavailableItems" (replace accessKey with your Access Key):</p><div class="alert-message note"><p>You can also use SDK to send this event as described in the SDK sample above.</p></div><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-4ed96fe7-628b-4be0-97b1-3eda2b8936eb">REST API</a></li> <li data-lang="python"><a href="#tab-8bbacab4-918e-4509-a358-4928ad8aa916">Python SDK</a></li> <li data-lang="php"><a href="#tab-07b9aedc-cf2d-4805-b2b0-d4da595bd22c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-634f2ca4-683e-4ca2-a799-4cd32eafeb9d">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-ec68b9d6-69d2-4d2e-9c86-6b85f6817a4e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-4ed96fe7-628b-4be0-97b1-3eda2b8936eb"> <div class="highlight shell"> <table style="borde r-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -599,7 +599,7 @@ http://localhost:8000/queries.json } "eventTime" : "2015-02-17T02:11:21.934Z" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-b9d0d355-3998-4bb6-81df-02130e5aa069"> <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-8bbacab4-918e-4509-a358-4928ad8aa916"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -618,7 +618,7 @@ http://localhost:8000/queries.json <span class="s">"items"</span> <span class="p">:</span> <span class="p">[</span><span class="s">"<ITEM ID1>"</span><span class="p">,</span> <span class="s">"<ITEM ID2>"</span><span class="p">]</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-737e0909-f713-4ab4-8332-b84c9cccfa1d"> <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-07b9aedc-cf2d-4805-b2b0-d4da595bd22c"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -635,7 +635,7 @@ http://localhost:8000/queries.json <span class="s1">'properties'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'items'</span> <span class="o">=></span> <span class="k">array</span><span class="p">(</span><span class="s1">'<ITEM ID1>'</span><span class="p">,</span> <span class="s1">'<ITEM ID2>'</span><span class="p">))</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-dd4d117e-5073-4494-ab16-3127e8035f6a"> <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-634f2ca4-683e-4ca2-a799-4cd32eafeb9d"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -650,7 +650,7 @@ http://localhost:8000/queries.json <span class="s1">'properties'</span> <span class="o">=></span> <span class="p">{</span> <span class="s1">'items'</span> <span class="o">=></span> <span class="p">[</span><span class="s1">'<ITEM ID1>'</span><span class="p">,</span> <span class="s1">'<ITEM ID2>'</span><span class="p">]</span> <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-7ba9b34f-09fd-4162-aa48-a7c3b5feec1b"> <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-ec68b9d6-69d2-4d2e-9c86-6b85f6817a4e"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4
http://git-wip-us.apache.org/repos/asf/predictionio-site/blob/52ba9b45/templates/leadscoring/quickstart/index.html ---------------------------------------------------------------------- diff --git a/templates/leadscoring/quickstart/index.html b/templates/leadscoring/quickstart/index.html index f10c996..e9039b2 100644 --- a/templates/leadscoring/quickstart/index.html +++ b/templates/leadscoring/quickstart/index.html @@ -32,7 +32,7 @@ Your system is all ready to go. <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp1 | 1 | 3mZWDzci2D5YsqAnqNnXH9SB6Rg3dsTBs8iHkK6X2i54IQsIZI1eEeQQyMfs7b3F | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> MyApp2 | 2 | io5lz6Eg4m3Xe4JZTBFE13GMAf1dhFl6ZteuJfrO84XpdOz9wRCrDU44EUaYuXq5 | <span class="o">(</span>all<span class="o">)</span> <span class="o">[</span>INFO] <span class="o">[</span>App<span class="nv">$]</span> Finished listing 2 app<span class="o">(</span>s<span class="o">)</span>. -</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, Lead Scoring Engine Template supports the following entities: <strong>user</strong>, <strong>page</strong>, and <strong>item</strong>. An user views a page, and buys an item.</p><p>Note that a "sessionId" property is required to indicate these events happen in the same session. In the first visit of a user, you should specify the optional "referrral ID" and "browser" information. These are used to determine where the user comes from and the browser information.</p><p>In summary, this template requires user-view-page event and user-buy-item events with the session ID, referrer ID and browser properties.</p> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when an user with ID u0 views a URL page "example.com/page0" on time <code>2014-11-02T09:39:45.618-08:00</code>, with session ID "akdj230fj8ass" (current time will be used if eventTime is not specified) you can send the event to Event Server. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-3726bd7a-9517-41f1- 899b-b1499982bbea">REST API</a></li> <li data-lang="python"><a href="#tab-5c91bf98-b7a4-4523-aefc-c5d73b5f20ca">Python SDK</a></li> <li data-lang="php"><a href="#tab-b78e7a18-36b6-498f-9603-3b5d7425ad93">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-c41a778a-99bd-486a-8038-8c6eb5e1fd34">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-e5c5f115-9d86-4989-848e-d916c0bc387e">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-3726bd7a-9517-41f1-899b-b1499982bbea"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p><a href="#"></a></p> <h2 id='4.-collecting-data' class='header-anchors'>4. Collecting Data</h2><p>Next, let's collect training data for this Engine. By default, Lead Scoring Engine Template supports the following entities: <strong>user</strong>, <strong>page</strong>, and <strong>item</strong>. An user views a page, and buys an item.</p><p>Note that a "sessionId" property is required to indicate these events happen in the same session. In the first visit of a user, you should specify the optional "referrral ID" and "browser" information. These are used to determine where the user comes from and the browser information.</p><p>In summary, this template requires user-view-page event and user-buy-item events with the session ID, referrer ID and browser properties.</p> <p>You can send these events to PredictionIO Event Server in real-time easily by making a HTTP request or through the provided SDK. Please see <a href="/appintegration/">App Integration Overview</a> for more details how to integrate your app with SDK.</p><p>Let's try sending events to EventServer with the following <code>curl</code> commands (The corresponding SDK code is showed in other tabs).</p><p>Replace <code><ACCCESS_KEY></code> by the Access Key generated in above steps. Note that <code>localhost:7070</code> is the default URL of the Event Server.</p><p>For convenience, set your access key to the shell variable, run:</p><p><code>$ ACCESS_KEY=<ACCESS_KEY></code></p> <p><a href="#"></a></p> <p>For example, when an user with ID u0 views a URL page "example.com/page0" on time <code>2014-11-02T09:39:45.618-08:00</code>, with session ID "akdj230fj8ass" (current time will be used if eventTime is not specified) you can send the event to Event Server. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-0d7ed415-bb8a-4b73- b9ef-4542db860795">REST API</a></li> <li data-lang="python"><a href="#tab-da5836ce-2ab2-4ad6-95b3-88a7cb49e7b4">Python SDK</a></li> <li data-lang="php"><a href="#tab-dbf26802-f359-4ad2-84bf-5383245eb5ab">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-701b4857-3443-438e-8076-61f87746f358">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-cce9018c-95d3-47bb-940d-e4b1bfcbc3c2">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-0d7ed415-bb8a-4b73-b9ef-4542db860795"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -61,7 +61,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:39:45.618-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-5c91bf98-b7a4-4523-aefc-c5d73b5f20ca"> <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-da5836ce-2ab2-4ad6-95b3-88a7cb49e7b4"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -106,7 +106,7 @@ Your system is all ready to go. <span class="s">"browser"</span><span class="p">:</span> <span class="o"><</span><span class="n">BROWSER</span><span class="o">></span> <span class="c"># optinal. but should specify this if you have this information when user views the landing page</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-b78e7a18-36b6-498f-9603-3b5d7425ad93"> <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-dbf26802-f359-4ad2-84bf-5383245eb5ab"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -145,7 +145,7 @@ Your system is all ready to go. <span class="p">)</span> <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-c41a778a-99bd-486a-8038-8c6eb5e1fd34"> <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-701b4857-3443-438e-8076-61f87746f358"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -178,7 +178,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-e5c5f115-9d86-4989-848e-d916c0bc387e"> <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-cce9018c-95d3-47bb-940d-e4b1bfcbc3c2"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -213,7 +213,7 @@ Your system is all ready to go. <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"referrerId"</span><span class="o">,</span> <span class="s">"<REFERRER ID>"</span><span class="o">)</span> <span class="o">.</span><span class="na">property</span><span class="o">(</span><span class="s">"browser"</span><span class="o">,</span> <span class="s">"<BROWSER>"</span><span class="o">);</span> <span class="n">client</span><span class="o">.</span><span class="na">createEvent</span><span class="o">(</span><span class="n">viewEvent</span><span class="o">);</span> -</pre></td> </tr></tbody></table> </div> </div> </div> <p>In the same browsing session "akdj230fj8ass", the user with ID u0 buys an item i0 on time <code>2014-11-02T09:42:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send the following buy event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-614cf9ce-72fa-4570-8a4c-23ecc763b67c">REST API</a></li> <li data-lang="python"><a href="#tab-7aa50836-b678-42c4-8d6a-16488479c326">Python SDK</a></li> <li data-lang="php"><a href="#tab-c428032a-eb1c-4ca7-bd07-15ce1648c81b">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-41ee2bdc-94dd-4fb6-a419-8c3eaee51f71">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-82eb1fe1-e8fe-496a-880d-3d4e47fdd9c0">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-614cf9ce-72fa-4570-8a4c-23ecc763b67c"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td> </tr></tbody></table> </div> </div> </div> <p>In the same browsing session "akdj230fj8ass", the user with ID u0 buys an item i0 on time <code>2014-11-02T09:42:00.123-08:00</code> (current time will be used if eventTime is not specified), you can send the following buy event. Run the following <code>curl</code> command:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-5da1caee-c357-464e-af5a-71ce31ed95bf">REST API</a></li> <li data-lang="python"><a href="#tab-94c5e9a1-48ce-4f1f-a776-52e714df5757">Python SDK</a></li> <li data-lang="php"><a href="#tab-fccbaa14-ebdf-4ccd-bc5b-a8d0e82d89fd">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-389b7ded-4172-4935-aa1b-5f39a529bbdf">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-2163fd4f-6969-472a-848b-df92978f2536">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-5da1caee-c357-464e-af5a-71ce31ed95bf"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -238,7 +238,7 @@ Your system is all ready to go. } "eventTime" : "2014-11-02T09:42:00.123-08:00" }'</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-7aa50836-b678-42c4-8d6a-16488479c326"> <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-94c5e9a1-48ce-4f1f-a776-52e714df5757"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -261,7 +261,7 @@ Your system is all ready to go. <span class="s">"sessionId"</span><span class="p">:</span> <span class="o"><</span><span class="n">SESSION</span> <span class="n">ID</span><span class="o">></span><span class="p">,</span> <span class="c"># required</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-c428032a-eb1c-4ca7-bd07-15ce1648c81b"> <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-fccbaa14-ebdf-4ccd-bc5b-a8d0e82d89fd"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -288,7 +288,7 @@ Your system is all ready to go. <span class="p">));</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-41ee2bdc-94dd-4fb6-a419-8c3eaee51f71"> <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-389b7ded-4172-4935-aa1b-5f39a529bbdf"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -311,7 +311,7 @@ Your system is all ready to go. <span class="p">}</span> <span class="p">}</span> <span class="p">)</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-82eb1fe1-e8fe-496a-880d-3d4e47fdd9c0"> <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-2163fd4f-6969-472a-848b-df92978f2536"> <div class="highlight java"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -371,7 +371,7 @@ User u5 buys item i5 </pre></td></tr></tbody></table> </div> <p>When the engine is deployed successfully and running, you should see a console message similar to the following:</p><div class="highlight shell"><table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1 2</pre></td><td class="code"><pre><span class="o">[</span>INFO] <span class="o">[</span>HttpListener] Bound to /0.0.0.0:8000 <span class="o">[</span>INFO] <span class="o">[</span>MasterActor] Bind successful. Ready to serve. -</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve the results. When a user lands on your page "example.com/page9", with referrer "referrer10.com" and browser "Firefox", you can get the predicted lead score by sending this JSON '{ "landingPageId" : "example.com/page9", "referrerId" : "referrer10.com", "browser": "Firefox" }' to the deployed engine. The engine will return a JSON with the score.</p><p>Simply send a query by making a HTTP request or through the <code>EngineClient </code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-cab8aed1-8143-4ecd-832e-46cf216c6731">REST API</a></li> <li data-lang="python"><a href="#tab-0bb934c5-8c46-4f56-8fad-85aa65caa4a2">Python SDK</a></li> <li data-lang="php"><a href="#tab-5a924b92-c141-42ca-b64c-77ea077e5d3c">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-b8e44c12-22d2-4515-95b5-a78029bf32e0">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-3050d780-e1d6-416a-b68e-8be6bc53dd95">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-cab8aed1-8143-4ecd-832e-46cf216c6731"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 +</pre></td></tr></tbody></table> </div> <p>Do not kill the deployed engine process.</p><p>By default, the deployed engine binds to <a href="http://localhost:8000"><a href="http://localhost:8000">http://localhost:8000</a></a>. You can visit that page in your web browser to check its status.</p><p><img alt="Engine Status" src="/images/engine-server-3246414b.png"/></p></p><h2 id='6.-use-the-engine' class='header-anchors'>6. Use the Engine</h2><p>Now, You can retrieve the results. When a user lands on your page "example.com/page9", with referrer "referrer10.com" and browser "Firefox", you can get the predicted lead score by sending this JSON '{ "landingPageId" : "example.com/page9", "referrerId" : "referrer10.com", "browser": "Firefox" }' to the deployed engine. The engine will return a JSON with the score.</p><p>Simply send a query by making a HTTP request or through the <code>EngineClient </code> of an SDK.</p><p>With the deployed engine running, open another terminal and run the following <code>curl</code> command or use SDK to send the query:</p><div class="tabs"> <ul class="control"> <li data-lang="json"><a href="#tab-4d4366c5-771c-447a-a8e3-4f89fa4d37e8">REST API</a></li> <li data-lang="python"><a href="#tab-a4725de8-9f57-43bf-8e71-4620e1b0c13b">Python SDK</a></li> <li data-lang="php"><a href="#tab-87708ce9-415c-42b2-8a84-cd7b2e5844b9">PHP SDK</a></li> <li data-lang="ruby"><a href="#tab-2f6f7204-f05c-4c04-9e0a-c9d216f94ccf">Ruby SDK</a></li> <li data-lang="java"><a href="#tab-fee9bd24-c67e-4bbc-a372-7fee8c7699d5">Java SDK</a></li> </ul> <div data-tab="REST API" data-lang="json" id="tab-4d4366c5-771c-447a-a8e3-4f89fa4d37e8"> <div class="highlight shell"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -384,7 +384,7 @@ User u5 buys item i5 "browser": "Firefox" }'</span> <span class="se">\</span> http://localhost:8000/queries.json -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Python SDK" data-lang="python" id="tab-0bb934c5-8c46-4f56-8fad-85aa65caa4a2"> <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-a4725de8-9f57-43bf-8e71-4620e1b0c13b"> <div class="highlight python"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -397,7 +397,7 @@ http://localhost:8000/queries.json <span class="s">"referrerId"</span> <span class="p">:</span> <span class="s">"referrer10.com"</span><span class="p">,</span> <span class="s">"browser"</span><span class="p">:</span> <span class="s">"Firefox"</span> <span class="p">})</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="PHP SDK" data-lang="php" id="tab-5a924b92-c141-42ca-b64c-77ea077e5d3c"> <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-87708ce9-415c-42b2-8a84-cd7b2e5844b9"> <div class="highlight php"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -426,7 +426,7 @@ http://localhost:8000/queries.json <span class="nb">print_r</span><span class="p">(</span><span class="nv">$response</span><span class="p">);</span> <span class="cp">?></span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Ruby SDK" data-lang="ruby" id="tab-b8e44c12-22d2-4515-95b5-a78029bf32e0"> <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-2f6f7204-f05c-4c04-9e0a-c9d216f94ccf"> <div class="highlight ruby"> <table style="border-spacing: 0"><tbody><tr> <td class="gutter gl" style="text-align: right"><pre class="lineno">1 2 3 4 @@ -447,7 +447,7 @@ http://localhost:8000/queries.json <span class="p">)</span> <span class="nb">puts</span> <span class="n">response</span> -</pre></td> </tr></tbody></table> </div> </div> <div data-tab="Java SDK" data-lang="java" id="tab-3050d780-e1d6-416a-b68e-8be6bc53dd95"> <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-fee9bd24-c67e-4bbc-a372-7fee8c7699d5"> <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