Monday 20 April 2020
Build more accurate forecasts with new capabilities in automated machine learning
Nilesh Acharya Senior Program Manager, Azure Machine Learning
We are excited to announce new capabilities which are apart of time-series forecasting in Azure Machine Learning service. We launched preview of forecasting in December 2018, and we have been excited with the strong customer interest. We listened to our customers and appreciate all the feedback. Your responses helped us reach this milestone. Thank you.
Building forecasts is an integral part of any business, whether it’s revenue, inventory, sales, or customer demand. Building machine learning models is time-consuming and complex with many factors to consider, such as iterating through algorithms, tuning your hyperparameters and feature engineering. These choices multiply with time series data, with additional considerations of trends, seasonality, holidays and effectively splitting training data.
Forecasting within automated machine learning (ML) now includes new capabilities that improve the accuracy and performance of our recommended models:
- New forecast function
- Rolling-origin cross validation
- Configurable Lags
- Rolling window aggregate features
- Holiday detection and featurization
Expanded forecast function
We are introducing a new way to retrieve prediction values for the forecast task type. When dealing with time series data, several distinct scenarios arise at prediction time that require more careful consideration. For example, are you able to re-train the model for each forecast? Do you have the forecast drivers for the future? How can you forecast when you have a gap in historical data? The new forecast function can handle all these scenarios.
Let’s take a closer look at common configurations of train and prediction data scenarios, when using the new forecasting function. For automated ML the forecast origin is defined as the point when the prediction of forecast values should begin. The forecast horizon is how far out the prediction should go into the future.
In many cases training and prediction do not have any gaps in time. This is the ideal because the model is trained on the freshest available data. We recommend you set your forecast this way if your prediction interval allows time to retrain, for example in more fixed data situations such as financial forecasts rate or supply chain applications using historical revenue or known order volumes.
When forecasting you may know future values ahead of time. These values act as contextual information that can greatly improve the accuracy of the forecast. For example, the price of a grocery item is known weeks in advance, which strongly influences the “sales” target variable. Another example is when you are running what-if analyses, experimenting with future values of drivers like foreign exchange rates. In these scenarios the forecast interface lets you specify forecast drivers describing time periods for which you want the forecasts (Xfuture).
If train and prediction data have a gap in time, the trained model becomes stale. For example, in high-frequency applications like IoT it is impractical to retrain the model constantly, due to high velocity of change from sensors with dependencies on other devices or external factors e.g. weather. You can provide prediction context with recent values of the target (ypast) and the drivers (Xpast) to improve the forecast. The forecast function will gracefully handle the gap, imputing values from training and prediction context where necessary.
In other scenarios, such as sales, revenue, or customer retention, you may not have contextual information available for future time periods. In these cases, the forecast function supports making zero-assumption forecasts out to a “destination” time. The forecast destination is the end point of the forecast horizon. The model maximum horizon is the number of periods the model was trained to forecast and may limit the forecast horizon length.
The forecast model enriches the input data (e.g. adds holiday features) and imputes missing values. The enriched and imputed data are returned with the forecast.
Rolling-origin cross validation
Cross-validation (CV) is a vital procedure for estimating and reducing out-of-sample error for a model. For time series data we need to ensure training only occurs using values to the past of the test data. Partitioning the data without regard to time does not match how data becomes available in production, and can lead to incorrect estimates of the forecaster’s generalization error.
To ensure correct evaluation, we added rolling-origin cross validation (ROCV) as the standard method to evaluate machine learning models on time series data. It divides the series into training and validation data using an origin time point. Sliding the origin in time generates the cross-validation folds.
As an example, when we do not use ROCV, consider a hypothetical time-series containing 40 observations. Suppose the task is to train a model that forecasts the series up-to four time-points into the future. A standard 10-fold cross validation (CV) strategy is shown in the image below. The y-axis in the image delineates the CV folds that will be made while the colors distinguish training points (blue) from validation points (orange). In the 10-fold example below, notice how folds one through nine result in model training on dates future to be included the validation set resulting inaccurate training and validation results.
This scenario should be avoided for time-series instead, when we use an ROCV strategy as shown below, we preserve the time series data integrity and eliminate the risk of data leakage.
ROCV is used automatically for forecasting. You simply pass the training and validation data together and set the number of cross validation folds. Automated machine learning (ML) will use the time column and grain columns you have defined in your experiment to split the data in a way that respects time horizons. Automated ML will also retrain the selected model on the combined train and validation set to make use of the most recent and thus most informative data, which under the rolling-origin splitting method ends up in the validation set.
Lags and rolling window aggregates
Often the best information a forecaster can have is the recent value of the target. Creating lags and cumulative statistics of the target then increases accuracy of your predictions.
In automated ML, you can now specify target lag as a model feature. Adding lag length identifies how many rows to lag based on your time interval. For example, if you wanted to lag by two units of time, you set the lag length parameter to two.
The table below illustrates how a lag length of two would be treated. Green columns are engineered features with lags of sales by one day and two day. The blue arrows indicate how each of the lags are generated by the training data. Not a number (Nan) are created when sample data does not exist for that lag period.
In addition to the lags, there may be situations where you need to add rolling aggregation of data values as features. For example, when predicting energy demand you might add a rolling window feature of three days to account for thermal changes of heated spaces. The table below shows feature engineering that occurs when window aggregation is applied. Columns for minimum, maximum, and sum are generated on a sliding window of three based on the defined settings. Each row has a new calculated feature, in the case of date January 4, 2017 maximum, minimum, and sum values are calculated using temp values for January 1, 2017, January 2, 2017, and January 3, 2017. This window of “three” shifts along to populate data for the remaining rows.
Generating and using these additional features as extra contextual data helps with the accuracy of the trained model. This is all possible by adding a few parameters to your experiment settings.
For many time series scenarios, holidays have a strong influence on how the modeled system behaves. The time before, during, and after a holiday can modify the series’ patterns, especially in scenarios such as sales and product demand. Automated ML will create additional features as input for model training on daily datasets. Each holiday generates a window over your existing dataset that the learner can assign an effect to. With this update, we will support over 2000 holidays in over 110 countries. To use this feature, simply pass the country code as a part of the time series settings. The example below shows input data in the left table and the right table shows updated dataset with holiday featurization applied. Additional features or columns are generated that add more context when models are trained for improved accuracy.
Get started with time-series forecasting in automated ML
With these new capabilities automated ML increases support more complex forecasting scenarios, provides more control to configure training data using lags and window aggregation and improves accuracy with new holiday featurization and ROCV. Azure Machine Learning aims to enable data scientists of all skill levels to use powerful machine learning technology that simplifies their processes and reduces the time spent training models. Get started by visiting our documentation and let us know what you think - we are committed to make automated ML better for you!
How Azure Machine Learning powers suggested replies in Outlook
Erez Barak Partner Group Program Manager, AI Platform Management
Microsoft 365 applications are so commonplace that it’s easy to overlook some of the amazing capabilities that are enabled with breakthrough technologies, including artificial intelligence (AI). Microsoft Outlook is an email client that helps you work efficiently with email, calendar, contacts, tasks, and more in a single place.
To help users be more productive and deliberate in their actions while emailing, the web version of Outlook and the Outlook for iOS and Android app have introduced suggested replies, a new feature powered by Azure Machine Learning. Now when you receive an email message that can be answered with a quick response, Outlook on the web and the Outlook mobile suggest three response options that you can use to reply with only a couple of clicks or taps, helping people communicate in both their workplace and personal life, by reducing the time and effort involved in replying to an email.
The developer team behind suggested replies is comprised of data scientists, designers, and machine learning engineers with diverse backgrounds who are working to improve the lives of Microsoft Outlook users by expediting and simplifying communications. They are at the forefront of applying cutting-edge natural language processing (NLP) and machine learning (ML) technologies and leverage these technologies to understand how users communicate through email and improve those interactions from a productivity standpoint to create a better experience for users.
A peek under the hood
To process the massive amount of raw data that these interactions provide, the team uses Azure Machine Learning pipelines to build their training models. Azure Machine Learning pipelines allow the team to divide training steps into discrete steps such as data cleanup, transforms, feature extraction, training, and evaluation. The output of the Azure Machine Learning pipeline converts raw data into a model. This Machine Learning pipeline allows the data scientists to build a training pipeline in a compliant manner that enforces privacy and compliance checks.
In order to train this model, the team needed a way to build and prepare a large data set comprised of over 100 million messages. To do this, the team leveraged a distributed processing framework to sample and retrieve data from a broad user base.
Azure Data Lake Storage is used to store the training data used for training the suggested replies models. We then clean and curate the data into message reply pairs (including potential responses to an email) that are stored in Azure Data Lake Storage (ADLS). The training pipelines also consume the reply pairs stored in ADLS in order to train models. To conduct the Machine Learning training itself, the team uses GPU pools available in Azure. The training pipelines leverage these curated Message Reply pairs to learn how to suggest appropriate replies based on a given message. Once the model is created, data scientists can compare the model performance with previous models and evaluate which approaches perform better at recommending relevant suggested replies.
The Outlook team helps protect your data by using the Azure platform to prepare large-scale data sets that are required to build a feature like suggested replies in accordance with Office 365 compliance standards. The data scientists use Azure compute and workflow solutions that enforce privacy policies to create experiments and train multiple models on GPUs. This helps with the overall developer experience and provides agility in the inner development loop cycle.
This is just one of many examples of how Microsoft products are powered by the breakthrough capabilities of Azure AI to create better user experiences. The team is learning from feedback every day and improving the feature for users while also expanding the types of suggested replies offered. Keep following the Azure blog to stay up-to-date with the team and be among the first to know when this feature is released.
Saturday 11 April 2020
Turn your whiteboard sketches to working code in seconds with Sketch2Code
User interface design process involves a lot a creativity that starts on a whiteboard where designers share ideas. Once a design is drawn, it is usually captured within a photograph and manually translated into some working HTML wire frame to play within a web browser. This takes efforts and delays the design process. What if a design is refactored on the whiteboard and the browser reflects changes instantly? In that sense, by the end of the session there is a resulting prototype validated between the designer, developer, and customer. Introducing Sketch2Code, a web based solution that uses AI to transform a handwritten user interface design from a picture to a valid HTML markup code.
Let’s understand the process of transforming handwritten image to HTML using Sketch2Code in more details.
- First the user uploads an image through the website.
- A custom vision model predicts what HTML elements are present in the image and their location.
- A handwritten text recognition service reads the text inside the predicted elements.
- A layout algorithm uses the spatial information from all the bounding boxes of the predicted elements to generate a grid structure that accommodates all.
- An HTML generation engine uses all these pieces of information to generate an HTML markup code reflecting the result.
Below is the the application workflow:
The Sketch2Code uses the following elements:
- A Microsoft Custom Vision Model: This model has been trained with images of different handwritten designs tagging the information of most common HTML elements like buttons, text box, and images.
- A Microsoft Computer Vision Service: To identify the text written into a design element a Computer Vision Service is used.
- An Azure Blob Storage: All steps involved in the HTML generation process are stored, including the original image, prediction results and layout grouping information.
- An Azure Function: Serves as the backend entry point that coordinates the generation process by interacting with all the services.
- An Azure website: User font-end to enable uploading a new design and see the generated HTML results.
The above elements form the architecture as follows:
You can find the code, solution development process, and all other details on GitHub. Sketch2Code is developed in collaboration with Kabel and Spike Techniques.
We hope this post helps you get started with AI and motivates you to become an AI developer.
Tara Jana Sr. Technical Product Marketing Manager, Artificial Intelligence
Home automation is much more than a one-trick pony. When you build on a strong foundation, such as an Solar Panel t hat powers your whole ...
Home automation is much more than a one-trick pony. When you build on a strong foundation, such as an Solar Panel t hat powers your whole ...
Is Your Business Really Protected or is it Home Alone: Prevent, Detect, and Respond for True SecurityProtecting a business’s IT infrastructure and data can be difficult with the abundance of threats out there, the array of new data privacy r...
Serverless architectures (also referred to as “FaaS” - Function as a Service) enable organizations to build and deploy software and se...