{"id":901,"date":"2020-04-12T20:41:24","date_gmt":"2019-05-27T19:24:18","guid":{"rendered":"https:\/\/www.aihello.com\/resources\/?p=901"},"modified":"2026-09-23T12:37:18","modified_gmt":"2026-09-23T12:37:18","slug":"multivariate-time-series-forecasting-using-deep-neural-networks","status":"publish","type":"post","link":"https:\/\/www.aihello.com\/resources\/blog\/multivariate-time-series-forecasting-using-deep-neural-networks\/","title":{"rendered":"Multivariate Time Series Forecasting using Deep Neural Networks"},"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 .ah-existing-step{display:grid;grid-template-columns:40px minmax(0,1fr);gap:16px;font-size:26px;line-height:1.45}.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-size:19px;font-weight:700}.ah-reading-guide h3.ah-existing-step{font-size:23px}<\/style><noscript><style>.ah-reading-guide [data-aos]{opacity:1!important;visibility:visible!important;transform:none!important}<\/style><\/noscript><p class=\"ah-lead\">Multivariate Time Series Forecasting is an important problem in many domains. Be it forecasting the demand for a product, or finding weather patterns, using time series parameters from the present to predict the future is vital to many organisations. In this article we are going to see <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> use recurrent neural networks with convolutional neural networks to predict time series forecast for grocery store <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>. <\/p><p>The data can be found <strong><a href=\"https:\/\/www.kaggle.com\/c\/rossmann-store-sales\/data\">here<\/a><\/strong>, and the code can be found <a href=\"https:\/\/gist.github.com\/wasifhameed\/1f104a21f680eaa55bce2abf9250fde5\"><strong>here<\/strong><\/a><strong><a href=\"https:\/\/gist.github.com\/wasifhameed\/1f104a21f680eaa55bce2abf9250fde5\">.<\/a><\/strong> This implementation was developed as a prototype for AI Hello, a company based in Toronto that provides e-commerce solutions including sales prediction for sellers on e-commerce platforms such as Amazon, Woocommerce, and Shopify.<\/p><p class=\"ah-definition wp-block-paragraph\">We are using an implementation called LSTNet to perform this prediction. LSTNet uses convolutional networks and recurrent networks in conjunction. Additionally, it also provides the capability to detect long or short term patterns according to the nature of the data.<\/p><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f901-1\" id=\"gspb_container-id-gsbp-f901-1\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"data-preparation-and-exploration\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Data_Preparation_and_Exploration\"><\/span>Data Preparation and Exploration<span class=\"ez-toc-section-end\"><\/span><\/h2><p>For this article we\u2019ll be looking at the data-set \u2014<a href=\"https:\/\/www.kaggle.com\/c\/rossmann-store-sales\/data\"> Rossman Store Sales<\/a> \u2014 available on Kaggle.<\/p><p>We are cleaning the data to get overall sales across all stores based on the day of the week and promotions. The code to extract this is given below:<\/p><p>The data now has aggregated values:<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to add a+ content in amazon | is amazon exchange rate good | how to automate order fulfillment shopify\" class=\"size-large aligncenter\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_UOd7aEq-341p6Sq3.png\" width=\"402\" height=\"221\"><\/figure><p>Now let\u2019s gain a better understanding of the cleaned data.<\/p><ol class=\"ah-steps\"><li><p>The graph below shows the sales average by each day of the week\u200a\u2014\u200aSundays have the lowest, and Mondays enjoy the highest sales.<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to sell on amazon europe | what does notable arrival mean on amazon | how to earn money on amazon\" class=\"size-large aligncenter\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_ijU45Ghqa5SPTuSG.png\" width=\"406\" height=\"246\"><\/figure><\/li><li><p> The relation between the number of customers and the total sales follow a linear pattern. It is only to be expected, but this is helpful while modelling our prediction algorithm.<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"what is cpc cost amazon | how to increase sell on amazon | is amazon available in sweden\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_bhw7ck6Np-PjFUBY.png\" width=\"458\" height=\"287\"><\/figure><\/li><li><p> Promotions have a big impact. The mean sales are almost doubled when a promotion was available:<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to sell books in amazon | how to send products to amazon fba uk | how to improve seo on amazon\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_S1zqemJHampK5B-t.png\" width=\"377\" height=\"259\"><\/figure><\/li><\/ol><p>We will split our data into test and train. We are using 20 percent of our data for training, 20 percent for validation, and we will train on 60 percent of our data.<\/p><p>Before we go into the model however, there is one important question to tackle. What are our features and what are our labels? Or in other words, what input are fitting to what desired output?<\/p><p class=\"ah-formula wp-block-paragraph\">In time series problems, our input <code>(X)<\/code> will be all the records from timestep <code>t(n-k)<\/code> to <code>t(n-1)<\/code>. The value we try to fit to this input will be our record at timestep <code>t(n)<\/code>. To model the problem in this fashion we <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2020\/04\/images-1-300x147.jpg\"  data-excerpt=\"Optimize your Amazon seller journey! Discover how FBA streamlines shipping, boosts seller ratings, and leverages customer feedback for online success.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/key-terms-you-need-to-know-when-you-start-out-as-a-seller\/\">need to do<\/a> further processing on the data. The code below demonstrates how to transform a time-series data this way.<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f901-2\" id=\"gspb_container-id-gsbp-f901-2\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"model-architecture\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_Architecture\"><\/span>Model Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2><p>Before we train the model, let\u2019s take a look at the model architecture. LSTNet has a very novel architecture, it uses both convolutional and recurrent components. It also has a skip-gram recurrent component to <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2020\/04\/download-14-300x154.jpg\"  data-excerpt=\"Mobile devices dominate shopping &amp; consumption. Learn why m-commerce apps are vital, when users engage most, and how iOS &amp; Android customers shop differently.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/what-to-take-into-account-to-win-over-mobile-consumers\/\">take into account<\/a> the long term patterns in the data better. Below, we have a detailed analysis of each component.<\/p><h3 id=\"convolutional-component\" class=\"wp-block-heading ah-process-heading ah-process-1\"><span class=\"ez-toc-section\" id=\"Convolutional_Component\"><\/span>Convolutional Component<span class=\"ez-toc-section-end\"><\/span><\/h3><p>The first layer of LSTNet is a convolutional <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2024\/12\/image-33-300x185.png\"  data-excerpt=\"Unlock the power of knowledge graphs for AI, LLMs &amp; RAG. Discover how to build efficient, cost-effective KGs with SpaCy: entity and relation extraction made easy.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/creating-a-knowledge-graph-without-llms\/\">network<\/a> without pooling, which aims to extract short-term patterns in the time dimension as well as local dependencies between variables. The convolutional layer consists of multiple filters of width \u03c9 and height n (the height is set to be the same as the number of variables)<\/p><h3 id=\"recurrent-component\" class=\"wp-block-heading ah-process-heading ah-process-2\"><span class=\"ez-toc-section\" id=\"Recurrent_Component\"><\/span> Recurrent Component<span class=\"ez-toc-section-end\"><\/span><\/h3><p>The output of the convolutional layer is simultaneously fed into the Recurrent component and Recurrent-skip component The Recurrent component is a recurrent layer with the Gated Recurrent Unit (GRU) and uses the RELU function as the hidden update activation function .<\/p><h3 id=\"recurrent-skip-component\" class=\"wp-block-heading ah-process-heading ah-process-3\"><span class=\"ez-toc-section\" id=\"Recurrent-skip_Component\"><\/span> Recurrent-skip Component<span class=\"ez-toc-section-end\"><\/span><\/h3><p>The Recurrent layers with GRU and LSTM unit are carefully designed to memorise the historical information and hence to be aware of relatively long-term dependencies. Due to gradient vanishing, however, GRU and LSTM usually fail to capture very long-term correlation in practice. A recurrent structure is used with temporal skip-connections to extend the temporal span of the information flow and hence to ease the <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/mistake-300x215.jpg\"  data-excerpt=\"Master Amazon SEO to beat competition! Learn how the A10 search engine works and discover strategies to boost your product rankings and sales on the Marketplace.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/amazon-seo-strategy-tips-and-tricks-for-beginners\/\">optimisation<\/a> process. <\/p><p>Specifically, skip-links are added between the current hidden cell and the hidden cells in the same phase in adjacent periods.<\/p><h3 id=\"4-temporal-attention-layer\" class=\"wp-block-heading ah-existing-step\"><span class=\"ez-toc-section\" id=\"_4Temporal_Attention_Layer\"><\/span>&nbsp;<span class=\"ah-literal-number\">4.<\/span><span>Temporal Attention Layer<\/span><span class=\"ez-toc-section-end\"><\/span><\/h3><p>The Recurrent-skip layer requires a predefined hyper-parameter p, which is unfavourable in the non-seasonal time series prediction, or whose period length is dynamic over time. To alleviate such issue, we consider an alternative approach, attention mechanism, which learns the weighted combination of hidden representations at each window position of the input matrix.<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f901-3\" id=\"gspb_container-id-gsbp-f901-3\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"hyper-parameters-for-the-model\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Hyper-parameters_for_the_model\"><\/span>Hyper-parameters for the model<span class=\"ez-toc-section-end\"><\/span><\/h2><p>Following are the parameters to decide for the model :<\/p><ol class=\"ah-steps\"><li><p><strong>Epochs <\/strong>\u2014 We found the loss function plateauing after 40 epochs for this data-set. Hence we decided running 50 epochs will provide <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> good accuracy.<\/p><\/li><li><p><strong>Window <\/strong>\u2014 This specifies how many time-steps from the past we should take into account for the prediction of sales in the next time-step. A key consideration is to make the window small enough to detect short term patterns, but also be aware of the larger trend. We have decided that the sales information from the past quarter would provide enough information to the predictor. <\/p><p>Hence, our window size is 90.<\/p><\/li><li><p><strong>Batchsize<\/strong>&#8211; We are passing 128 values in one batch.<\/p><\/li><li><p><strong>CNN Filters<\/strong>&#8211; Number of output filters in the CNN layer<\/p><\/li><li><p><strong>CNN Kernel <\/strong>\u2014 The filter size of CNN layer. We are using a value of 6<\/p><\/li><li><p><strong>GRU Units<\/strong>&#8211; Number of hidden states in GRU layer. We are using 100 hidden states<\/p><\/li><li><p><strong>Skip <\/strong>\u2014 Number of values to skip when looking for patterns, we are assuming weekly pattern and will use a value of 7<\/p><\/li><li><p><strong>Highway <\/strong>\u2014 Number of timeseries values to consider for the linear layer, i.e. the auto regression layer, we will keep this to 90 too.<\/p><\/li><\/ol><p class=\"ah-callout wp-block-paragraph\">And lastly, we are using RMSE values as our error function and we will use Adam Optimizer for our model.<\/p><p>Now we will see how to setup the neural network :<\/p><p>With our model defined we can delve into the code for actually training our data.<\/p><\/div><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f901-4\" id=\"gspb_container-id-gsbp-f901-4\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><h2 id=\"evaluate-model\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Evaluate_Model\"><\/span>Evaluate Model<span class=\"ez-toc-section-end\"><\/span><\/h2><p>The mean squared error value and the correlation value for our model during training and validation are given below. We see a considerable decrease in the error and a rising trend in the correlation, both of which are good indicators.<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to start making money on amazon | how does amazon ppc work | how to see competitors keywords\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_zjoB7oKVuW7YEAuE.png\" width=\"600\" height=\"327\"><\/figure><p>Given below is the prediction for the whole time period. Let\u2019s concentrate on the test values prediction.<\/p><p>The blue values indicate the actual sales.<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to find competitors adwords keywords | what is ppc for amazon | what is amazon ppc campaign\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0__2h1ArJNvDp2vGVz.png\" width=\"600\" height=\"331\"><\/figure><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to get on amazon vine | how to sell products on amazon | how to calculate fba fees\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_xiJDKcoUj7Hn-e6p.png\" width=\"600\" height=\"341\"><\/figure><p>We have not considered certain factors such as holidays and individual store location holidays which will help us predict the outliers, but the general trend and dips, as well as the weeks in which the sales were generally low or high have been perfectly predicted by the algorithm. Taking a closer look reveals this:<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"what are good alternatives for managing amazon advertising myself | how to ship merchant fulfilled amazon | how to use amazon sponsored brands ads\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_zbbT0sEBbRDwChoU.png\" width=\"600\" height=\"337\"><\/figure><h2 id=\"comparison\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Comparison\"><\/span>Comparison<span class=\"ez-toc-section-end\"><\/span><\/h2><p>To compare the results, here is the prediction pattern we are getting with FB Prophet( another time series prediction <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/amazon-brand-analytics-guide-300x200.jpg\"  data-excerpt=\"Master Amazon sales! Discover how Amazon Brand Analytics empowers sellers to stand out, optimize products,\" href=\"https:\/\/www.aihello.com\/resources\/blog\/amazon-brand-analytics-a-complete-guide-2026\/\">tool<\/a>):<\/p><figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" title=\"how to make money off amazon | what is amazon sponsored products | how to set up fba amazon\" class=\"alignnone size-large\" src=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2019\/05\/0_NPaFYLDLTuKScCSe.png\" width=\"600\" height=\"295\"><figcaption>FB Prophet Results<\/figcaption><\/figure><div class=\"wp-block-group ah-callout\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><p>We see that while FB Prophet is good at accounting for the periodicity and general trend of the data, it does not do as good a job when it comes to predicting actual sales value for each day. Even while sales tend to rise and fall by each week, FB Prophet predicts the same values for all weeks. Our algorithm however, is able to predict how each week is going to be different from the last, which is a huge factor when it comes to sales <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/mistake-300x215.jpg\"  data-excerpt=\"Master Amazon SEO to beat competition! Learn how the A10 search engine works and discover strategies to boost your product rankings and sales on the Marketplace.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/amazon-seo-strategy-tips-and-tricks-for-beginners\/\">strategy<\/a>. <\/p><\/div><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Predict grocery sales using Multivariate Time Series Forecasting. This article explores LSTNet, combining RNN and CNN for accurate e-commerce sales prediction.<\/p>\n","protected":false},"author":1,"featured_media":931,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":".gspb_container-id-gsbp-f901-1,.gspb_container-id-gsbp-f901-2,.gspb_container-id-gsbp-f901-3,.gspb_container-id-gsbp-f901-4{flex-direction:column;box-sizing:border-box}#gspb_container-id-gsbp-f901-1.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f901-2.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f901-3.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f901-4.gspb_container>p:last-of-type{margin-bottom:0}#gspb_container-id-gsbp-f901-1.gspb_container.aos-animate,#gspb_container-id-gsbp-f901-1.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f901-2.gspb_container.aos-animate,#gspb_container-id-gsbp-f901-2.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f901-3.gspb_container.aos-animate,#gspb_container-id-gsbp-f901-3.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f901-4.gspb_container.aos-animate,#gspb_container-id-gsbp-f901-4.gspb_container[data-gs-aos]{opacity:1;transform:translateZ(0)}#gspb_container-id-gsbp-f901-1.gspb_container,#gspb_container-id-gsbp-f901-2.gspb_container,#gspb_container-id-gsbp-f901-3.gspb_container,#gspb_container-id-gsbp-f901-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,40,103],"tags":[177,445],"republish_tag":[],"class_list":["post-901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-amazon","category-demand-forecasting","category-machine-learning","tag-demand-forecasting","tag-ecommerce"],"_links":{"self":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/901","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=901"}],"version-history":[{"count":1,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/901\/revisions"}],"predecessor-version":[{"id":14425,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/901\/revisions\/14425"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/media\/931"}],"wp:attachment":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/categories?post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/tags?post=901"},{"taxonomy":"republish_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/republish_tag?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}