%3CLINGO-SUB%20id%3D%22lingo-sub-1468697%22%20slang%3D%22en-US%22%3ELinear%20regression%26nbsp%3Banalysis%26nbsp%3Bon%20COVID%20data%20using%20SQL%20endpoint%20in%20Azure%20Synapse%20Analytics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1468697%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Foverview-what-is%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EAzure%20Synapse%20Analytics%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AFis%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ebig%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edata%20analytics%20service%20that%20enables%20you%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eanalyze%20data%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bon%20Azure%20storage%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Busing%20SQL%20language%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EYou%20can%20use%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESQL%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eendpoints%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql-data-warehouse%2Fsql-data-warehouse-overview-what-is%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Eprovisioned%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AFand%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql%2Fon-demand-workspace-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Eserverless%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E)%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%20analyze%20your%20data%20using%20SQL%20language.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESQL%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Every%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bpowerful%20analytic%20language%20that%20can%20be%20used%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eimplement%20performant%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eanalysis%20on%20big%20data.%20As%20an%20example%2C%20you%20can%20write%20a%20SQL%20query%20that%20creates%20a%20linear%20regression%20model%20on%20your%20datasets.%20Phil%20Factor%20described%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehow%20to%20implement%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fwww.red-gate.com%2Fsimple-talk%2Fblogs%2Fstatistics-sql-simple-linear-regressions%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Esimple%20linear%20regression%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Busing%20SQL%20language.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20this%20article%2C%20you%20will%20see%20how%20you%20can%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bcreate%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bsimple%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blinear%20regression%20model%20to%20determine%20COVID%20mortality%20rate%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eusing%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fservices%2Fopen-datasets%2Fcatalog%2Fcovid-19-data-lake%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EAzure%20Open%20Dat%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3Easet%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESynapse%20SQL%20endpoint%20in%20Synapse%20Analytics.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId--1324793424%22%20id%3D%22toc-hId--1324793424%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EPrerequisite%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETo%20try%20this%20sample%2C%20you%20need%20to%20have%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EAzure%20Synapse%20Analytics%20workspace%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20If%20you%20don%E2%80%99t%20have%20one%20you%20can%20easily%20deploy%20it%20using%20-ERR%3AREF-NOT-FOUND-Azure%20portal%20or%20this%E2%80%AF%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fquickstart-create-workspace%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EDeployment%20template%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20Synapse%20workspace%20automatically%20deploys%20one%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fquickstart-create-workspace%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Eserverless%3C%2FA%3E%20Synapse%20SQL%20endpoint%20that%20is%20everything%20we%20need%20for%20this%20kind%20of%20analysis.%20With%20the%20workspace%20you%20are%20also%20getting%20easy-to-use%20web%20UI%20called%20Synapse%20Studio%20that%20enables%20you%20to%20start%20analyzing%20files%20in%20your%20browser.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3ENOTE%3A%20You%20need%20Synapse%20SQL%20-ERR%3AREF-NOT-FOUND-serverless%20(on-demand)%20query%20endpoint%20to%20execute%20the%20code%20in%20this%20article.%20The%20functionalities%20used%20in%20this%20article%20are%20still%20not%20available%20in%26nbsp%3B-ERR%3AREF-NOT-FOUND-provisioned%E2%80%AF%20endpoint.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId-1162719409%22%20id%3D%22toc-hId-1162719409%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId--644735054%22%20id%3D%22toc-hId--644735054%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ECOVID%20dataset%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20this%20sample%20is%20used%20the%20latest%20available%20public%20data%20on%20COVID-19%20cases%20worldwide%20from%20the%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%3EEuropean%20Center%20for%20Disease%20Prevention%20and%20Control%20(ECDC)%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20Each%20row%2Fentry%20contains%20the%20number%20of%20new%20cases%20reported%20per%20day%20and%20per%20country.%20For%20more%20information%20about%20this%20dataset%2C%20see%E2%80%AF%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3Ehere%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20Dataset%20is%20updated%20on%20daily%20basis%20and%20placed%20as%20a%20part%20of%E2%80%AF%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3EAzure%20Open%20Dataset%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId-1842777779%22%20id%3D%22toc-hId-1842777779%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EOPENROWSET%20function%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESynapse%20SQL%20endpoint%20in%20Synapse%20Analytics%20enables%20you%20to%20use%E2%80%AF%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3EOPENROWSET%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AFT-SQL%20function%20to%20analyze%20data%20on%20Azure%20Data%20Lake%20storage.%20This%20is%20easy%20to%20use%20function%20where%20you%20need%20to%20provide%20URL%20of%20some%20publicly%20available%20file%20on%20Azure%20storage%20and%20you%20will%20get%20the%20content%20of%20the%20file.%20Example%20of%E2%80%AF%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3EOPENROWSET%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AFfunction%20that%20reads%20the%20content%20of%20a%20parquet%20file%20placed%20on%20Azure%20storage%20is%20shown%20in%20the%20following%20example%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Eselect%20*%26nbsp%3B%0Afrom%26nbsp%3Bopenrowset(bulk%20'https%3A%2F%2F****.blob.core.windows.net%2F...%2Fcases.parquet'%2C%26nbsp%3B%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20format%3D'parquet')%20as%20cases%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIf%20you%20provide%20a%20file%20URL%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(for%20example%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-ERR%3AREF-NOT-FOUND-%3CA%20href%3D%22https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet%3C%2FA%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E)%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eafter%20the%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSTRONG%3EBULK%3C%2FSTRONG%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ekeyword%20and%20specify%20that%20you%20are%20using%20parquet%20format%2C%20you%20will%20get%20the%20content%20of%20file.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThis%20file%20is%20publicly%20available%2C%20so%20you%20don%E2%80%99t%20need%20some%20credential%20to%20read%20the%20content%20of%20the%20file.%20If%20the%20file%20is%20protected%20using%20Azure%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAD%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eauthentication%20or%20SAS%20token%2C%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efollow%20the%20instructions%20in%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql%2Fdevelop-storage-files-storage-access-control%3Ftabs%3Duser-identity%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%3Ethis%20article%3C%2FSPAN%3E%3C%2FA%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20setup%20permissions.%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId-35323316%22%20id%3D%22toc-hId-35323316%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ESimple%20linear%20regression%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ELinear%20regression%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Esimple%2C%20yet%20effective%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Epredi%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ection%20model%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bused%20to%20estimate%20the%20value%20of%20variable%20Y%20based%20on%20the%20known%20value%20of%20variable%20X%20under%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eassumption%20that%20there%20is%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Ba%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blinear%20dependency%20between%20them.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20f%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eormula%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bfor%20simple%20linear%20regression%20is%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EY%20%3D%20a%26nbsp%3B%2B%20b*X%26nbsp%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMathematically%2C%20we%20say%20that%20Y%20is%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3Eproportional%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%26nbsp%3BX%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AF%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3BThere%20is%20another%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Evalue%20called%20R%20factor%20that%20describes%20how%20reliable%20is%20the%20model.%20The%20models%20with%20low%20R%20factor%20are%20not%20reliable.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESynapse%20SQL%20can%20easily%20determine%20the%20coefficients%20of%20linear%20regression%20model%20based%20on%20a%20set%20of%20(X%2C%20Y)%20values%20that%20you%20select%20from%20some%20file.%20If%20we%20use%20the%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3Esimple%20linear%20regressio%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3En%20sample%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthat%20Phil%20Factor%20described%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bin%20his%20article%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20we%20need%20to%20create%20a%20query%20that%20selects%20some%20values%20X%20and%20Y%20using%20some%20SQL%20query%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%20put%20it%20in%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethe%20%3CSTRONG%3Edata%3C%2FSTRONG%3E%20part%20of%20the%20following%20query%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Ewith%E2%80%AFdata%E2%80%AFas%E2%80%AF(%26nbsp%3B%0A---%20insert%20query%20here%3A%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFselect%E2%80%AFx%E2%80%AF%3D%E2%80%AF%2C%E2%80%AFy%E2%80%AF%3D%E2%80%AF%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFfrom%E2%80%AF......%26nbsp%3B%0A---%20end%20of%20query%26nbsp%3B%0A)%26nbsp%3B%0A%E2%80%AFSELECT%E2%80%AF%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((Sy%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSxy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AF((N%E2%80%AF*%E2%80%AF(Sxx))%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%E2%80%AFAS%E2%80%AFa%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((N%E2%80%AF*%E2%80%AFSxy)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AF((N%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%E2%80%AFAS%E2%80%AFb%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((N%E2%80%AF*%E2%80%AFSxy)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AFSQRT(%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF(((N%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF*%E2%80%AF((N%E2%80%AF*%E2%80%AFSyy%E2%80%AF-%E2%80%AF(Sy%E2%80%AF*%E2%80%AFSy)))))%E2%80%AFAS%E2%80%AFr%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFFROM%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF(%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSELECT%E2%80%AFSUM(data.x)%E2%80%AFAS%E2%80%AFSx%2C%E2%80%AFSUM(data.y)%E2%80%AFAS%E2%80%AFSy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.x%E2%80%AF*%E2%80%AFdata.x)%E2%80%AFAS%E2%80%AFSxx%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.x%E2%80%AF*%E2%80%AFdata.y)%E2%80%AFAS%E2%80%AFSxy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.y%E2%80%AF*%E2%80%AFdata.y)%E2%80%AFAS%E2%80%AFSyy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFCOUNT(*)%E2%80%AFAS%E2%80%AFN%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFFROM%E2%80%AFdata%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF)%E2%80%AFsums%3B%26nbsp%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20query%20in%20%3CSTRONG%3Edata%3C%2FSTRONG%3E%20part%20will%20provide%20the%20result%20set%20that%20will%20be%20used%20for%20linear%20regression%20analysis%20and%20the%20rest%20of%20the%20query%20will%20return%20a%2C%20b%2C%20and%20r%20parameters%20of%20the%20linear%20regression%20model%20applied%20on%20that%20result%20set.%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%20data-contrast%3D%22auto%22%3EYou%20can%20find%20more%20info%20about%20this%20query%20in%26nbsp%3B%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3Ethis%20article%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3EThe%20important%20thing%20that%20you%20need%20to%20notice%20here%20is%20that%20this%20is%26nbsp%3Blinear%26nbsp%3Bregression%20model%20is%20not%20created%20on%20client%20side.%20This%20query%20can%20be%20executed%20on%20large%20dataset%20and%20build%26nbsp%3Bprediction%20model%20based%20on%20large%20number%20of%20records%20without%20transferring%20data%20to%20the%20client%20side.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId--1772131147%22%20id%3D%22toc-hId--1772131147%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId-715381686%22%20id%3D%22toc-hId-715381686%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EApplying%20linear%20regression%20on%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E%26nbsp%3BCOVID%20dataset%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ENow%20it%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bis%20time%20to%20use%20SQL%20endpoint%20to%20perform%20linear%20regression%20on%20the%20COVID%20dataset.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EProbably%20the%20easiest%20tool%20that%20you%20can%20use%20to%20analyze%20file%20in%E2%80%AF%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3ESynapse%20Studio%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%E2%80%AF%E2%80%93%20Web%20UI%20where%20you%20can%20write%20a%20T-SQL%20query%20and%20see%20results%20in%20browser.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20can%20begin%20analysis%20by%20exploring%20the%20columns%20in%20dataset%20on%20first%2010%20records%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_0-1592329979971.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199062iD5F2DB5F5B180414%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_0-1592329979971.png%22%20alt%3D%22JovanPop_0-1592329979971.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIn%20this%20set%20we%20can%20see%20that%20we%20are%20getting%20new%20daily%20entries%20for%20the%20reported%20COVID%20cases%20in%20each%20country.%3C%2FSPAN%3E%26nbsp%3B%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20interesting%20columns%20are%20number%20of%20new%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ecases%20(cases)%2C%20number%20of%20fatal%20cases%20(deaths)%2C%20id%20of%20the%20country%20(geo_id)%2C%20and%20the%20population%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eof%20the%20country%20recorded%202018%20(%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3Epop%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E_%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3Edata%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E_2018%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E).%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ELet%E2%80%99s%20test%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ea%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehypothesis%20that%20number%20of%20fatal%20cases%20(deaths)%20is%20proportional%20to%20the%20number%20of%20total%20cases.%20First%20let%E2%80%99s%20get%20the%20number%20of%20total%20and%20fatal%20cases%20per%20each%20country%20using%20the%20following%20query%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Eselect%E2%80%AFgeo_id%2C%E2%80%AFcases%E2%80%AF%3D%E2%80%AFsum(CASES)%2C%E2%80%AFdeaths%E2%80%AF%3D%E2%80%AFsum(DEATHS)%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFfrom%E2%80%AFopenrowset(bulk%E2%80%AF'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFformat%3D'parquet')%E2%80%AFas%E2%80%AFa%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFgroup%E2%80%AFby%E2%80%AFgeo_id%26nbsp%3B%0Aorder%E2%80%AFby%E2%80%AFcases%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EIf%20we%20browse%20the%20results%20of%20this%20query%20using%20Synapse%20Studio%2C%20we%20will%20see%20that%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewe%20have%20many%20countries%20with%20small%20number%20of%20cases%20and%20some%20countries%20with%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Emany%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bfatal%20cases.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_1-1592329979963.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F199061i14C75DB41639D90E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_1-1592329979963.png%22%20alt%3D%22JovanPop_1-1592329979963.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3EThere%20are%20some%20countries%20that%20avoided%20pandemic%20with%20small%20number%20of%20cases%20and%20other%20big%20countries%20where%20pandemic%20escalated%20like%20in%20USA%2C%20Brazil%2C%20Italy%2C%20and%20Spain.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3ETherefore%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3E%26nbsp%3Bwe%20will%20exclude%20countries%20with%20less%20than%20100%20cases%20and%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3Efocus%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3Eo%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3En%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthe%20mid-size%20countries%20with%20the%20population%20between%2050%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3EK%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%2011%20million.%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3BWe%20can%20easily%20add%20this%20filter%20condition%20in%20the%20%3CSTRONG%3Ehaving%3C%2FSTRONG%3E%20clause%20of%20the%20query%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Eselect%E2%80%AFgeo_id%2C%E2%80%AFcases%E2%80%AF%3D%E2%80%AFsum(CASES)%2C%E2%80%AFdeaths%E2%80%AF%3D%E2%80%AFsum(DEATHS)%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFfrom%E2%80%AFopenrowset(bulk%E2%80%AF'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFformat%3D'parquet')%E2%80%AFas%E2%80%AFa%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFgroup%E2%80%AFby%E2%80%AFgeo_id%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFhaving%E2%80%AFAVG(CAST(POP_DATA_2018%E2%80%AFAS%E2%80%AFBIGINT))%E2%80%AFbetween%E2%80%AF50000%E2%80%AFand%E2%80%AF11000000%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFAND%E2%80%AFsum(CASES)%E2%80%AF%26gt%3B%E2%80%AF100%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFand%E2%80%AFsum(DEATHS)%E2%80%AF%26gt%3B%E2%80%AF100%26nbsp%3B%0Aorder%E2%80%AFby%E2%80%AFcases%3B%26nbsp%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ENow%20it%20is%20time%20to%20add%20the%20result%20of%20this%20query%20into%20the%20linear%20regression%20query%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20We%20will%20rename%20the%20columns%20to%20X%20and%20Y%2C%20cast%20them%20to%20%3CSTRONG%3Efloat%3C%2FSTRONG%3E%20to%20avoid%20arithmetic%20overflow%2C%20remove%20%3CSTRONG%3Eorder%20by%3C%2FSTRONG%3E%20clause%20because%20it%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eunnecessary%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%20run%20the%20following%20query%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Ewith%E2%80%AF%E2%80%AFdata%E2%80%AFas%E2%80%AF(%26nbsp%3B%0A---%20insert%20query%20here%3A%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFselect%E2%80%AFx%E2%80%AF%3D%E2%80%AFCAST(sum(CASES)%E2%80%AFAS%E2%80%AFFLOAT)%2C%E2%80%AFy%E2%80%AF%3D%E2%80%AFCAST(sum(DEATHS)%E2%80%AFAS%E2%80%AFFLOAT)%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFfrom%E2%80%AFopenrowset(bulk%E2%80%AF'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFformat%3D'parquet')%E2%80%AFas%E2%80%AFa%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFgroup%E2%80%AFby%E2%80%AFgeo_id%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFhaving%E2%80%AFAVG(CAST(POP_DATA_2018%E2%80%AFAS%E2%80%AFBIGINT))%E2%80%AFbetween%E2%80%AF50000%E2%80%AFand%E2%80%AF11000000%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFAND%E2%80%AFsum(CASES)%E2%80%AF%26gt%3B%E2%80%AF100%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFand%E2%80%AFsum(DEATHS)%E2%80%AF%26gt%3B%E2%80%AF100%26nbsp%3B%0A---%20end%20of%20query%26nbsp%3B%0A)%26nbsp%3B%0A%E2%80%AFSELECT%E2%80%AF%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((Sy%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSxy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AF((N%E2%80%AF*%E2%80%AF(Sxx))%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%E2%80%AFAS%E2%80%AFa%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((N%E2%80%AF*%E2%80%AFSxy)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AF((N%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%E2%80%AFAS%E2%80%AFb%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF((N%E2%80%AF*%E2%80%AFSxy)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSy))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%2F%E2%80%AFSQRT(%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF(((N%E2%80%AF*%E2%80%AFSxx)%E2%80%AF-%E2%80%AF(Sx%E2%80%AF*%E2%80%AFSx))%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF*%E2%80%AF((N%E2%80%AF*%E2%80%AFSyy%E2%80%AF-%E2%80%AF(Sy%E2%80%AF*%E2%80%AFSy)))))%E2%80%AFAS%E2%80%AFr%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFFROM%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF(%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSELECT%E2%80%AFSUM(data.x)%E2%80%AFAS%E2%80%AFSx%2C%E2%80%AFSUM(data.y)%E2%80%AFAS%E2%80%AFSy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.x%E2%80%AF*%E2%80%AFdata.x)%E2%80%AFAS%E2%80%AFSxx%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.x%E2%80%AF*%E2%80%AFdata.y)%E2%80%AFAS%E2%80%AFSxy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFSUM(data.y%E2%80%AF*%E2%80%AFdata.y)%E2%80%AFAS%E2%80%AFSyy%2C%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFCOUNT(*)%E2%80%AFAS%E2%80%AFN%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AFFROM%E2%80%AFdata%26nbsp%3B%0A%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF%E2%80%AF)%E2%80%AFsums%3B%26nbsp%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20result%20of%20this%20query%20will%20give%20us%20A%20and%20B%20parameters%20of%20the%20linear%20regression%20model%20that%20estimates%20mortality%20rate%20of%20COVID%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CTABLE%20data-tablestyle%3D%22MsoTableGrid%22%20data-tablelook%3D%221184%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EA%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EB%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ER%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E-24.7405767572961%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E0.0356209053608031%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3CTD%20data-celllook%3D%220%22%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E0.57349202459482%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EUsing%20these%20parameters%2C%20we%20might%20assume%20that%20the%20following%20formula%20will%20estimate%20number%20of%20fatal%20cases%3A%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3Edeaths%20%3D%200.0356209053608031%20*%20cases%20-24.7405767572961%26nbsp%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20might%20conclude%20that%20around%203.6%25%20of%20total%20cases%20is%20fatal%2C%20but%20by%20looking%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eat%20the%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BR%20factor%20of%20this%20model%200.57349202459482%20we%20can%20see%20that%20this%20is%20not%20reliable%20estimate.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E%26nbsp%3BIn%20this%20case%2C%20we%20can%20conclude%20moderate%20correlation%20between%20number%20of%20total%20cases%20and%20number%20of%20fatal%20cases%20in%20this%20dataset.%20For%20more%20reliable%20analysis%2C%20a%20larger%20data%20sample%20is%20needed.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EHowever%2C%20the%20approach%20used%20in%20this%20example%20shows%20how%20to%20apply%20linear%20regression%20model%20on%20any%20other%20dataset.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20aria-level%3D%222%22%20id%3D%22toc-hId--1092072777%22%20id%3D%22toc-hId--1092072777%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EConclusion%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESynapse%20SQL%20endpoint%20and%20Synapse%20Studio%20in%20Azure%20Synapse%20Analytics%20are%20tools%20for%20easy%20data%20exploration%20that%20enable%20you%20to%20easily%20read%20the%20content%20of%20a%20file%20and%20do%20basic%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edata%20prediction%20on%20very%20large%20datasets%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20In%20this%20example%2C%20we%20have%20seen%20how%20to%20leverage%20T-SQL%20language%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eto%20create%20simple%20linear%20regression%20model%20on%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ECOVID%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edataset%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAlthough%20the%20model%20created%20on%20the%20dataset%20is%20not%20reliable%20enough%2C%20we%20have%20seen%20the%20approach%20that%20you%20can%20use%20to%20create%20your%20own%20simple%20linear%20regression%20models%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eon%20any%20other%20dataset.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EYou%20can%20find%20more%20information%20about%20querying%20files%20in%20Azure%20Data%20Lakes%20Storage%20in%20this%E2%80%AF%3C%2FSPAN%3E-ERR%3AREF-NOT-FOUND-%3CSPAN%20data-contrast%3D%22none%22%3Earticle%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1468697%22%20slang%3D%22en-US%22%3E%3CP%3ESQL%20endpoint%20in%20Azure%20Synapse%20Analytics%20enables%20you%20to%20use%20T-SQL%20language%20to%20analyze%20your%20data%20in%20Data%20Lake%20storage.%20TSQL%20language%20enables%20you%20to%20implement%20some%20prediction%20models%20such%20as%20linear%20regression%20models%20to%20predict%20the%20values.%20In%20this%20sample%20you%20will%20see%20hot%20to%20estimate%20number%20of%20fatal%20cases%20of%20COVID%20using%20linear%20regression%20model%20implemented%20in%20synapse%20SQL%20endpoint.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1468697%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20Studio%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Azure Synapse Analytics is a big data analytics service that enables you to analyze data on Azure storage using SQL languageYou can use SQL endpoints (provisioned and serverlessto analyze your data using SQL language. 

SQL is very powerful analytic language that can be used to implement performant analysis on big data. As an example, you can write a SQL query that creates a linear regression model on your datasets. Phil Factor described how to implement simple linear regression using SQL language. 

In this article, you will see how you can create simple linear regression model to determine COVID mortality rate using Azure Open Dataset and Synapse SQL endpoint in Synapse Analytics. 

 

Prerequisite 

To try this sample, you need to have Azure Synapse Analytics workspace. If you don’t have one you can easily deploy it using Azure portal or this Deployment template. Synapse workspace automatically deploys one serverless Synapse SQL endpoint that is everything we need for this kind of analysis. With the workspace you are also getting easy-to-use web UI called Synapse Studio that enables you to start analyzing files in your browser. 

 

NOTE: You need Synapse SQL serverless (on-demand) query endpoint to execute the code in this article. The functionalities used in this article are still not available in provisioned  endpoint.

 

COVID dataset 

In this sample is used the latest available public data on COVID-19 cases worldwide from the European Center for Disease Prevention and Control (ECDC). Each row/entry contains the number of new cases reported per day and per country. For more information about this dataset, see  here. Dataset is updated on daily basis and placed as a part of Azure Open Dataset. 

 

OPENROWSET function 

Synapse SQL endpoint in Synapse Analytics enables you to use OPENROWSET T-SQL function to analyze data on Azure Data Lake storage. This is easy to use function where you need to provide URL of some publicly available file on Azure storage and you will get the content of the file. Example of OPENROWSET function that reads the content of a parquet file placed on Azure storage is shown in the following example: 

 

select * 
from openrowset(bulk 'https://****.blob.core.windows.net/.../cases.parquet', 
                format='parquet') as cases

 

 If you provide a file URL  (for example https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases....after the BULK keyword and specify that you are using parquet format, you will get the content of file.

This file is publicly available, so you don’t need some credential to read the content of the file. If the file is protected using Azure AD authentication or SAS token, follow the instructions in this article to setup permissions.  

 

Simple linear regression 

Linear regression is simple, yet effective prediction model used to estimate the value of variable Y based on the known value of variable X under the assumption that there is a linear dependency between them. The formula for simple linear regression is: 

 

Y = a + b*X 

 

Mathematically, we say that Y is proportional to X. There is another value called R factor that describes how reliable is the model. The models with low R factor are not reliable. 

Synapse SQL can easily determine the coefficients of linear regression model based on a set of (X, Y) values that you select from some file. If we use the simple linear regression sample that Phil Factor described in his article, we need to create a query that selects some values X and Y using some SQL query and put it into the data part of the following query: 

 

with data as ( 
--- insert query here: 
    select x = , y =  
    from ...... 
--- end of query 
) 
 SELECT  
    ((Sy * Sxx) - (Sx * Sxy)) 
    / ((N * (Sxx)) - (Sx * Sx)) AS a, 
    ((N * Sxy) - (Sx * Sy)) 
    / ((N * Sxx) - (Sx * Sx)) AS b, 
    ((N * Sxy) - (Sx * Sy)) 
    / SQRT( 
        (((N * Sxx) - (Sx * Sx)) 
         * ((N * Syy - (Sy * Sy))))) AS r 
    FROM 
      ( 
      SELECT SUM(data.x) AS Sx, SUM(data.y) AS Sy, 
        SUM(data.x * data.x) AS Sxx, 
        SUM(data.x * data.y) AS Sxy, 
        SUM(data.y * data.y) AS Syy, 
        COUNT(*) AS N 
        FROM data 
      ) sums; 

 

The query in data part will provide the result set that will be used for linear regression analysis and the rest of the query will return a, b, and r parameters of the linear regression model applied on that result set. You can find more info about this query in this article. 

 

The important thing that you need to notice here is that this is linear regression model is not created on client side. This query can be executed on large dataset and build prediction model based on large number of records without transferring data to the client side. 

 

Applying linear regression on COVID dataset 

Now it is time to use SQL endpoint to perform linear regression on the COVID dataset. Probably the easiest tool that you can use to analyze file in Synapse Studio – Web UI where you can write a T-SQL query and see results in browser. 

We can begin analysis by exploring the columns in dataset on first 10 records: 

JovanPop_0-1592329979971.png

In this set we can see that we are getting new daily entries for the reported COVID cases in each country. The interesting columns are number of new cases (cases), number of fatal cases (deaths), id of the country (geo_id), and the population of the country recorded 2018 (pop_data_2018). 

 

Let’s test hypothesis that number of fatal cases (deaths) is proportional to the number of total cases. First let’s get the number of total and fatal cases per each country using the following query: 

 

select geo_id, cases = sum(CASES), deaths = sum(DEATHS) 
    from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet', 
                format='parquet') as a 
    group by geo_id 
order by cases;

 

If we browse the results of this query using Synapse Studio, we will see that we have many countries with small number of cases and some countries with many fatal cases.  

JovanPop_1-1592329979963.png

There are some countries that avoided pandemic with small number of cases and other big countries where pandemic escalated like in USA, Brazil, Italy, and Spain. Therefore, we will exclude countries with less than 100 cases and focus on the mid-size countries with the population between 50K and 11 million.  We can easily add this filter condition in the having clause of the query:

 

select geo_id, cases = sum(CASES), deaths = sum(DEATHS) 
    from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet', 
                format='parquet') as a 
    group by geo_id 
    having AVG(CAST(POP_DATA_2018 AS BIGINT)) between 50000 and 11000000 
    AND sum(CASES) > 100 
    and sum(DEATHS) > 100 
order by cases; 

 

Now it is time to add the result of this query into the linear regression query. We will rename the columns to X and Y, cast them to float to avoid arithmetic overflow, remove order by clause because it is unnecessary and run the following query: 

 

with  data as ( 
--- insert query here: 
    select x = CAST(sum(CASES) AS FLOAT), y = CAST(sum(DEATHS) AS FLOAT) 
    from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet', 
                format='parquet') as a 
    group by geo_id 
    having AVG(CAST(POP_DATA_2018 AS BIGINT)) between 50000 and 11000000 
    AND sum(CASES) > 100 
    and sum(DEATHS) > 100 
--- end of query 
) 
 SELECT  
    ((Sy * Sxx) - (Sx * Sxy)) 
    / ((N * (Sxx)) - (Sx * Sx)) AS a, 
    ((N * Sxy) - (Sx * Sy)) 
    / ((N * Sxx) - (Sx * Sx)) AS b, 
    ((N * Sxy) - (Sx * Sy)) 
    / SQRT( 
        (((N * Sxx) - (Sx * Sx)) 
         * ((N * Syy - (Sy * Sy))))) AS r 
    FROM 
      ( 
      SELECT SUM(data.x) AS Sx, SUM(data.y) AS Sy, 
        SUM(data.x * data.x) AS Sxx, 
        SUM(data.x * data.y) AS Sxy, 
        SUM(data.y * data.y) AS Syy, 
        COUNT(*) AS N 
        FROM data 
      ) sums; 

 

The result of this query will give us A and B parameters of the linear regression model that estimates mortality rate of COVID: 

A 

B 

R 

-24.7405767572961 

0.0356209053608031 

0.57349202459482 

 Using these parameters, we might assume that the following formula will estimate number of fatal cases: 

 

deaths = 0.0356209053608031 * cases -24.7405767572961 

 

We might conclude that around 3.6% of total cases is fatal, but by looking at the R factor of this model 0.57349202459482 we can see that this is not reliable estimate.  In this case, we can conclude moderate correlation between number of total cases and number of fatal cases in this dataset. For more reliable analysis, a larger data sample is needed. 

However, the approach used in this example shows how to apply linear regression model on any other dataset. 

 

Conclusion 

Synapse SQL endpoint and Synapse Studio in Azure Synapse Analytics are tools for easy data exploration that enable you to easily read the content of a file and do basic data prediction on very large datasets. In this example, we have seen how to leverage T-SQL language to create simple linear regression model on a COVID datasetAlthough the model created on the dataset is not reliable enough, we have seen the approach that you can use to create your own simple linear regression models on any other dataset. 

You can find more information about querying files in Azure Data Lakes Storage in this article.