Home
%3CLINGO-SUB%20id%3D%22lingo-sub-784908%22%20slang%3D%22en-US%22%3ERetail%20Sales%20Forecasting%20with%20Discovery%20Hub%C2%AE%20and%20Azure%20Machine%20Learning%20service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-784908%22%20slang%3D%22en-US%22%3E%3CP%3ESales%20forecasting%20is%20an%20essential%20task%20for%20the%20management%20of%20almost%20any%20retail%20organization.%20Being%20able%20to%20estimate%20sales%20on%20the%20lowest%20granularity%2C%20per%20retail%20outlet%20is%20crucial%20for%20both%20inventory%20and%20cost%20optimization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlthough%20it%20can%20seem%20easy%20at%20first%20glance%2C%20building%20a%20sales%20forecasting%20model%20that%20is%20accurate%20and%20ready%20to%20run%20in%20a%20production%20environment%20is%20a%20complex%20challenge%20involving%20both%20technical%20skills%2C%20process%20skills%2C%20and%20domain%20knowledge.%20Couple%20that%20with%20a%20set%20of%20diverse%20new%20technologies%20and%20services%20in%20the%20AI%20space%2C%20massive%20data%20volumes%20and%20hundreds%20of%20different%20data%20sources%20and%20you%20can%20understand%20why%20it%20has%20become%20hard%20to%20identify%20and%20prepare%20the%20right%20data%20for%20analytics%20and%20artificial%20intelligence%20(AI).%20Add%20to%20that%20the%20need%20to%20eliminate%20the%20creation%20of%20data%20silos%20and%20integrate%20the%20forecasts%20from%20an%20AI%20routine%20with%20existing%20business%20applications%20and%20you%20can%20understand%20why%20many%20enterprise%20organizations%20dedicate%20vast%20teams%20to%20this%2C%20in%20order%20to%20differentiate%20themselves%20in%20a%20competitive%20market.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMany%20medium%20and%20corporate%20sized%20organizations%20that%20want%20to%20start%20leveraging%20the%20transformative%20benefits%20of%20AI%20and%20experimenting%20with%20machine%20learning%20models%20do%20not%20have%20the%20necessary%20resources%2C%20knowledge%2C%20or%20even%20data%20scientists%20to%20get%20started%2C%20leaving%20them%20behind%20the%20competitive%20curve.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%2C%20we%E2%80%99ll%20describe%20an%20end-to-end%20solution%20for%20building%20a%20retail%20sales%20forecasting%20model%20with%20%3CA%20href%3D%22https%3A%2F%2Fwww.timextender.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETimeXtender%E2%80%99s%3C%2FA%3EDiscovery%20Hub%20(Data%20management%20platform%20for%20building%20a%20modern%20data%20estate)%20and%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Foverview-what-is-azure-ml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20service%3C%2FA%3E.%20The%20entire%20end-to-end%20solution%2C%20including%20Discovery%20Hub%2C%20the%20required%20Azure%20services%20as%20well%20as%20all%20the%20prerequisites%20is%20now%20available%20through%20a%20one-click%20%3CA%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fmarketplace%2Fapps%2Ftimextender.timextender_dh_sqldb_dl_aas_ml%3Ftab%3DOverview%26amp%3Bpub_source%3Demail%26amp%3Bpub_status%3Dsuccess%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Marketplace%3C%2FA%3Edeployment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBefore%20we%20dive%20into%20the%20architecture%20and%20the%20actual%20code%2C%20here%20is%20a%20quick%20video%20from%20TimeXtender%20that%20describes%20the%20solution%20and%20how%20to%20get%20started.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1795243049%22%20id%3D%22toc-hId-1795243049%22%20id%3D%22toc-hId-1795243049%22%20id%3D%22toc-hId-1795243049%22%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252F1OJGWrVeajM%253Ffeature%253Doembed%26amp%3Burl%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D1OJGWrVeajM%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252F1OJGWrVeajM%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22600%22%20height%3D%22337%22%20scrolling%3D%22no%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%20title%3D%22Video%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--756913912%22%20id%3D%22toc-hId--756913912%22%20id%3D%22toc-hId--756913912%22%20id%3D%22toc-hId--756913912%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-985896423%22%20id%3D%22toc-hId-985896423%22%20id%3D%22toc-hId-985896423%22%20id%3D%22toc-hId-985896423%22%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EHigh%20Level%20Architecture%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3EThis%20solution%20uses%20TimeXtender%E2%80%99s%20Discovery%20Hub%20to%20prepare%20the%20historical%20sales%20forecasting%20data%20that%20the%20Azure%20ML%E2%80%99s%20Automated%20ML%20(Auto%20ML)%20functionality%20uses%20to%20train%2C%20select%2C%20and%20operationalize%20a%20time-series%20forecasting%20model%20for%20multiple%20time-series%2C%20all%20while%20integrating%20this%20output%20with%20the%20existing%20analytics%20business%20process.%20Below%20is%20a%20high-level%20architecture%20of%20the%20solution%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20904px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125348iB8C5D7196E268E73%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22tx_architectural_diagram.png%22%20title%3D%22tx_architectural_diagram.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1566260538%22%20id%3D%22toc-hId--1566260538%22%20id%3D%22toc-hId--1566260538%22%20id%3D%22toc-hId--1566260538%22%3ESolution%20Overview%3C%2FH2%3E%0A%3CP%3EWhen%20you%20deploy%20the%20solution%20through%20the%20%3CA%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fmarketplace%2Fapps%2Ftimextender.timextender_dh_sqldb_dl_aas_ml%3Ftab%3DOverview%26amp%3Bpub_source%3Demail%26amp%3Bpub_status%3Dsuccess%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Marketplace%3C%2FA%3E%2C%20all%20the%20required%20services%20including%20the%20Discovery%20Hub%2C%20Azure%20Data%20Lake%20Storage%20Gen2%2C%20Azure%20SQL%2C%20Azure%20Analysis%20Services%20and%20the%20Azure%20Machine%20Learning%20Workspace%20are%20deployed%20in%20sequence%2C%20eliminating%20the%20need%20for%20any%20manual%20configuration.%20Once%20deployed%2C%20we%20run%20an%20Azure%20Jupyter%20Notebook%20(hosted%20in%20an%20Azure%20Notebook%20VM)%20to%20connect%20to%20the%20data%2C%20run%20AutoML%20to%20create%20and%20test%20the%20best%20model%2C%20and%20predict%20and%20store%20the%20forecast%20sales%20back%20into%20Azure%20SQL%20DB.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20more%20information%20on%20how%20Azure%20AutoML%20trains%20a%20multivariate%20regression%20with%20lagging%20features%20for%20forecasting%20please%20visit%20the%20links%20below%3A%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Fconcept-automated-ml%23time-series-forecasting%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Fconcept-automated-ml%23time-series-forecasting%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Fhow-to-auto-train-forecast%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Fhow-to-auto-train-forecast%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20%3CA%20href%3D%22https%3A%2F%2Fsupport.timextender.com%2Fhc%2Fen-us%2Farticles%2F360031207371-Configure-Discovery-Hub-with-ADLS-Gen2-Azure-SQL-DB-AAS-and-ML%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edetailed%20step-by-step%20guide%3C%2FA%3Eto%20complete%20the%20deployment%20has%20been%20made%20available%20by%20TimeXtender.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--19963708%22%20id%3D%22toc-hId--19963708%22%20id%3D%22toc-hId--19963708%22%20id%3D%22toc-hId--19963708%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1722846627%22%20id%3D%22toc-hId-1722846627%22%20id%3D%22toc-hId-1722846627%22%20id%3D%22toc-hId-1722846627%22%3ERead%20the%20input%3C%2FH3%3E%0A%3CP%3ETimeXtender%E2%80%99s%20Discovery%20Hub%20prepares%20and%20cleanses%20all%20the%20historical%20monthly%20aggregated%20sales%20data%20and%20stores%20it%20in%20an%20Azure%20SQL%20database.%20The%3A%20%3CEM%3ESalesQuantity%3C%2FEM%3E%2C%20%3CEM%3EStoreName%2C%20ProductName%3C%2FEM%3E%2C%20%3CEM%3EProductCategory%3C%2FEM%3E%2C%20and%20%3CEM%3EOrderDate%3C%2FEM%3Efields%20are%20used%20to%20create%20a%20time-series%20sales%20forecasting%20model%20that%20predicts%20sales%20by%20Store%2C%20ProductCategory%2C%20and%20Product%20for%20the%20next%20three%20months.%20In%20this%20step%20we%20read%20the%20following%20user%20parameters%20to%20be%20used%20in%20further%20steps.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20859px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125349i69529C0EBA8CFDC0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code1.png%22%20title%3D%22code1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--829310334%22%20id%3D%22toc-hId--829310334%22%20id%3D%22toc-hId--829310334%22%20id%3D%22toc-hId--829310334%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-913500001%22%20id%3D%22toc-hId-913500001%22%20id%3D%22toc-hId-913500001%22%20id%3D%22toc-hId-913500001%22%3ESetup%20prerequisites%3C%2FH3%3E%0A%3CP%3EInstall%20all%20necessary%20prerequisites%2C%20including%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fconnect%2Fpython%2Fpyodbc%2Fpython-sql-driver-pyodbc%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epyodbc%3C%2FA%3Eand%20%3CA%20href%3D%22https%3A%2F%2Fwww.sqlalchemy.org%2Fdownload.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Esqlalchemy%3C%2FA%3Eto%20connect%20to%20Azure%20SQL.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20859px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125350i1A1CA2753F44F555%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code2.png%22%20title%3D%22code2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1638656960%22%20id%3D%22toc-hId--1638656960%22%20id%3D%22toc-hId--1638656960%22%20id%3D%22toc-hId--1638656960%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-104153375%22%20id%3D%22toc-hId-104153375%22%20id%3D%22toc-hId-104153375%22%20id%3D%22toc-hId-104153375%22%3EConnect%20and%20read%20data%20from%20Azure%20SQL%3C%2FH3%3E%0A%3CP%3EWe%20connect%20directly%20to%20Azure%20SQL%20to%20read%20the%20historical%20sales%20data.%20With%20Discovery%20Hub%2C%20the%20dataset%20is%20already%20aggregated%20by%20Store%2C%20Category%2C%20and%20Product%20thus%20there%20is%20no%20need%20for%20further%20data%20preparation%2Fmanipulation%20within%20the%20Azure%20Notebook%20(E.g%20remove%20duplicates%2C%20aggregation%2C%20cleansing%20etc.).%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20859px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125351iD8C68BDF9310E44B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code3.png%22%20title%3D%22code3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1131802421%22%20id%3D%22toc-hId-1131802421%22%20id%3D%22toc-hId-1131802421%22%20id%3D%22toc-hId-1131802421%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId--1420354540%22%20id%3D%22toc-hId--1420354540%22%20id%3D%22toc-hId--1420354540%22%20id%3D%22toc-hId--1420354540%22%3EData%20Splitting%3C%2FH3%3E%0A%3CP%3EWe%20now%20split%20the%20data%20into%20a%20training%20and%20a%20testing%20set%20for%20later%20forecast%20evaluation.%20The%20splits%20should%20be%20stratified%20by%20series%2C%20so%20we%20use%20a%20group-by%20statement%20on%20the%20grain%20columns.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20859px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125352i9F50F3682D5E7B40%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code4.png%22%20title%3D%22code4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-322455795%22%20id%3D%22toc-hId-322455795%22%20id%3D%22toc-hId-322455795%22%20id%3D%22toc-hId-322455795%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-2065266130%22%20id%3D%22toc-hId-2065266130%22%20id%3D%22toc-hId-2065266130%22%20id%3D%22toc-hId-2065266130%22%3EModeling%3C%2FH3%3E%0A%3CP%3EThe%20AutoMLConfig%20object%20defines%20the%20settings%20and%20data%20for%20an%20AutoML%20training%20job.%20Here%2C%20we%20set%20necessary%20inputs%20like%20the%20task%20type%2C%20the%20number%20of%20AutoML%20iterations%20to%20try%2C%20the%20training%20data%2C%20and%20cross-validation%20parameters.%3C%2FP%3E%0A%3CP%3EThe%20forecast%20horizon%20is%20given%20in%20units%20of%20the%20time-series%20frequency%3B%20for%20instance%2C%20the%20sales%20forecasting%20series%20frequency%20is%20monthly%2C%20so%20a%20horizon%20of%203%20means%20that%20a%20trained%20model%20will%20estimate%20sales%20up%20to%203%20months%20beyond%20the%20latest%20date%20in%20the%20training%20data%20for%20each%20series.%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20summary%20of%20AutoMLConfig%20parameters%20used%20for%20training%20the%20retail%20sales%20forecasting%20model%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20858px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125353iA5C9ED4BCF709577%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code5.png%22%20title%3D%22code5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--486890831%22%20id%3D%22toc-hId--486890831%22%20id%3D%22toc-hId--486890831%22%20id%3D%22toc-hId--486890831%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1255919504%22%20id%3D%22toc-hId-1255919504%22%20id%3D%22toc-hId-1255919504%22%20id%3D%22toc-hId-1255919504%22%3ERetrieve%20the%20best%20model%3C%2FH3%3E%0A%3CP%3EEach%20run%20within%20an%20Experiment%20stores%20serialized%20(i.e.%20pickled)%20pipelines%20from%20the%20AutoML%20iterations.%20We%20can%20now%20retrieve%20the%20pipeline%20with%20the%20best%20performance%20on%20the%20validation%20dataset%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20858px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125354iC1CDABFC763B2BCE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code6.png%22%20title%3D%22code6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1296237457%22%20id%3D%22toc-hId--1296237457%22%20id%3D%22toc-hId--1296237457%22%20id%3D%22toc-hId--1296237457%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-446572878%22%20id%3D%22toc-hId-446572878%22%20id%3D%22toc-hId-446572878%22%20id%3D%22toc-hId-446572878%22%3EPredict%20and%20store%20results%20back%20in%20Azure%20SQL%3C%2FH3%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20859px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125355i1E7A98B122AB0186%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code7.png%22%20title%3D%22code7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20860px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125356iC03A90E2CA036913%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22code8.png%22%20title%3D%22code8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20code%20for%20this%20blog%20post%20is%20a%20simplified%20version%20of%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%2Fblob%2Fmaster%2Fhow-to-use-azureml%2Fautomated-machine-learning%2Fforecasting-orange-juice-sales%2Fauto-ml-forecasting-orange-juice-sales.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%3CSPAN%3EGitHub%20sample%2C%20which%20includes%20additional%20steps%20to%20evaluate%20and%20operationalize%20the%20sales%20forecasting%20model.%3C%2FSPAN%3E%20%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--308632724%22%20id%3D%22toc-hId--308632724%22%20id%3D%22toc-hId--308632724%22%20id%3D%22toc-hId--308632724%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1434177611%22%20id%3D%22toc-hId-1434177611%22%20id%3D%22toc-hId-1434177611%22%20id%3D%22toc-hId-1434177611%22%3ESummary%3C%2FH2%3E%0A%3CP%3EBuilding%20an%20accurate%20and%20useful%20sales%20forecasting%20model%20can%20be%20a%20complex%2C%20time-consuming%20challenge%20that%20requires%20extensive%20resources.%20This%20blog%20post%20provided%20an%20overview%20of%20how%20to%20easily%20create%20a%20sales%20forecasting%20model%20with%20TimeXtender%E2%80%99s%20Discovery%20Hub%20and%20Azure%20Automated%20Machine%20Learning%20service.%20You%20can%20get%20started%20by%20deploying%20the%20%3CA%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fmarketplace%2Fapps%2Ftimextender.timextender_dh_sqldb_dl_aas_ml%3Ftab%3DOverview%26amp%3Bpub_source%3Demail%26amp%3Bpub_status%3Dsuccess%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDiscovery%20Hub%C2%AE%20and%20ADLS%20Gen2%2C%20SQL%20DB%2C%20AAS%2C%20and%20ML%20%3C%2FA%3EAzure%20Marketplace%20template.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20let%20us%20know%20your%20thoughts%2Fquestions%20in%20the%20comments%20section%20below.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1121299317%22%20id%3D%22toc-hId-1121299317%22%20id%3D%22toc-hId-1121299317%22%20id%3D%22toc-hId-1121299317%22%3E%3CSPAN%20style%3D%22background%3A%20white%3B%22%3EFurther%20Resources%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E-%20%3CA%20href%3D%22http%3A%2F%2Fblog.timextender.com%2Freversing-the-80-20-rule-in-data-wrangling%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETimeXtender%3A%20Reversing%20the%2080-20%20rule%20in%20data%20wrangling%20for%20AI%20and%20machine%20learning%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%26nbsp%3B%3CA%20title%3D%22TimeXtender%3A%20Tap%20into%20the%20transformative%20power%20of%20data%20with%20Discovery%20Hub%20and%20Azure%20Machine%20Learning%20service%22%20href%3D%22http%3A%2F%2Fblog.timextender.com%2Ftransformative-power-of-data-with-discovery-hub-and-azure-machine-learning-service%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETimeXtender%3A%20Tap%20into%20the%20transformative%20power%20of%20data%20with%20Discovery%20Hub%20and%20Azure%20Machine%20Learning%20service%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FMachineLearningNotebooks%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20service%20example%20notebooks%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fmachine-learning-service%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20service%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fresearch%2Fproject%2Fautoml%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20AutoML%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E-%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fblog%2Fgetting-ai-ml-and-devops-working-better-together%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGetting%20AI%2FML%20and%20DevOps%20working%20better%20together%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-784908%22%20slang%3D%22en-US%22%3E%3CP%3EEnd-to-end%20solution%20for%20building%20a%20retail%20sales%20forecasting%20model%20with%20%3CA%20href%3D%22https%3A%2F%2Fwww.timextender.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETimeXtender%E2%80%99s%3C%2FA%3EDiscovery%20Hub%20and%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fservice%2Foverview-what-is-azure-ml%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Machine%20Learning%20service%3C%2FA%3E.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20897px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F125346i45AD418027983CDE%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22tx_teaser.png%22%20title%3D%22tx_teaser.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-784908%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eazure%20ml%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzureAI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EE2E%20Solutions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-834068%22%20slang%3D%22en-US%22%3ERe%3A%20Retail%20Sales%20Forecasting%20with%20Discovery%20Hub%C2%AE%20and%20Azure%20Machine%20Learning%20service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-834068%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20to%20use%20this%20technology%20to%20the%20traditional%20manufacturing%20industry%20business%20such%20as%20the%20%3CA%20title%3D%22stainless%20steel%20cups%22%20href%3D%22http%3A%2F%2Fwww.accoyun.com%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Estainless%20steel%20cups%3C%2FA%3E%2C%20%3CA%20href%3D%22http%3A%2F%2Fwww.accoyun.com%2Fe_productshow%2F%3F30-Vacuum-insulated-travel-mugs-manufacturer-in-China-travel-mugs-for-coffee-30.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Evacuum%20thermos%20cups%3C%2FA%3E%2C%20especially%20in%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.accoyun.com%2Fe_productshow%2F%3F19-Bullet-Stainless-Steel-Vacuum-Cup-500ml-16oz-BPA-free-19.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eretails%3C%2FA%3Eand%26nbsp%3B%3CA%20href%3D%22http%3A%2F%2Fwww.accoyun.com%2Fe_products%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EB2B%20international%20trading%3C%2FA%3E%3F%26nbsp%3B%3C%2FP%3E%3CP%3ELooking%20forward%20to%20your%20suggestion.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-855030%22%20slang%3D%22en-US%22%3ERE%3A%20Retail%20Sales%20Forecasting%20with%20Discovery%20Hub%C2%AE%20and%20Azure%20Machine%20Learning%20service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-855030%22%20slang%3D%22en-US%22%3EI%20could%20use%20a%20lot%20of%20help%20with%20getting%20IoT%20ironed%20out%20AI%20U%26amp%3BI%20have%20more%20businesses%20than%20people%20have%20products%20and%20I%20mean%20it's%20a%20cluster%20fu%404%20SORRY%20will%20try%20to%20not%20use%20that%20word%20but%20when%20you%20see%20what%20we%20are%20work%20with%20or%20whats%20working%20us%20it%20is%20a%20lot.%3C%2FLINGO-BODY%3E

Sales forecasting is an essential task for the management of almost any retail organization. Being able to estimate sales on the lowest granularity, per retail outlet is crucial for both inventory and cost optimization.

 

Although it can seem easy at first glance, building a sales forecasting model that is accurate and ready to run in a production environment is a complex challenge involving both technical skills, process skills, and domain knowledge. Couple that with a set of diverse new technologies and services in the AI space, massive data volumes and hundreds of different data sources and you can understand why it has become hard to identify and prepare the right data for analytics and artificial intelligence (AI). Add to that the need to eliminate the creation of data silos and integrate the forecasts from an AI routine with existing business applications and you can understand why many enterprise organizations dedicate vast teams to this, in order to differentiate themselves in a competitive market.

 

Many medium and corporate sized organizations that want to start leveraging the transformative benefits of AI and experimenting with machine learning models do not have the necessary resources, knowledge, or even data scientists to get started, leaving them behind the competitive curve.

 

In this blog post, we’ll describe an end-to-end solution for building a retail sales forecasting model with TimeXtender’s Discovery Hub (Data management platform for building a modern data estate) and the Azure Machine Learning service. The entire end-to-end solution, including Discovery Hub, the required Azure services as well as all the prerequisites is now available through a one-click Azure Marketplace deployment.

 

Before we dive into the architecture and the actual code, here is a quick video from TimeXtender that describes the solution and how to get started.

 

High Level Architecture

This solution uses TimeXtender’s Discovery Hub to prepare the historical sales forecasting data that the Azure ML’s Automated ML (Auto ML) functionality uses to train, select, and operationalize a time-series forecasting model for multiple time-series, all while integrating this output with the existing analytics business process. Below is a high-level architecture of the solution:

 

tx_architectural_diagram.png

Solution Overview

When you deploy the solution through the Azure Marketplace, all the required services including the Discovery Hub, Azure Data Lake Storage Gen2, Azure SQL, Azure Analysis Services and the Azure Machine Learning Workspace are deployed in sequence, eliminating the need for any manual configuration. Once deployed, we run an Azure Jupyter Notebook (hosted in an Azure Notebook VM) to connect to the data, run AutoML to create and test the best model, and predict and store the forecast sales back into Azure SQL DB.

 

For more information on how Azure AutoML trains a multivariate regression with lagging features for forecasting please visit the links below:

- https://docs.microsoft.com/azure/machine-learning/service/concept-automated-ml#time-series-forecasti...

- https://docs.microsoft.com/azure/machine-learning/service/how-to-auto-train-forecast

 

A detailed step-by-step guide to complete the deployment has been made available by TimeXtender.

 

Read the input

TimeXtender’s Discovery Hub prepares and cleanses all the historical monthly aggregated sales data and stores it in an Azure SQL database. The: SalesQuantity, StoreName, ProductName, ProductCategory, and OrderDate fields are used to create a time-series sales forecasting model that predicts sales by Store, ProductCategory, and Product for the next three months. In this step we read the following user parameters to be used in further steps.

code1.png

 

Setup prerequisites

Install all necessary prerequisites, including pyodbc and sqlalchemy to connect to Azure SQL.

code2.png

 

Connect and read data from Azure SQL

We connect directly to Azure SQL to read the historical sales data. With Discovery Hub, the dataset is already aggregated by Store, Category, and Product thus there is no need for further data preparation/manipulation within the Azure Notebook (E.g remove duplicates, aggregation, cleansing etc.).

code3.png

 

Data Splitting

We now split the data into a training and a testing set for later forecast evaluation. The splits should be stratified by series, so we use a group-by statement on the grain columns.

code4.png

 

Modeling

The AutoMLConfig object defines the settings and data for an AutoML training job. Here, we set necessary inputs like the task type, the number of AutoML iterations to try, the training data, and cross-validation parameters.

The forecast horizon is given in units of the time-series frequency; for instance, the sales forecasting series frequency is monthly, so a horizon of 3 means that a trained model will estimate sales up to 3 months beyond the latest date in the training data for each series.

Here is a summary of AutoMLConfig parameters used for training the retail sales forecasting model:

code5.png

 

Retrieve the best model

Each run within an Experiment stores serialized (i.e. pickled) pipelines from the AutoML iterations. We can now retrieve the pipeline with the best performance on the validation dataset:

code6.png

 

Predict and store results back in Azure SQL

code7.png

code8.png

The code for this blog post is a simplified version of this GitHub sample, which includes additional steps to evaluate and operationalize the sales forecasting model.  

 

Summary

Building an accurate and useful sales forecasting model can be a complex, time-consuming challenge that requires extensive resources. This blog post provided an overview of how to easily create a sales forecasting model with TimeXtender’s Discovery Hub and Azure Automated Machine Learning service. You can get started by deploying the Discovery Hub® and ADLS Gen2, SQL DB, AAS, and ML Azure Marketplace template.

 

Please let us know your thoughts/questions in the comments section below.

Further Resources

- TimeXtender: Reversing the 80-20 rule in data wrangling for AI and machine learning

TimeXtender: Tap into the transformative power of data with Discovery Hub and Azure Machine Learning...

- Azure Machine Learning service example notebooks

- Azure Machine Learning service

- Azure AutoML

- Getting AI/ML and DevOps working better together

1 Comment
New Contributor
I could use a lot of help with getting IoT ironed out AI U&I have more businesses than people have products and I mean it's a cluster fu@4 SORRY will try to not use that word but when you see what we are work with or whats working us it is a lot.