BookmarkSubscribeRSS Feed

Learn how to do anomaly detection in floodlights for Smart Campus using SAS Analytics for IoT

Started ‎03-02-2020 by
Modified ‎03-03-2020 by
Views 3,343


With SAS Analytics for IoT, you can analyze real-time streaming data to monitor energy consumption, equipment operations, lighting, and heating, ventilation and air conditioning (HVAC) systems to improve operational efficiencies. This drives business outcomes such as lower downtime, lower cost, and sustainability.


In this example we will use data from a smart parking lot with six floodlights. It consists of energy consumption (kW) values captured every five minutes from these floodlight circuits over a span of three months.


We will use the  Subspace tracking (SST) algorithm packaged in SAS Event Stream Processing Studio (included in the SAS Analytics for IoT solution) to detect the outliers in real-time using streaming data. We frequently use SST in the IoT world when data is gathered from many sensors that are connected to each other and have high correlation. SST detects anomalies and system degradation in systems that generate high-frequency, high-dimensional data. It can also be used for data containing a single measure for sensors from various devices operating under similar conditions (e.g., energy output from multiple panels in a Solar farm), or multiple measures for sensors from a single device operating under similar conditions (e.g., turbofan in an aircraft).


Let's get started

This example takes you through the workflow to build an anomaly detection model using capabilities within SAS Analytics for IoT.



Data description

Our first step is to better understand our data.  Each light circuit has sensors that measures the energy consumption of the floodlights which can be used for operational efficiency, energy savings, and monitoring usage.


Data exploration

Next, we’ll analyze the first 16 days of the data in SAS Visual Analytics.  In Figure 1, we see that the energy consumption throughout the day is zero because the lights are off during the day. Light 2 has a dip in energy consumption for a couple of hours on the sixth night, indicating one of the lights controlled by the circuit was not functioning properly. During day 15, all lights have a spike in energy consumption during the day. A storm occurred on that day, creating enough darkness to trigger the lights to come on briefly. Just looking at the data it can be determined that there was no malfunction in the lights, saving any maintenance cost.



From analyzing the most recent 16 days of the data, Figure 2, we see that Light 4 starts to have many dips in energy consumption in the last 11 nights. Several of the lights on this circuit are starting to fail. Additionally, Light 5 dips in energy consumption, especially on the second-last night. This indicates that problems are occurring in this circuit as well and might need part replacement. The sooner we detect the issue the lower will be the floodlight downtime.



Building a streaming model

So far, the analysis has been done on static data. But how do we detect malfunctioning floodlights in real-time?  


ESP Studio provides in-stream learning models to make real time decisions. For this example, we will use the SST method. SST is a streaming analytics method which converts a set of correlated variables to a set of linearly uncorrelated variables known as principal components. Because the first few principal components usually capture most of the variability in the data, they can be tracked over time to assess whether any changes have taken place in the subspace that is spanned by the data. We can use SST to detect malfunctioning circuits in the floodlights by tracking angle changes between principal components or by using principal component distances away from the mean.


Figure 3 shows the model built in ESP Studio.



Result interpretation

Our last step is to interpret the results.  To do this, we can plot the output using SAS Visual Analytics. It shows the first principal component that is obtained after applying the SST method over the sliding windows of data.





  • Light 2 starts deviating from the first principal components that are associated with the other lights around the same time the dips were observed on the sixth night for these lights as seen in Figure 1.
  • Light 4 starts deviating from the first principal components that are associated with the other lights again around the same time the dips for this light were observed towards the end as seen in Figure 2.

This plot can help determine which floodlight circuits are malfunctioning. SST can give you a relatively clear indication of which part of the system is getting out of control.


Figure 5 displays the angle change of the first principal component between consecutive windows.



  • Value of angle change, indicated as vertical spikes in figure 5, is relatively higher when an outlier enters or exits the window
  • Checking value of angle change can detect when a light circuit is not functioning properly

This method can help identify the issues in real time. Decisions can be put into place to trigger maintenance activities when the angle change value is above an acceptable level for more cost effective and energy efficient lighting system.



We can build in-stream models using the Subspace tracking (SST) algorithm. It can monitor the system in real-time to identify and alert on faulty lights. This method can be used in other systems like HVAC, solar farm, wind turbines, etc. that generate high-frequency, high-dimensional data to detect anomalies and degradation in real-time.


Download the files to try it yourself!

The CSV file for data and XML model file are available along with step by step instructions in GitHub.

Take Me To GitHub

Sources and more information

Version history
Last update:
‎03-03-2020 08:51 AM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started