Skip to content

Automating Time Series with WhizzML

by on July 18, 2017

Since the beginning of our civilization, humans have worried about the future. In particular, we worry about predicting the future. It’s widely known that in ancient Greece, the most famous oracle was in Delphi. Greek people went there to find out about their future and to decide what they should do to turn their fortunes around. Three thousand years later, the worry about how to act in the future remains, however, we’ve learned to base our decisions on the algorithms and science inherited from Pythagoras, Euclid, Thales or Archimedes rather than on Pythia’s words.

oraculo_griego_ml

To continue with our series of posts about Time Series, this fifth blog post focuses on WhizzML users. WhizzML is our Domain Specific Language for Machine Learning workflow automation, which provides programmatic support for all your BigML resources in a way that is completely executed in the BigML back-end.

Every resource in BigML can be managed through WhizzML. It follows naturally that you can now use WhizzML scripts to create Time Series models and make forecasts with it.

For the Time Series resource, we are going to begin explaining how to split a dataset based on the range parameter as it’s important to keep the data in the same order for creating the Time Series and also for evaluating it. As explained in a previous blog post, when testing other supervised models, we can use as test data any randomly sampled subset of instances. However, evaluating time series requires the hold out to be a range of our data, as the training-test splits must be sequential. For an 80-20 split, the test set is the final 20% of rows in the dataset. WhizzML calculates the split ranges by specifying a percentage of rows. In the script snippet below, we set aside 80% of our rows.

Screen Shot 2017-07-17 at 03.22.21

The function linear-split receives a dataset and a percentage, and it creates two complementary datasets, one for testing test-ds and one for training train-ds, by splitting the existing rows in two ranges. The one above is the largest script in this post, so it only gets easier from here on.

Now let’s see how to create a Time Series that models our data. Because we would like to evaluate our Time Series later on, we will use the training_ds_id that is output by our script. In fact, the unique mandatory parameter to create a Time Series is the dataset ID used for training. You can also specify which ETS models you would like to generate. By default, BigML will explore all of them. So the simplest code to create a Time Series is as easy as the example that follows.

Screen Shot 2017-07-18 at 11.45.12

In case you have more information about your data, you might want to use other Time Series creation parameters. The full list of parameters can be found in the Time Series section of the API documentation.

For monthly data and seasonal activities, you can set an additive trend for your data with its seasonality set to additive (with value 1) and its period specified as 12. Then you may fill the properties in the function that creates the time series as in the example below.

Screen Shot 2017-07-18 at 11.49.42

This is a good point to remind ourselves about the fact that most WhizzML requests are asynchronous. Thus, it’s quite possible that you will need to wait for the resource to finish before referring to it in other scripts or accessing its properties. For the previous example, the code would look like this:

Screen Shot 2017-07-18 at 11.52.17

Once the Time Series has been created, we can evaluate how good its fit is. Remember that our original dataset was chronologically split into two parts. Now, we will use the remaining 20% of the dataset to check the Time Series model performance.  The test-ds parameter in the code below represents the second part of the dataset. Following WhizzML’s less is more philosophy, creating an evaluation requires a simple code snippet with only two mandatory parameters: a Time Series to be evaluated and a dataset to use as test data.

Screen Shot 2017-07-18 at 11.55.00

In the evaluation object, there are some measures for each one of the ETS models in the Time Series. For more on this, see section 5 of our previous post.

After evaluating your Time Series, what’s next is calling for the aforementioned “Modern-day Oracle”. Once you build a Time Series with the entire original dataset, that is, including the hold-out rows, you can predict the future values of one or many features in your data domain. In this code, we demonstrate the simplest case, where the forecast is made only for one of the fields in your dataset.

Screen Shot 2017-07-17 at 10.53.26

As a developer, the cool part of WhizzML is that it allows you to create a complete script with all the steps you need and execute them in the cloud or in an on-premises deployment with a single call. This takes advantage of the service’s built-in scalability and parallelization capabilities and minimizes latency or possible network brittleness while exchanging information with the cloud. You can do this by directly creating an execution of your script either directly in the BigML API or by using any of the existing BigML Bindings.

BigML supports bindings in different programming languages that allow you to create not only the resources available in the platform, such as Time Series and Evaluations, but also Scripts and Executions. Everything can be managed from your favorite programming languages like Python, Node.js among many others. You can see the complete list of our bindings and the related documentation on our dedicated Tools page.

Want to know more about Time Series?

If you have any questions or you’d like to learn more about how Time Series work, please visit the dedicated release page for further learning. It includes a series of six blog posts about Time Series, the BigML Dashboard and API documentation, the webinar slideshow as well as the full webinar recording.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: