{"id":76130,"date":"2020-09-23T18:00:00","date_gmt":"2020-09-23T15:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/build-machine-learning-recommendations-into-your-app-with-aws-personalize-cloudsavvy-it\/"},"modified":"2020-09-23T18:00:00","modified_gmt":"2020-09-23T15:00:00","slug":"build-machine-learning-recommendations-into-your-app-with-aws-personalize-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/build-machine-learning-recommendations-into-your-app-with-aws-personalize-cloudsavvy-it\/","title":{"rendered":"#Build Machine Learning Recommendations Into Your App With AWS Personalize \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2c39e9ee1ef\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2c39e9ee1ef\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/build-machine-learning-recommendations-into-your-app-with-aws-personalize-cloudsavvy-it\/#What_Is_AWS_Personalize\" >What Is AWS Personalize?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/build-machine-learning-recommendations-into-your-app-with-aws-personalize-cloudsavvy-it\/#Setting_Up_AWS_Personalize\" >Setting Up AWS Personalize<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<p>[*]&#8221;#Build Machine Learning Recommendations Into Your <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">App<\/a> With AWS Personalize \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3669\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/b36812b2293054cab4551c8bd9e904d2\/p\/uploads\/2020\/01\/3da27b5a.png\" alt=\"aws personalize\" width=\"700\" height=\"300\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>AWS Personalize is a product recommendation engine which works much like the one used for Amazon.com, built up from over 20 years of personalization experience. You can implement it as your own API to power your app\u2019s suggestions with machine learning.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_Is_AWS_Personalize\"><\/span>What Is AWS Personalize?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u201cProduct recommendation engine\u201d is a <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a> term that can be extended to apply to many things, not just online shopping. Take <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">YouTube<\/a> for example. If you sign up for a new YouTube account, you\u2019ll get a lot of general videos that appeal to a mass audience\u2014stuff that\u2019s on trending, mostly. However, if you search for \u201cminecraft letsplay,\u201d and watch a half hour video, the YouTube recommendation algorithm will take note of this. It will look at the tags, title, channel, posting date, and other metadata from the video that you liked, and then, using machine learning, will try to find other videos that are similar to it, and had similar engagement from other users. It perhaps you\u2019ll get more videos from the same <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/watch-movies-tv-seriess\/\" data-internallinksmanager029f6b8e52c=\"8\" title=\"Watch Movies &amp; TV Series\" target=\"_blank\" rel=\"noopener\">series<\/a>, since people will tend to watch things in chronological order. Perhaps there\u2019s another channel making similar content, that you might like as well.<\/p>\n<p>All of this is powered by machine learning recommendations. The \u201cProduct\u201d can be anything\u2014in the case of Amazon, it\u2019s the items they have for sale. For YouTube, it\u2019s videos. For Spotify, it\u2019s new songs to play. For Facebook (or any social media service, really), it\u2019s posts from users.<\/p>\n<p>This engine is packaged into a standalone PaaS that doesn\u2019t require any sort of specific machine learning knowledge. You feed the engine user actions (clicked on this post, listened to this song for X minutes, etc) and the engine will spit out new recommendations from your product catalogue when requested.\u00a0Recommendations may start out a little spotty, but once your model is trained enough, they\u2019ll start to become very accurate.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Setting_Up_AWS_Personalize\"><\/span>Setting Up AWS Personalize<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Each <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/aws.amazon.com\/personalize\/?tag=reviewgeek-20\">AWS Personalize<\/a> project will have three datasets:<\/p>\n<ul>\n<li>Users, which track metadata about the users themselves<\/li>\n<li>Items, which functions as a product catalogue<\/li>\n<li>Interactions, which log interaction events between users and items<\/li>\n<\/ul>\n<p>The Interactions list is the one that is most important, as it tracks all events and functions as the basis for training the model. The Users and Items lists provide supplemental data that will help the model make intelligent connections. For example, knowing the age of a user, Personalize can recommend different products to different age groups, based on their likelihood of being applicable.<\/p>\n<p>The default option is to import historical data from a CSV file, though you can use the Event Tracker API to send real-time updates once you get everything going. You\u2019ll need to have some training data to import though\u2014import will fail if you have less than 1,000 entries in your interactions list. If you\u2019re just looking to test out Personalize, you\u2019ll need to create some sort of dummy data that adheres to your schema before proceeding with the import.<\/p>\n<p>Head over to the <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\/\/redirect.viglink.com?u=https%3A%2F%2Fconsole.aws.amazon.com%2Fpersonalize%2Fhome&amp;key=204a528a336ede4177fff0d84a044482\">AWS Personalize Management Console<\/a> to get started. Create a new dataset group, which will function as an individual \u201cApp.\u201d It will ask for a name:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3648\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/11edbec41661aac7a1f45d64bab5cec1\/p\/uploads\/2020\/01\/ee31ab68.png\" alt=\"new dataset group\" width=\"700\" height=\"285\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Click next, and you\u2019ll automatically be brought to configure the interactions import. Give it a name (\u201cinteractions\u201d), and define your schema. This is in <a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/avro.apache.org\/docs\/current\/\">Apache Avro<\/a> format, and tells Personalize what fields each interaction (or product\/user) has. For interactions, the most basic is a bind of USER_ID to PRODUCT_ID, which is used to look up users and products from the other tables (a many-to-many relational link).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" alignnone wp-image-3649 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/acf46f83d0db4bddce06f87209316820\/p\/uploads\/2020\/01\/ab978daf.png\" alt=\"dataset schema\" width=\"700\" height=\"600\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>You\u2019ll next need to import data into Personalize, from a CSV file in S3. First, select or create a service role that can access this bucket. You\u2019ll also need to attach the following bucket policy to the target bucket to allow Personalize to access it, replacing <code>bucketname<\/code>\u00a0with your bucket\u2019s name:<\/p>\n<pre>{&#13;\n    \"Version\": \"2012-10-17\",&#13;\n    \"Id\": \"PersonalizeS3BucketAccessPolicy\",&#13;\n    \"Statement\": [&#13;\n        {&#13;\n            \"Sid\": \"PersonalizeS3BucketAccessPolicy\",&#13;\n            \"Effect\": \"Allow\",&#13;\n            \"Principal\": {&#13;\n                \"Service\": \"personalize.amazonaws.com\"&#13;\n            },&#13;\n            \"Action\": [&#13;\n                \"s3:GetObject\",&#13;\n                \"s3:ListBucket\"&#13;\n            ],&#13;\n            \"Resource\": [&#13;\n                \"arn:aws:s3:::bucket-name\",&#13;\n                \"arn:aws:s3:::bucket-name\/*\"&#13;\n            ]&#13;\n        }&#13;\n    ]&#13;\n}<\/pre>\n<p>Then you can paste in the path to the file:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3650\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/f10a9c55df8d5cab697706fa6aff80e3\/p\/uploads\/2020\/01\/5c3517c8.png\" alt=\"import S3 file\" width=\"700\" height=\"546\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Click finish, and you\u2019ll be brought to the datasets panel, where you\u2019ll see that the interactions dataset is now configured. You\u2019ll need to repeat this process twice more, creating datasets for users and products. Everything will probably take a few minutes to import depending on the size of your data.<\/p>\n<p>Once everything is imported, you must create a solution, which is a trained model based off of your data, which can be used as the basis for campaigns which will give actual recommendations. Create one from the dashboard:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" alignnone wp-image-3666 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/e4578fe742f5bd3d70977c73b8191878\/p\/uploads\/2020\/01\/ab978daf-1.png\" alt=\"create new solution\" width=\"700\" height=\"292\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Give it a name, and select the recipe you\u2019d like to use to power the solution. You can select this manually, or you can choose \u201cAutoML,\u201d which will use AWS\u2019s HRNN to make predictions. If you\u2019re unsure, select AutoML.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3667\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/94cea9fcb57a207e1e0ed2a2110a8464\/p\/uploads\/2020\/01\/ee31ab68-1.png\" alt=\"solution configuration\" width=\"700\" height=\"638\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Solutions will have multiple versions to make managing them easier. When you create the solution, the initial version will be created as well.<\/p>\n<p>Once your solution version finishes initializing, you can create a campaign: basically, an instanced inference engine, for getting actual recommendations. It has a REST API endpoint which you can query and use from your application.<\/p>\n<p>From the \u201cCampaigns\u201d tab in the sidebar, create a new campaign, give it a name, and select your solution. Once that\u2019s created, you should be able to test it out from the AWS CLI:<\/p>\n<pre>aws personalize<span class=\"token operator\">-<\/span>rec get<span class=\"token operator\">-<\/span>recommendations <span class=\"token operator\">--<\/span>campaign<span class=\"token operator\">-<\/span>arn <span class=\"token variable\">$CAMPAIGN_ARN<\/span> &#13;\n<span class=\"token operator\">--<\/span>user<span class=\"token operator\">-<\/span><span class=\"token function\">id<\/span> <span class=\"token variable\">$USER_ID<\/span> <span class=\"token operator\">--<\/span>query <span class=\"token string\">\"itemList[*].itemId\"<\/span><\/pre>\n<p>This command will fetch the recommendations from your campaign for the user ID specified. If everything works correctly, you should see a list of item IDs recommended for the user.<\/p>\n<p>To add real time data to the solution, you\u2019ll need to create an Event Tracker from the sidebar. This will give you a tracker ID which you can use to input data.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" imgchk9 alignnone wp-image-3668 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/84325200e5253b64290787b18e82729f\/p\/uploads\/2020\/01\/ab978daf-2.png\" alt=\"example function\" width=\"700\" height=\"356\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>There are two ways to set this up: if you\u2019re using AWS Amplify, AWS\u2019s web and mobile app backend framework, setup is simple, and you\u2019ll just have to configure it from the Amplify console. If you\u2019re not, you\u2019ll have to set up a Lambda function to process the data and send it to Personalize.\n<\/p><\/div>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">[*]If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener noreferrer\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/3647\/build-machine-learning-recommendations-into-your-app-with-aws-personalize\/\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[*]&#8221;#Build Machine Learning Recommendations Into Your App With AWS Personalize \u2013 CloudSavvy IT&#8221; AWS Personalize is a product recommendation engine which works much like the one used for Amazon.com, built up from over 20 years of personalization experience. You can implement it as your own API to power your app\u2019s suggestions with machine learning. What&#8230;<\/p>\n","protected":false},"author":1,"featured_media":76131,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/01\/3da27b5a.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-76130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/76130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=76130"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/76130\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/76131"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=76130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=76130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=76130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}