%3CLINGO-SUB%20id%3D%22lingo-sub-1323238%22%20slang%3D%22en-US%22%3ERunning%20ML.NET%20%2B%20Notebooks%20in%20Azure%20Machine%20Learning%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1323238%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20size%3D%227%22%3ETime%20Series%20Forecasting%20in%20ML.NET%20and%20Notebooks%20in%20Azure%20ML%20Studio%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EIn%20this%20sample%2C%20learn%20how%20to%20run%20time%20series%20forecasting%20in%20a%20Jupyter%20notebook.%20We%20will%20read%20in%20data%20from%20a%20csv%20file%2C%20do%20some%20exploratory%20plots%2C%20fit%20a%20regression%20model%2C%20and%20fit%20a%20more%20sophisticated%20Singular%20Spectrum%20Analysis%20(SSA)%20forecaster.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22toc-hId-439776785%22%20id%3D%22toc-hId-439776785%22%3EDownload%20the%20source%20code%3C%2FH1%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Ftimeseries-mlnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAccess%20the%20GitHub%20repo%3C%2FA%3E%20and%20copy%20the%20%E2%80%9Cclone%E2%80%9D%20link%20in%20order%20to%20run%20this%20tutorial%20on%20your%20own%20machine.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1130338259%22%20id%3D%22toc-hId-1130338259%22%3EPrerequisites%3C%2FH2%3E%0A%3CH3%20id%3D%22toc-hId-1820899733%22%20id%3D%22toc-hId-1820899733%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-13445270%22%20id%3D%22toc-hId-13445270%22%3EInstall%20C%23%20Kernel%3C%2FH3%3E%0A%3CP%3ENote%3A%20These%20instructions%20only%20apply%20if%20you%20intend%20to%20run%20this%20notebook%20in%20Azure%20Machine%20Learning.%20You%20can%20also%20run%20this%20notebook%20on%20your%20local%20machine%20by%20following%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Finteractive%23how-to-install-net-interactive%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethe%20instructions%20at%20the%20dotnet%20interactive%20GitHub%20repo%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EGo%20to%20ml.azure.com.%20Select%20your%20subscription%20and%20machine%20learning%20workspace.%3C%2FLI%3E%0A%3CLI%3EOpen%20up%20the%20%22Notebooks%22%20tab%20on%20the%20lefthand%20side%20of%20the%20page%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20compute%20instance%20if%20you%20have%20not%20already%2C%20or%20select%20an%20existing%20one%20from%20the%20dropdown%20menu.%3C%2FLI%3E%0A%3CLI%3EOpen%20a%20notebook%20file%20with%20an%20extension%20of%20.ipynb%3C%2FLI%3E%0A%3CLI%3ESelect%20the%20Terminal%20button%20at%20the%20top%20right.%3C%2FLI%3E%0A%3CLI%3EFollow%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fcore%2Finstall%2Flinux-package-manager-ubuntu-1604%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethe%20instructions%20here%3C%2FA%3E%20to%20register%20a%20Microsoft%20product%20key%20and%20install%20.NET%20Core%203.1.%3C%2FLI%3E%0A%3CLI%3EInstall%20dotnet%20interactive%20by%20running%20dotnet%20tool%20install%20-g%20--add-source%20%22%3CA%20href%3D%22https%3A%2F%2Fdotnet.myget.org%2FF%2Fdotnet-try%2Fapi%2Fv3%2Findex.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdotnet.myget.org%2FF%2Fdotnet-try%2Fapi%2Fv3%2Findex.json%3C%2FA%3E%22%20dotnet-interactive%3C%2FLI%3E%0A%3CLI%3ECreate%20a%20symlink%20between%20the%20installed%20location%20of%20dotnet%20interactive%20and%20your%20local%20bin%20directory%3A%20sudo%20ln%20-s%20%2Fhome%2Fazureuser%2F.dotnet%2Ftools%2Fdotnet-interactive%20%2Fusr%2Flocal%2Fbin%2Fdotnet-interactive%3C%2FLI%3E%0A%3CLI%3ESet%20your%20dotnet%20root%20directory%3A%20export%20DOTNET_ROOT%3D%24(dirname%20%24(realpath%20%24(which%20dotnet)))%3C%2FLI%3E%0A%3CLI%3EInstall%20the%20jupyter%20kernel%3A%20dotnet%20interactive%20jupyter%20install%3C%2FLI%3E%0A%3CLI%3EVerify%20the%20installation%20by%20running%20jupyter%20kernelspec%20list.%20You%20should%20see%20%22.net-fsharp%22%20and%20%22.net-csharp%22%20listed%20as%20kernels.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CH3%20id%3D%22toc-hId--1794009193%22%20id%3D%22toc-hId--1794009193%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-693503640%22%20id%3D%22toc-hId-693503640%22%3EInstall%20Mkl%20on%20Ubuntu%20Linux%3C%2FH3%3E%0A%3CP%3EIf%20you%20are%20running%20ML.NET%20for%20the%20first%20time%20on%20an%20Ubuntu%20Linux%20machine%20(like%20Azure%20Machine%20Learning%20notebooks)%2C%20please%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fdotnet%2Fmachine-learning%2Fhow-to-guides%2Finstall-extra-dependencies%23linux%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Efollow%20these%20instructions%3C%2FA%3E%20to%20download%20the%20required%20dependencies.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-683000536%22%20id%3D%22toc-hId-683000536%22%3EStart%20visualizing%20data%3C%2FH2%3E%0A%3CP%3EGreat!%20We%E2%80%99re%20now%20set%20up%20to%20run%20ML.NET%20in%20Azure%20ML%20Integrated%20Notebooks.%20Let%E2%80%99s%20begin%20by%20visualizing%20our%20data%2C%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Finteractive%2Fblob%2Fmaster%2FNotebookExamples%2Fcsharp%2FDocs%2FPlotting%2520with%2520Xplot.ipynb%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eusing%20the%20XPlot%20library.%3C%2FA%3E%20Notice%20how%20the%20data%20display%20a%20sinusoidal%20pattern%2C%20but%20there%E2%80%99s%20also%20a%20good%20amount%20of%20noise.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_6%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_7%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22original-series.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%2F185501iEFB38E965B9C2648%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22original-series.png%22%20alt%3D%22original-series.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1124453927%22%20id%3D%22toc-hId--1124453927%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1363058906%22%20id%3D%22toc-hId-1363058906%22%3ECompute%20an%20engineered%20feature%3C%2FH2%3E%0A%3CP%3EAs%20we%20mentioned%2C%20the%20data%20display%20a%20sinusoidal%20pattern%2C%20so%20let%E2%80%99s%20use%20that%20intuition%20to%20fit%20a%20regression%20model%20with%20an%20engineered%20feature.%20Specifically%2C%20let%E2%80%99s%20fit%20a%20model%20using%20a%20cosine%20function%20as%20our%20independent%20variable.%20Below%2C%20consider%20how%20well%20a%20cosine%20model%20can%20mimic%20the%20periodicity%20of%20our%20original%20model.%20The%20only%20things%20that%20are%20wrong%20are%20the%20distance%20between%20crests%20and%20troughs%20of%20each%20wave%20(the%20%E2%80%9Camplitude%E2%80%9D)%20and%20the%20y-intercept%20of%20the%20wave.%20Luckily%2C%20linear%20regression%20can%20give%20us%20these%20values.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22original-series-cosine.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%2F185502i8BE2D786BC3C80CA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22original-series-cosine.png%22%20alt%3D%22original-series-cosine.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--444395557%22%20id%3D%22toc-hId--444395557%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--578080281%22%20id%3D%22toc-hId--578080281%22%3EFit%20a%20linear%20regression%20model%3C%2FH2%3E%0A%3CP%3ELet%E2%80%99s%20try%20fitting%20a%20model%20using%20our%20engineered%20features%20from%20the%20previous%20step.%20Because%20the%20input%20data%20are%20so%20nicely%20sinusoidal%2C%20this%20model%20actually%20works%20quite%20well.%20It%20has%20a%20Mean%20Absolute%20Error%20(MAE)%20of%201.997%20and%20a%20Root%20Mean%20Squared%20Error%20(RMSE)%20of%202.574.%20Let%E2%80%99s%20see%20if%20we%20can%20do%20better.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22series-with-regression.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%2F185503i39E2C80046F050C8%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22series-with-regression.png%22%20alt%3D%22series-with-regression.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1909432552%22%20id%3D%22toc-hId-1909432552%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-101978089%22%20id%3D%22toc-hId-101978089%22%3EUse%20ML.NET%E2%80%99s%20SSA%20Forecasting%20Transformer%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fmicrosoft.ml.timeseriescatalog.forecastbyssa%3Fview%3Dml-dotnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EML.NET%E2%80%99s%20SSAForecastingTransformer%3C%2FA%3E%20can%20fit%20a%20forecasting%20model%20on%20our%20original%20data%2C%20without%20our%20having%20to%20provide%20it%20with%20engineered%20features.%20Most%20of%20the%20required%20parameters%20are%20based%20on%20the%20amount%20of%20data%20you%20have%20and%20the%20amount%20of%20time%20in%20the%20future%20you%20expect%20to%20predict.%20The%20only%20tricky%20one%20is%20the%20%E2%80%9CwindowSize%E2%80%9D%20parameter%2C%20which%20should%20be%20set%20to%20be%20twice%20the%20length%20of%20the%20maximum%20expected%20seasonality%20in%20the%20data.%20For%20example%2C%20if%20you%20have%20data%20that%20is%20collected%20once%20per%20day%20in%20an%20environment%20that%20shows%20both%20monthly%20and%20yearly%20seasonality%2C%20you%20should%20set%20windowSize%20to%20be%20twice%20the%20length%20of%20the%20year%2C%20or%20730.%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Ftimeseries-mlnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESee%20the%20example%20notebook%3C%2FA%3E%20for%20more%20details%20on%20the%20other%20parameters.%3C%2FP%3E%0A%3CP%3ENotice%20that%20the%20SSA%20Forecasting%20Transformer%20gives%20us%20not%20only%20a%20lower%20MAE%20and%20RMSE%20of%201.963%20and%202.491%2C%20respectively%2C%20but%20also%20gives%20us%2095%25%20confidence%20bounds.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22train-ssa.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%2F185504iD429B7354616E574%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22train-ssa.png%22%20alt%3D%22train-ssa.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1705476374%22%20id%3D%22toc-hId--1705476374%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-782036459%22%20id%3D%22toc-hId-782036459%22%3EPredict%20future%20values%3C%2FH2%3E%0A%3CP%3ESo%20we%E2%80%99ve%20found%20our%20model%20of%20interest%2C%20now%20let%E2%80%99s%20use%20it%20to%20predict%20the%20future!%20We%20can%20simply%20retrain%20the%20model%20on%20all%20of%20the%20data%2C%20and%20then%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fdotnet%2Fapi%2Fmicrosoft.ml.transforms.timeseries.predictionfunctionextensions.createtimeseriesengine%3Fview%3Dml-dotnet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECreateTimeSeriesEngine%3C%2FA%3E%20to%20get%20a%20predictor%2C%20and%20then%20call%20Predict()%20to%20predict%20points%20up%20to%20the%20horizon%20we%20specified%20during%20training.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorgopalv_5%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22predict-ssa.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%2F185505i96B685C197AC1AD2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22predict-ssa.png%22%20alt%3D%22predict-ssa.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1025418004%22%20id%3D%22toc-hId--1025418004%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1462094829%22%20id%3D%22toc-hId-1462094829%22%3ENext%20steps%3C%2FH2%3E%0A%3CP%3EIn%20this%20notebook%2C%20you%20learned%20how%20to%20do%20time%20series%20forecasting%20in%20ML.NET%20with%20Jupyter%20notebooks.%20We%20initially%20used%20linear%20regression%20with%20an%20engineered%20feature%2C%20but%20we%20were%20able%20to%20improve%20performance%20by%20relying%20on%20ML.NET's%20SSA%20forecaster.%3C%2FP%3E%0A%3CP%3ETo%20learn%20more%20about%20C%23%20and%20Jupyter%20Notebooks%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdotnet%2Finteractive%23how-to-install-net-interactive%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echeck%20out%20this%20GitHub%20repo%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3ETo%20see%20another%20example%20of%20using%20ML.NET%20in%20Jupyter%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Fcesardelatorre%2Fusing-ml-net-in-jupyter-notebooks%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echeck%20out%20this%20blog%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3ETo%20learn%20about%20using%20DataFrames%20in%20C%23%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Fdotnet%2Fan-introduction-to-dataframe%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Echeck%20out%20this%20blog%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3ETo%20get%20started%20with%20Model%20Builder%20in%20Visual%20Studio%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdotnet.microsoft.com%2Flearn%2Fml-dotnet%2Fget-started-tutorial%2Fintro%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Etry%20this%20getting%20started%20tutorial%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1323238%22%20slang%3D%22en-US%22%3E%3CP%3EInstall%20a%20custom%20C%23%20kernel%20in%20Notebook%20in%20Azure%20Machine%20Learning%20Studio%20and%20run%20a%20time%20series%20analysis%20in%20ML.NET.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1323238%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Machine%20Learning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMachine%20Learning%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Time Series Forecasting in ML.NET and Notebooks in Azure ML Studio

In this sample, learn how to run time series forecasting in a Jupyter notebook. We will read in data from a csv file, do some exploratory plots, fit a regression model, and fit a more sophisticated Singular Spectrum Analysis (SSA) forecaster.

 

Download the source code

Access the GitHub repo and copy the “clone” link in order to run this tutorial on your own machine.

 

Prerequisites

 

Install C# Kernel

Note: These instructions only apply if you intend to run this notebook in Azure Machine Learning. You can also run this notebook on your local machine by following the instructions at the dotnet interactive GitHub repo

 

  1. Go to ml.azure.com. Select your subscription and machine learning workspace.
  2. Open up the "Notebooks" tab on the lefthand side of the page
  3. Create a compute instance if you have not already, or select an existing one from the dropdown menu.
  4. Open a notebook file with an extension of .ipynb
  5. Select the Terminal button at the top right.
  6. Follow the instructions here to register a Microsoft product key and install .NET Core 3.1.
  7. Install dotnet interactive by running dotnet tool install -g --add-source "https://dotnet.myget.org/F/dotnet-try/api/v3/index.json" dotnet-interactive
  8. Create a symlink between the installed location of dotnet interactive and your local bin directory: sudo ln -s /home/azureuser/.dotnet/tools/dotnet-interactive /usr/local/bin/dotnet-interactive
  9. Set your dotnet root directory: export DOTNET_ROOT=$(dirname $(realpath $(which dotnet)))
  10. Install the jupyter kernel: dotnet interactive jupyter install
  11. Verify the installation by running jupyter kernelspec list. You should see ".net-fsharp" and ".net-csharp" listed as kernels.

 

Install Mkl on Ubuntu Linux

If you are running ML.NET for the first time on an Ubuntu Linux machine (like Azure Machine Learning notebooks), please follow these instructions to download the required dependencies.

 

Start visualizing data

Great! We’re now set up to run ML.NET in Azure ML Integrated Notebooks. Let’s begin by visualizing our data, using the XPlot library. Notice how the data display a sinusoidal pattern, but there’s also a good amount of noise.

 
 
 

original-series.png

 

 

Compute an engineered feature

As we mentioned, the data display a sinusoidal pattern, so let’s use that intuition to fit a regression model with an engineered feature. Specifically, let’s fit a model using a cosine function as our independent variable. Below, consider how well a cosine model can mimic the periodicity of our original model. The only things that are wrong are the distance between crests and troughs of each wave (the “amplitude”) and the y-intercept of the wave. Luckily, linear regression can give us these values.

 

original-series-cosine.png

 

 

Fit a linear regression model

Let’s try fitting a model using our engineered features from the previous step. Because the input data are so nicely sinusoidal, this model actually works quite well. It has a Mean Absolute Error (MAE) of 1.997 and a Root Mean Squared Error (RMSE) of 2.574. Let’s see if we can do better.

 

series-with-regression.png

 

 

Use ML.NET’s SSA Forecasting Transformer

ML.NET’s SSAForecastingTransformer can fit a forecasting model on our original data, without our having to provide it with engineered features. Most of the required parameters are based on the amount of data you have and the amount of time in the future you expect to predict. The only tricky one is the “windowSize” parameter, which should be set to be twice the length of the maximum expected seasonality in the data. For example, if you have data that is collected once per day in an environment that shows both monthly and yearly seasonality, you should set windowSize to be twice the length of the year, or 730. See the example notebook for more details on the other parameters.

Notice that the SSA Forecasting Transformer gives us not only a lower MAE and RMSE of 1.963 and 2.491, respectively, but also gives us 95% confidence bounds.

 

train-ssa.png

 

 

Predict future values

So we’ve found our model of interest, now let’s use it to predict the future! We can simply retrain the model on all of the data, and then use CreateTimeSeriesEngine to get a predictor, and then call Predict() to predict points up to the horizon we specified during training.

 

predict-ssa.png

 

 

Next steps

In this notebook, you learned how to do time series forecasting in ML.NET with Jupyter notebooks. We initially used linear regression with an engineered feature, but we were able to improve performance by relying on ML.NET's SSA forecaster.

To learn more about C# and Jupyter Notebooks, check out this GitHub repo.

To see another example of using ML.NET in Jupyter, check out this blog.

To learn about using DataFrames in C#, check out this blog.

To get started with Model Builder in Visual Studio, try this getting started tutorial.