From Machine Learning for Business by Doug Hudgeon and Richard Nichol
This article covers basic time-series forecasting: what it is and why it’s a tough problem.
Forecasting your company’s monthly power usage
Kiara works for a retail chain which has forty-eight locations around the country. She’s an engineer and every month her boss asks her how much energy they’ll consume in the next month. Kiara follows the procedure taught to her by the previous engineer in her role: She looks at how much energy they consumed in the same month last year, weights it by the number of locations they gained or lost, and provides that number to her boss. Her boss then sends this estimate to the facilities management teams to help plan their activities and to Finance to forecast expenditure. The problem is that Kiara’s estimates are always wrong, sometimes by a lot.
As an engineer, she reckons there must be a better way to approach this problem. In this article, you’ll use SageMaker to help Kiara produce better estimates of her company’s upcoming power consumption. When the estimates are correct, they’ll be able to figure out if they are able to decrease the cost of their energy bills by comparing prices when looking at Business Energy quotes. Ultimately, it is no secret that soaring energy costs can have a detrimental impact on a business. The same goes for household bills too. After all, no one wants to pay too much for their electricity and other utilities and will often look for waves to save on their energy bills. You can click here to learn more. With this in mind, it is important to remember that sometimes switching energy suppliers can lead to big savings. For more information, and to check out some Reliant Energy plans that might be more affordable than your current energy plan, head to the Home Energy Club website.
What are you making decisions about?
We’re going to use a neural network to predict how much power Kiara’s company will use next month. Neural networks are much more difficult to intuitively understand than machine learning algorithms. Rather than attempt to give you a deep understanding of neural networks, in this article, we’ll focus on how to explain the output from the neural network. Instead of a theoretical discussion of neural networks, you’ll come out of this article knowing how to use a neural network to forecast time series events and how to explain the results of the forecast. Rather than learning in detail the why of neural networks, you’ll learn the how.
For example, figure 1 shows the predicted verses actual power consumption for one of Kiara’s sites for a six-week period from mid-October 2018 to the end of November. The site follows a weekly pattern with high usage on the weekdays and dropping low on Sunday.
The shaded blue area shows the range Kiara predicted with 80% accuracy. When Kiara calculates the average error for her prediction, she discovers it is 5.7%, which means that for any predicted amount, it is more likely to be within 5.7% of the predicted figure than not. Using SageMaker, you can do all of this without understanding in-depth how the neural network functions. In our view, this is OK.
Figure 1. Chart showing predicted verses actual power consumption for November 2018 for a site
To understand how neural networks can be used for time series forecasting, you need to understand why time-series forecasting is a thorny problem. Once you understand this, you’ll see what a neural network is and how a neural network can be applied to time-series forecasting. Then you’ll roll up your sleeves, fire up SageMaker, and see it in retailaction on real data.
The power consumption data you’ll use in this article is provided by BidEnergy (www.bidenergy.com), a company that specializes in power-usage forecasting and in minimizing power expenditure. The algorithms used by BidEnergy are more sophisticated than you’ll see in this article but you’ll get a feel for how machine learning in general and neural networks in particular can be applied to forecasting problems.
Introduction to time series data
Time-series data consists of a number of observations at particular interval. For example, if
you created a time series of your weight, you could record your weight on the first of every month for a year. Your time series would have twelve observations with a numerical value for each observation. Table 1 shows what this might look like.
Table 1. table showing a person’s weight over the past year
It’s pretty boring to look at a table of data. It’s hard to get a real understanding of the data when it’s presented in a table format. Line charts are the best way to view time series data.
Figure 2 shows the same data presented as a chart.
Figure 2. Chart showing time series data of my weight over the past year
You can see from this time series that the date is on the left and your weight is on the right. if you wanted to record time series of body weight for your entire family you’d add a column for each of your family members. In table 2 you can see your weight and the weight of each of your family members over the course of a year.
Table 2. Table showing the weight of members of a family over a year
|Date||Me||Spouse||Child 1||Child 2|
And, once you have that, you can visualize the data as four separate charts as shown in
Figure 3. Chart showing time series data of the weight of members of a family over the past year
Kiara’s time series data: daily power consumption
Power consumption data is displayed in a similar manner. Kiara’s company has forty-eight different business sites (retail, industrial, and transport), and each site gets its own column. Each observation is cell in that column. Table 3 shows a sample of the electricity data used in this article.
This data looks similar to the data in figure 3 showing the weight of each family member each month. The difference is that instead of each column representing a family member, in Kiara’s data each column represents a site (office/warehouse location) for her company. And instead of each row representing a person’s weight on the first day of the month, each row of Kiara’s data shows how much power each site used on that day.
Table 3. Power usage data sample (half-hour intervals)
Now that you see how time-series data can be represented and visualized, the next step is to see how to use a Jupyter notebook to visualize this data.