{"id":1270,"date":"2020-04-12T00:06:28","date_gmt":"2017-03-22T23:37:00","guid":{"rendered":"https:\/\/www.aihello.com\/resources\/predicting-amazon-sales-using-deep-learning-2\/"},"modified":"2026-09-23T14:21:13","modified_gmt":"2026-09-23T14:21:13","slug":"predicting-amazon-sales-using-deep-learning-2","status":"publish","type":"post","link":"https:\/\/www.aihello.com\/resources\/blog\/predicting-amazon-sales-using-deep-learning-2\/","title":{"rendered":"Predicting Amazon sales using Deep Learning"},"content":{"rendered":"<div class=\"wp-block-group ah-reading-guide\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><style>\n.ah-reading-guide{max-width:820px;margin:0 auto;color:#26364a;font-size:18px;line-height:1.8;counter-reset:ah-section}.ah-reading-guide *{box-sizing:border-box}.ah-reading-guide p{margin:0 0 22px;line-height:1.8}.ah-reading-guide strong{color:#142d48}.ah-reading-guide h2{position:relative;margin:56px 0 24px;padding-top:24px;border-top:1px solid #dce7ef;font-size:29px;line-height:1.35;letter-spacing:-.4px;color:#142d48}.ah-reading-guide h2.ah-numbered{padding-left:54px;counter-increment:ah-section}.ah-reading-guide h2.ah-numbered:before{content:counter(ah-section,decimal-leading-zero);position:absolute;left:0;top:26px;display:flex;align-items:center;justify-content:center;width:38px;height:38px;background:#eaf4fc;color:#216faf;border-radius:10px;font-size:15px;font-weight:700;letter-spacing:0}.ah-reading-guide h3{position:relative;margin:34px 0 16px;font-size:23px;line-height:1.4;color:#163f65}.ah-reading-guide h4{position:relative;margin:28px 0 14px;font-size:20px;line-height:1.45;color:#163f65}.ah-reading-guide .ah-lead{margin:0 0 28px;padding:24px 28px;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#eef6fc;font-size:20px;line-height:1.75}.ah-reading-guide .ah-callout,.ah-reading-guide .ah-formula{margin:28px 0;padding:24px 26px;border:1px solid #d7e5f1;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#f5f9fd}.ah-reading-guide .ah-formula{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums;line-height:1.9;overflow-wrap:anywhere}.ah-reading-guide ul,.ah-reading-guide ol{margin:24px 0 30px;padding-left:28px}.ah-reading-guide li{margin:0 0 12px;padding-left:7px;line-height:1.75}.ah-reading-guide li::marker{color:#2479ba;font-weight:700}.ah-reading-guide ol.ah-steps{list-style:none;counter-reset:ah-step;padding:0;display:grid;gap:14px}.ah-reading-guide ol.ah-steps>li{position:relative;counter-increment:ah-step;margin:0;padding:22px 24px 22px 64px;border:1px solid #dbe7f1;border-radius:12px;background:#f6fafd}.ah-reading-guide ol.ah-steps>li:before{content:counter(ah-step);position:absolute;top:23px;left:20px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;background:#2378b9;color:white;font-size:14px;font-weight:700}.ah-reading-guide ul.ah-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:0;list-style:none}.ah-reading-guide ul.ah-cards>li{margin:0;padding:20px 22px;border:1px solid #dbe8f2;background:#f7fbfe;border-radius:12px;font-size:17px;line-height:1.7}.ah-reading-guide ul.ah-cards>li:last-child:nth-child(odd){grid-column:1\/-1}.ah-reading-guide .ah-cards>li>strong:first-child{display:block;margin-bottom:8px;color:#19598d}.ah-reading-guide .ah-step-panel{margin:22px 0;padding:24px 28px;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#f5f9fd}.ah-reading-guide .ah-step-panel h3{margin-top:0}.ah-reading-guide .ah-step-panel p:last-child{margin-bottom:0}.ah-reading-guide figure{max-width:100%;margin:30px 0}.ah-reading-guide figure.wp-block-image{padding:7px;border:1px solid #e0e8ef;border-radius:12px;background:white;box-shadow:0 5px 18px rgba(20,45,72,.06)}.ah-reading-guide img{max-width:100%;height:auto}.ah-reading-guide figure.wp-block-image img{display:block;border-radius:6px}.ah-reading-guide figcaption{font-size:14px;line-height:1.5;color:#587086;margin-top:10px}.ah-reading-guide figure.wp-block-table{overflow-x:auto;border:1px solid #d8e5ef;border-radius:10px}.ah-reading-guide table{width:100%;border-collapse:collapse;font-size:16px;line-height:1.6}.ah-reading-guide th,.ah-reading-guide td{padding:14px 16px;border:1px solid #d8e5ef;text-align:left;vertical-align:top}.ah-reading-guide th{background:#eaf4fc;color:#163f65;font-weight:700}.ah-reading-guide tbody tr:nth-child(even){background:#f6f9fc}.ah-reading-guide blockquote{margin:30px 0;padding:22px 26px;border-left:4px solid #2479ba;background:#f3f8fc;border-radius:0 10px 10px 0}.ah-reading-guide #ez-toc-container{width:100%;margin:32px 0 42px;padding:22px 24px;border:1px solid #cbdfee;border-top:4px solid #2479ba;border-radius:12px;background:#f7fbfe;box-shadow:none}.ah-reading-guide #ez-toc-container .ez-toc-title{margin:0;font-size:20px;font-weight:700;color:#163f65;line-height:1.5}.ah-reading-guide #ez-toc-container .ez-toc-title-container{margin-bottom:14px}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1{display:block;column-count:2;column-gap:26px;padding:0;margin:0}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1>li{break-inside:avoid;padding:11px 0;margin:0;border-bottom:1px solid #dce7ef;line-height:1.5;font-size:16px}.ah-reading-guide #ez-toc-container ul ul{margin:7px 0 0;padding-left:18px}.ah-reading-guide #ez-toc-container li li{padding:0;margin:5px 0;font-size:14px}.ah-reading-guide #ez-toc-container a{color:#19598d;text-decoration:none}.ah-reading-guide #ez-toc-container a:hover{text-decoration:underline}.ah-reading-guide #ez-toc-container a:focus-visible{outline:3px solid #2479ba;outline-offset:4px;border-radius:3px}.ah-reading-guide :is(h2,h3,h4)>.ez-toc-section{position:absolute;top:-100px;left:0}.ah-reading-guide :is(h2,h3,h4)>.ez-toc-section-end{position:absolute;top:0;left:0}.ah-reading-guide [id]{scroll-margin-top:100px}.ah-reading-guide .gspb_container{min-width:0}@media(max-width:700px){.ah-reading-guide{font-size:17px}.ah-reading-guide h2{font-size:25px;margin-top:44px}.ah-reading-guide h2.ah-numbered{padding-left:43px}.ah-reading-guide h2.ah-numbered:before{width:30px;height:30px;font-size:13px}.ah-reading-guide h3{font-size:21px}.ah-reading-guide ul.ah-cards{grid-template-columns:1fr}.ah-reading-guide .ah-lead,.ah-reading-guide .ah-callout,.ah-reading-guide .ah-formula,.ah-reading-guide .ah-step-panel{padding:20px}.ah-reading-guide .ah-lead,.ah-reading-guide .ah-formula{font-size:18px}.ah-reading-guide #ez-toc-container{padding:18px}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1{column-count:1}}@media(prefers-reduced-motion:reduce){.ah-reading-guide [data-aos]{opacity:1!important;visibility:visible!important;transform:none!important;transition:none!important;animation:none!important}}\n\n.ah-reading-guide .ah-process-heading{padding-left:48px;min-height:36px}.ah-reading-guide .ah-process-heading:before{position:absolute;left:0;top:0;width:34px;height:34px;display:flex;align-items:center;justify-content:center;border-radius:9px;background:#eaf4fc;color:#216faf;font-size:15px;font-weight:700}.ah-reading-guide .ah-process-1:before{content:\"01\"}.ah-reading-guide .ah-process-2:before{content:\"02\"}.ah-reading-guide .ah-process-3:before{content:\"03\"}.ah-reading-guide .ah-process-4:before{content:\"04\"}.ah-reading-guide .ah-process-5:before{content:\"05\"}.ah-reading-guide .ah-process-6:before{content:\"06\"}.ah-reading-guide .ah-process-7:before{content:\"07\"}.ah-reading-guide .ah-process-8:before{content:\"08\"}.ah-reading-guide .ah-process-9:before{content:\"09\"}\n.ah-reading-guide .ah-definition{padding:20px 24px;margin:14px 0;border:1px solid #dbe7f1;border-radius:12px;background:#f8fbfe}.ah-reading-guide .ah-definition strong{color:#163f65}\n.ah-reading-guide .ah-long-form-list>li{margin-bottom:28px}.ah-reading-guide .ah-long-form-list>li>strong:first-child{display:block;font-size:22px;line-height:1.4;margin-bottom:16px}.ah-reading-guide .ah-long-form-list li img{display:block;margin:22px auto}.ah-reading-guide .ah-formula-comparison{font-variant-numeric:tabular-nums}\n.ah-reading-guide h5,.ah-reading-guide h6{font-size:18px;line-height:1.5;color:#163f65;margin:26px 0 14px;font-weight:700}\n.ah-reading-guide h2.ah-instruction-heading{font-size:21px;margin:24px 0 18px;padding-top:18px}.ah-reading-guide h2.ah-instruction-heading:before{top:18px}\n.ah-reading-guide ul.ah-stacked-cards{list-style:none;padding:0}.ah-reading-guide .ah-stacked-cards>li{margin:14px 0;padding:20px 24px;border:1px solid #dbe7f1;border-radius:12px;background:#f8fbfe}\n.ah-reading-guide .ah-minor-label{font-weight:700;color:#1e4e64;font-size:18px;margin:20px 0 8px;}\n.ah-reading-guide h3.ah-do,.ah-reading-guide h3.ah-dont{font-size:21px;padding:18px 22px;border-radius:0 10px 10px 0}.ah-reading-guide h3.ah-do{border-left:4px solid #20877e;background:#f0faf8}.ah-reading-guide h3.ah-dont{border-left:4px solid #ae6340;background:#fff7f0}\n.ah-reading-guide p.ah-fact-row{margin:6px 0;padding:12px 18px;background:#f4f8fc;border-left:3px solid #c7dcf0;border-radius:0 8px 8px 0;font-size:17px;line-height:1.65}.ah-reading-guide p.ah-cta a{display:inline-block;padding:12px 20px;border-radius:9px;background:#135faa;color:#fff;text-decoration:none;font-weight:700}.ah-reading-guide p.ah-cta a:hover{background:#104d89}.ah-reading-guide .ah-agency-summary td:first-child{width:38%;color:#184b75}\n.ah-reading-guide details.ah-original-index{padding:16px 20px;border:1px solid #dce7f0;border-radius:10px;margin:24px 0;background:#f8fafc}.ah-reading-guide details.ah-original-index summary{cursor:pointer;font-size:18px;font-weight:700;color:#244f74}.ah-reading-guide details.ah-original-index>ol{margin-top:18px}\n.ah-reading-guide ul.ah-cycle-cards{grid-template-columns:repeat(3,minmax(0,1fr));gap:22px}.ah-reading-guide ul.ah-cycle-cards>li{position:relative;text-align:center;display:flex;align-items:center;justify-content:center;min-height:110px;font-weight:700;color:#20567d}.ah-reading-guide ul.ah-cycle-cards>li:last-child:nth-child(odd){grid-column:auto}.ah-reading-guide ul.ah-cycle-cards>li:not(:last-child)::after{content:\"\u203a\";position:absolute;right:-19px;top:50%;transform:translateY(-50%);font-size:28px;color:#3785b4}@media(max-width:700px){.ah-reading-guide ul.ah-cycle-cards{grid-template-columns:1fr}.ah-reading-guide ul.ah-cycle-cards>li:not(:last-child)::after{right:50%;top:auto;bottom:-25px;transform:rotate(90deg)}}\n.ah-reading-guide .ah-process-10::before{content:\"10\"}\n.ah-reading-guide pre.wp-block-code{background:#122238;color:#eff6ff;border:1px solid #29415f;border-radius:12px;padding:22px 24px;margin:24px 0;overflow-x:auto;font-size:15px;line-height:1.7;white-space:pre;tab-size:4}.ah-reading-guide pre.wp-block-code code{background:transparent;color:inherit;padding:0;white-space:pre;font-family:Consolas,Monaco,monospace}.ah-reading-guide p code{background:#edf3fa;color:#204d78;border-radius:4px;padding:2px 5px}\n.ah-reading-guide ol.ah-steps.ah-start-2{counter-reset:ah-step 1}\n.ah-reading-guide ol.ah-steps.ah-start-3{counter-reset:ah-step 2}\n.ah-reading-guide ol.ah-steps.ah-start-4{counter-reset:ah-step 3}\n.ah-reading-guide ol.ah-steps.ah-start-5{counter-reset:ah-step 4}\n.ah-reading-guide ol.ah-steps.ah-start-6{counter-reset:ah-step 5}\n.ah-reading-guide ol.ah-steps.ah-start-7{counter-reset:ah-step 6}\n.ah-reading-guide ol.ah-steps.ah-start-8{counter-reset:ah-step 7}\n.ah-reading-guide ol.ah-steps.ah-start-9{counter-reset:ah-step 8}\n.ah-reading-guide ol.ah-steps.ah-start-10{counter-reset:ah-step 9}\n.ah-reading-guide ol.ah-steps.ah-start-11{counter-reset:ah-step 10}\n.ah-reading-guide ol.ah-steps.ah-start-12{counter-reset:ah-step 11}\n.ah-reading-guide #ez-toc-container nav{max-height:460px;overflow-y:auto;padding-right:8px}.ah-reading-guide figure.ah-comparison-wide{max-height:650px;overflow:auto;border:1px solid #dae4ee;border-radius:12px}.ah-reading-guide .ah-comparison-wide table{min-width:760px;font-size:15px}.ah-reading-guide .ah-comparison-wide thead th{position:sticky;top:0;background:#183f65;color:#fff;z-index:1}.ah-reading-guide figure.ah-agency-summary tbody th{width:30%;background:#edf4fa;color:#244764;font-weight:700}\n.ah-reading-guide #ez-toc-container a.ez-toc-link::before{content:none!important;display:none!important}\n.ah-reading-guide .ah-comparison-wide thead th,.ah-reading-guide .ah-comparison-wide thead th *{color:#fff!important}\n.ah-reading-guide .ah-equation{display:block;margin:16px 0;padding:16px 20px;border-left:4px solid #2378b9;background:#edf4fa;border-radius:8px;font-size:20px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}\n.ah-reading-guide .ah-feature-comparison thead th:nth-child(1){width:18%}.ah-reading-guide .ah-feature-comparison thead th:nth-child(2){width:12%;white-space:nowrap}.ah-reading-guide .ah-feature-comparison thead th:nth-child(3){width:48%}.ah-reading-guide .ah-feature-comparison thead th:nth-child(4){width:22%}\n.ah-reading-guide.ah-compact-toc #ez-toc-container ul.ez-toc-list>li>ul>li>ul{display:none}.ah-reading-guide h4.ah-do{color:#276044!important}.ah-reading-guide h4.ah-dont{color:#855218!important}.ah-reading-guide p.ah-tool-bullet{margin:.45em 0!important;padding:.6em 1em;border-radius:8px;background:#f4f7fa;line-height:1.65}\n.ah-reading-guide .ah-glossary-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;margin:30px 0}.ah-reading-guide .ah-glossary-entry{background:#f7f9fc;border:1px solid #dce5ef;border-radius:12px;padding:22px;height:100%;box-sizing:border-box}.ah-reading-guide .ah-glossary-entry h2{font-size:21px!important;margin:0 0 14px!important;line-height:1.4!important;border:0;padding:0}.ah-reading-guide .ah-glossary-entry p{font-size:16px!important;line-height:1.7!important;margin:0!important}@media(max-width:650px){.ah-reading-guide .ah-glossary-grid{grid-template-columns:1fr}}\n.ah-reading-guide .ah-glossary-grid{display:block}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;align-items:stretch}.ah-reading-guide .ah-glossary-entry{height:auto!important;margin:0!important;min-width:0}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container>.wp-block-greenshift-blocks-container{display:flex;min-width:0}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container>.wp-block-greenshift-blocks-container>.ah-glossary-entry{flex:1}@media(max-width:650px){.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container{grid-template-columns:1fr}}\n.ah-reading-guide ol.ah-steps.ah-feature-grid{grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:700px){.ah-reading-guide ol.ah-steps.ah-feature-grid{grid-template-columns:1fr}}\n.ah-reading-guide pre.wp-block-preformatted{background:#122238;color:#eff6ff;border:1px solid #29415f;border-radius:12px;padding:22px 24px;margin:24px 0;overflow-x:auto;font-size:15px;line-height:1.7;white-space:pre;tab-size:4;font-family:Consolas,Monaco,monospace}.ah-reading-guide pre.wp-block-preformatted code{background:transparent;color:inherit;padding:0;white-space:pre;font:inherit}.ah-reading-guide .ah-output-sample{max-height:360px;overflow:auto;padding:24px;border:1px solid #d7e5f1;border-radius:12px;background:#f5f9fd;font-size:16px;line-height:1.8}\n.ah-reading-guide pre.wp-block-preformatted,.ah-reading-guide pre.wp-block-preformatted code{white-space:pre!important;text-align:left!important}.ah-reading-guide pre br{display:initial!important}\n.ah-reading-guide .wp-block-media-text{display:grid!important;grid-template-columns:minmax(120px,22%) minmax(0,1fr)!important;gap:24px;padding:28px;border:1px solid #d7e5f1;border-radius:14px;background:#f5f9fd;align-items:center!important}.ah-reading-guide .wp-block-media-text__content{min-width:0;max-width:none!important;width:auto!important;padding:0!important}.ah-reading-guide .wp-block-media-text__content p{width:auto!important;max-width:none!important;text-align:left!important}.ah-reading-guide .wp-block-media-text__content p:not(:first-child) strong{font-weight:400}.ah-reading-guide .wp-block-media-text__media{margin:0!important;min-width:0}.ah-reading-guide .wp-block-media-text__media img{width:100%;max-width:160px;height:auto;margin:auto}.ah-reading-guide .wp-block-media-text__content .wp-block-button{max-width:100%}@media(max-width:650px){.ah-reading-guide .wp-block-media-text{grid-template-columns:1fr!important;padding:20px}.ah-reading-guide .wp-block-media-text__media{grid-column:1!important;grid-row:1!important}.ah-reading-guide .wp-block-media-text__content{grid-column:1!important;grid-row:2!important}}.ah-reading-guide ol.ah-literal-flow{list-style:none;margin:28px 0;padding:0}.ah-reading-guide ol.ah-literal-flow>li{display:grid;grid-template-columns:38px minmax(0,1fr);gap:18px;padding:24px;margin:18px 0;border:1px solid #d7e5f1;border-radius:12px;background:#f8fbfe}.ah-reading-guide .ah-literal-number{display:flex;align-items:center;justify-content:center;background:#1979b4;color:#fff;width:36px;height:36px;border-radius:50%;font-weight:700}.ah-reading-guide ol.ah-literal-flow>li>div>p:first-child{margin-top:0}.ah-reading-guide ol.ah-literal-flow>li>div>p:last-child{margin-bottom:0}@media(max-width:650px){.ah-reading-guide ol.ah-literal-flow>li{padding:18px;gap:12px;grid-template-columns:32px minmax(0,1fr)}.ah-reading-guide .ah-literal-number{width:30px;height:30px}}.ah-reading-guide pre.ah-code-long{max-height:620px;overflow:auto}<\/style><noscript><style>.ah-reading-guide [data-aos]{opacity:1!important;visibility:visible!important;transform:none!important}<\/style><\/noscript><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f1270-1\" id=\"gspb_container-id-gsbp-f1270-1\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"introduction\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction\"><\/span>Introduction<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"ah-lead wp-block-paragraph\">My primary aim was to predict the sales of an item given the <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/www.aihello.com\/amazon_launch_calculator.html\">Best Seller Rank<\/a> on <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/02\/boost-sales-300x200.jpg\"  data-excerpt=\"Unlock Amazon&#039;s Brand Referral Bonus! Discover how driving external traffic, especially from Google Ads, boosts your sales, increases organic reach, and earns rewards.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/boost-amazon-sales-using-google-ads\/\">Amazon<\/a>. Predicting the sales helps me in other use cases like suggesting sellers the best products to sell. My final aim is to provide data insights about any product: How much it will sell as well as when, where and how.<\/p><h2 id=\"what-is-amazon-s-best-seller-rank\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_Amazons_Best_Seller_Rank\"><\/span>What is Amazon&#8217;s Best Seller Rank?<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"ah-definition wp-block-paragraph\"><a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2020\/04\/download-7-1.jpg\"  data-excerpt=\"Don&#039;t guess Amazon prices. Learn proven strategies for setting competitive, profitable prices on Amazon. Go beyond lowballing to maximize your sales!\" href=\"https:\/\/www.aihello.com\/resources\/blog\/pricing-your-products-correctly\/\">Best Selling<\/a> Rank is a ranking system provided by Amazon that is linked to the number of <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/02\/boost-sales-300x200.jpg\"  data-excerpt=\"Unlock Amazon&#039;s Brand Referral Bonus! Discover how driving external traffic, especially from Google Ads, boosts your sales, increases organic reach, and earns rewards.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/boost-amazon-sales-using-google-ads\/\">sales<\/a> of that product. This rank is calculated frequently. An important point to note is that Best Selling Rank is a &#8216;ranking system&#8217; and by itself it doesn&#8217;t mean anything. &nbsp;<\/p><p>A rank of #1, therefore, means that the product has sold more than any other product in that category, on that marketplace.<\/p><p>This kind of makes it relatively easy to predict the number of sales of a product if we know the sales of other products ranking close to it.<\/p><p>How did we get the initial sales data? I have been selling professionally on Amazon and have been tracking my own sales vs ranks for all my products in various categories. Additionally I interviewed other professional sellers to get an approximate idea of their sales.<\/p><p>With all the data obtained, cleaned and setup I entered the next phase of design: Choosing the best framework for Predictive Analysis<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f1270-2\" id=\"gspb_container-id-gsbp-f1270-2\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"enter-spark\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Enter_Spark\"><\/span>Enter Spark<span class=\"ez-toc-section-end\"><\/span><\/h2><p>At the 2016 Spark Summit Nick Heudecker asked the question <a href=\"https:\/\/spark-summit.org\/2016\/events\/is-apache-spark-the-future-of-data-analysis\/\" target=\"_blank\" rel=\"noopener noreferrer\">Is Apache Spark the future of data analysis?<\/a><\/p><p>While no clear answer was provided we certainly know that&nbsp;<a href=\"https:\/\/thomaswdinsmore.com\/2017\/02\/14\/spark-is-the-future-of-analytics\/\" target=\"_blank\" rel=\"noopener noreferrer\">Spark alone is not the future of data analysis<\/a>. We depended on a number of third-party tools like Stanford NLP for natural language parsing and <a href=\"https:\/\/github.com\/ganeshkrishnan1\/socialmediabot\" target=\"_blank\" rel=\"noopener noreferrer\">tensor flow for image analysis<\/a>&nbsp;but Spark formed the backbone of almost all of it.<\/p><figure class=\"wp-block-image\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/portfortune.files.wordpress.com\/2017\/02\/screen-shot-2017-02-09-at-2-58-05-pm.png?w=860&amp;h=631\"><img loading=\"lazy\" decoding=\"async\" title=\"how to set up amazon sponsored ads | what is the amazon marketplace | how to be a best seller on amazon\" src=\"https:\/\/portfortune.files.wordpress.com\/2017\/02\/screen-shot-2017-02-09-at-2-58-05-pm.png?w=860&amp;h=631\" width=\"640\" height=\"468\" border=\"0\"><\/a><\/figure><p>While there might be some truth to the above chart I tend to believe the Spark has not reached peak hype yet. Or maybe it seems that way from here down under in Australia and probably Spark has surpassed peak in the Silicon Valley.<\/p><p>Spark has played amazingly well with our spring boot application and our standalone <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2020\/04\/5770b06cdf39b-300x140.jpeg\"  data-excerpt=\"AiHello: Your AI e-commerce solution to automate Amazon &amp; eBay sales. Leverage machine learning for smart pricing, optimized keywords, and accurate sales forecasts.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/welcome\/\">machine learning<\/a> application (Command Line Interface).<\/p><p>Our database is PostgresSQL and Spark CLI programs run weekly reading the PostgresSQL database via JDBC bridge, processes them, builds learning models and saves the trained model to local path.<\/p><p>This trained model is then read by the Spark in Spring Boot to quickly make predictions or process any incoming information from web users in real time. &nbsp;With all the infrastructure setup we had estimated a week to complete the linear regression algorithms or worst case scenario of two weeks if the problem turned out to be the more complex log-linear regression.<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f1270-3\" id=\"gspb_container-id-gsbp-f1270-3\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"houston-we-have-a-problem\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Houston_We_have_a_problem\"><\/span>Houston, We have a problem<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"ah-formula wp-block-paragraph\">I expected a straightforward linear regression model of type&nbsp;<i>&nbsp;<code>y=mx+b<\/code>&nbsp;<\/i>This would have made the problem very simple as Apache Spark has&nbsp;GeneralizedLinearRegression &nbsp;&nbsp;<\/p><pre class=\"wp-block-preformatted ah-code-long\">val glr = new GeneralizedLinearRegression()&#10;  .setFamily(\"gaussian\")&#10;  .setLink(\"identity\")&#10;  .setMaxIter(100)&#10;  .setRegParam(0.4)<\/pre><p>I first plotted the chart on an Excel Sheet as I had already exported the data from SQL to CSV.<\/p><p>The relationship between <a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/www.aihello.com\/amazon_launch_calculator.html\">Amazon Best Seller Rank<\/a> and number of sales turned out to be like this chart.<\/p><figure class=\"wp-block-image\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/2.bp.blogspot.com\/-ey70zFiSfnI\/WMui5LnNSjI\/AAAAAAABSzE\/mcJ240_FvDUW4jd5816V8taoZdAPlGDcQCLcB\/s1600\/bsrrales.png\"><img loading=\"lazy\" decoding=\"async\" title=\"how to sell on amazon germany from uk | how to be best seller on amazon | how to sell on amazon fbm\" src=\"https:\/\/2.bp.blogspot.com\/-ey70zFiSfnI\/WMui5LnNSjI\/AAAAAAABSzE\/mcJ240_FvDUW4jd5816V8taoZdAPlGDcQCLcB\/s640\/bsrrales.png\" width=\"640\" height=\"364\" border=\"0\"><\/a><\/figure><p>So it looked like a log-linear model and I assumed the <i>poisson <\/i>family of &nbsp;GeneralizedLinearRegression&nbsp;would be a good fit. &nbsp;We changed the GLM family to <i>poisson <\/i>and ran the tests few more times however the Mean Squared Error &amp; the RMSE was too huge.&nbsp;<\/p><p>I suspect Spark has issues in dealing with sparse data.<\/p><p>We have limited data of our sales and we don&#8217;t sell products in all categories since Amazon has gated some categories which left <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/selling-on-amazon-mexico-300x225.jpg\"  data-excerpt=\"Mexico&#039;s eCommerce boom presents huge opportunities for Amazon sellers. This guide explores the thriving Mexican online market, Amazon.mx&#039;s growth, and key considerations for successfully selling your products to millions of Mexican consumers. Learn how to navigate logistics, expand your reach, and capitalize on this expanding market.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/how-to-launch-an-amazon-mexico-business\/\">us<\/a> unable to sell or make any observations on sales for those gated categories.<\/p><p>With limited amount of input data, Spark MSE was too high and even for our products for which we knew the sales, the predicted sales were way off the mark.<\/p><p>Over the next few weeks I spent my time trying out all combinations of Regression family on Spark and none of them gave the desired results. I had absolutely no idea on <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/08\/amazon-backend-search-terms-optimization-guide-basics-how-to-300x300.png\"  data-excerpt=\"Unlock Amazon success! Master backend keywords to boost product visibility, improve relevancy, and drive sales without keyword stuffing.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/everything-about-optimizing-amazon-backend-keywords-guide-2022\/\">how to<\/a> proceed now and this reminded me of this quote by <a href=\"https:\/\/www.facebook.com\/dan.ariely\/posts\/904383595868?imm_mid=0a9701&amp;cmp=em-strata-newsletters-strata-olc-20130529-elist\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Dan Ariely<\/a><\/p><blockquote>\u201cBig data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone claims they are doing it\u2026\u201d<\/blockquote><p>My last resort was to use <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/18297-1-300x116.jpg\"  data-excerpt=\"Predict grocery sales using Multivariate Time Series Forecasting. This article explores LSTNet, combining RNN and CNN for accurate e-commerce sales prediction.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/multivariate-time-series-forecasting-using-deep-neural-networks\/\">Deep Neural Network<\/a> Learning. I had completed the Andrew Ng course on <a href=\"https:\/\/www.coursera.org\/learn\/machine-learning\" target=\"_blank\" rel=\"noopener noreferrer\">Machine Learning<\/a>&nbsp;when he has first launched it and I cannot recommend it enough. Now my aim was to use Neural Network to solve this problem.<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f1270-4\" id=\"gspb_container-id-gsbp-f1270-4\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"we-must-go-deeper\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"We_must_go_Deeper\"><\/span>We must go Deeper.<span class=\"ez-toc-section-end\"><\/span><\/h2><p>I eventually made the decision to keep Spark for big data analysis however we would resort to other libraries for <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/18297-1-300x116.jpg\"  data-excerpt=\"Predict grocery sales using Multivariate Time Series Forecasting. This article explores LSTNet, combining RNN and CNN for accurate e-commerce sales prediction.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/multivariate-time-series-forecasting-using-deep-neural-networks\/\">Deep Learning<\/a>.<\/p><p>I narrowed down my choices to two libraries<\/p><ol class=\"ah-literal-flow\"><li><span class=\"ah-literal-number\">1)<\/span><div><p> <a href=\"https:\/\/deeplearning4j.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">DeepLearning4J<\/a><\/p><\/div><\/li><li><span class=\"ah-literal-number\">2)<\/span><div><p> <a href=\"https:\/\/databricks.com\/blog\/2014\/06\/30\/sparkling-water-h20-spark.html\" target=\"_blank\" rel=\"noopener noreferrer\">Sparkling water- H2O<\/a><\/p><\/div><\/li><\/ol><p>I was particularly impressed with<a href=\"http:\/\/www.kdnuggets.com\/2015\/04\/deep-learning-fight-crime.html\" target=\"_blank\" rel=\"noopener noreferrer\"> this article <\/a>&nbsp;that discusses how H2O deep learning was used to predict crimes and arrests in San Francisco and Chicago. Since our future use cases are similar where we will be predicting fraudulent users and fraudulent competitors I decided to plunge into Deep Learning using H20 rather than attempting to work around with Spark ML issues.<\/p><p>Sparkling Water-H2O runs within the Spark framework so I could use their integrated framework without replacing Spark. This was a definite bonus for me. Also the documentation was nicely done and I was thoroughly impressed with H2o web-UI , Flow.<\/p><p>I could test my data and algorithms on the browser without writing any code.<\/p><p>The Web-UI provided excellent insights into the data and true to my beliefs, the Deep Learning Neural Networks provided exceptional results.<\/p><p>Using the optimized parameters from H2O Flow, I quickly coded the Deep Learning network in my CLI Program.<\/p><pre class=\"wp-block-preformatted ah-code-long\">val train = result('categoryIndex, '<a rel=\"noopener\" target=\"_blank\" href=\"https:\/\/www.aihello.com\/amazon_launch_calculator.html\">bsr<\/a>, 'sales)&#10;\/\/ Configure Deep Learning algorithm&#10;val dlParams = new DeepLearningParameters()&#10;dlParams._train = train&#10;dlParams._response_column = 'sales&#10;dlParams._fast_mode = false&#10;dlParams._epochs = 30&#10;dlParams._nfolds = 3&#10;dlParams._distribution = DistributionFamily.gaussian&#10;val dl = new DeepLearning(dlParams)<\/pre><pre class=\"wp-block-preformatted ah-code-long\">val dlModel = dl.trainModel.get&#10;\/\/save the model&#10;ModelSerializationSupport.exportH2OModel(dlModel, new File(\"\/data\/deeplearning.bin\").toURI)<\/pre><p>On the Web API (Spring Boot) application I read this model in and used it for making predictions in realtime from web users.<\/p><pre class=\"wp-block-preformatted ah-code-long\">def startup(): Unit = {&#10;  dlModel = ModelSerializationSupport.loadH2OModel(new File(\"\/data\/deeplearning.bin\").toURI)&#10;  println(\"Initialization Of BSR Deep learning Module complete\")&#10;}<\/pre><pre class=\"wp-block-preformatted ah-code-long\">def predict(categoryIndex:Int, bsr:Int): Double = {&#10;if(null==dlModel) {&#10;startup()&#10;}&#10;println(\"n====&gt; Making prediction with help of DeepLearning modeln\")&#10;val caseClassDS = Seq(InputBSR(categoryIndex, bsr, 0)).toDS()&#10;val finalresult = dlModel.score(caseClassDS)('predict)&#10;val finaldf = asDataFrame(finalresult)(sqlContext)&#10;val predictedSales = finaldf.first().getDouble(0)&#10;println(s\"For category index ${categoryIndex} and BSR ${bsr} the result is ... ${predictedSales}\")&#10;predictedSales&#10;}<\/pre><h2 id=\"the-end-result-is-this\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_end_result_is_this\"><\/span>The end result is this:<span class=\"ez-toc-section-end\"><\/span><\/h2><figure class=\"wp-block-image\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/4.bp.blogspot.com\/-nNEqiKAP-Yw\/WMuj6HsHsSI\/AAAAAAABSzM\/gYPIcUK_L6Uimhr74XScSOLiqBnuQKw-QCLcB\/s1600\/chrome%2Bextension.png\"><img loading=\"lazy\" decoding=\"async\" title=\"what are sales trends | what is the number one book on amazon | how to sell on amazon\" src=\"https:\/\/4.bp.blogspot.com\/-nNEqiKAP-Yw\/WMuj6HsHsSI\/AAAAAAABSzM\/gYPIcUK_L6Uimhr74XScSOLiqBnuQKw-QCLcB\/s640\/chrome%2Bextension.png\" width=\"640\" height=\"316\" border=\"0\"><\/a><\/figure><p>As you can see from the screenshot, we can only predict sales of products which have Best Selling Ranks for top level category since we have trained the Neural Network with data of sales only from top selling categories.<\/p><p>As we keep collecting data and our algorithm has sufficient confidence to predict sales of lower level categories, the app will start making prediction for more number of products.<\/p><p class=\"ah-callout wp-block-paragraph\">This, IMHO, is the best thing about Big Data and Deep Learning. The machine never stops learning and eventually as more data is fed into it, the algorithms automatically start making better predictions.<\/p><p><a href=\"https:\/\/chrome.google.com\/webstore\/detail\/aihello-for-amazon\/pgoamldljlplabdgigpaadipejlapgmg\" target=\"_blank\" rel=\"noopener noreferrer\">The chrome extension is available here<\/a>&nbsp;on the Google app store<\/p><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Master Amazon sales prediction using Best Seller Rank. We explore leveraging BSR for deep data insights with Spark, revealing the hurdles of advanced predictive analysis.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":".gspb_container-id-gsbp-f1270-1,.gspb_container-id-gsbp-f1270-2,.gspb_container-id-gsbp-f1270-3,.gspb_container-id-gsbp-f1270-4{flex-direction:column;box-sizing:border-box}#gspb_container-id-gsbp-f1270-1.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f1270-2.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f1270-3.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f1270-4.gspb_container>p:last-of-type{margin-bottom:0}#gspb_container-id-gsbp-f1270-1.gspb_container.aos-animate,#gspb_container-id-gsbp-f1270-1.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f1270-2.gspb_container.aos-animate,#gspb_container-id-gsbp-f1270-2.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f1270-3.gspb_container.aos-animate,#gspb_container-id-gsbp-f1270-3.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f1270-4.gspb_container.aos-animate,#gspb_container-id-gsbp-f1270-4.gspb_container[data-gs-aos]{opacity:1;transform:translateZ(0)}#gspb_container-id-gsbp-f1270-1.gspb_container,#gspb_container-id-gsbp-f1270-2.gspb_container,#gspb_container-id-gsbp-f1270-3.gspb_container,#gspb_container-id-gsbp-f1270-4.gspb_container{position:relative;transition-duration:.5s;transition-timing-function:var(--gs-root-animation-easing, cubic-bezier(0.42, 0, 0.58, 1));opacity:var(--gs-root-animation-opacity, 0);transition-property:opacity,transform,filter;box-sizing:border-box}","footnotes":""},"categories":[89,103],"tags":[237,173,238,255,505,273],"republish_tag":[],"class_list":["post-1270","post","type-post","status-publish","format-standard","hentry","category-amazon","category-machine-learning","tag-amazon-ad-spend","tag-amazon-ads","tag-amazon-ads-automation","tag-amazon-ads-autopilot","tag-amazon-best-seller-rank","tag-amazon-sales"],"_links":{"self":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/1270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/comments?post=1270"}],"version-history":[{"count":1,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/1270\/revisions"}],"predecessor-version":[{"id":14459,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/1270\/revisions\/14459"}],"wp:attachment":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/media?parent=1270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/categories?post=1270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/tags?post=1270"},{"taxonomy":"republish_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/republish_tag?post=1270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}