How AI is transforming the Smart Cities IoT? [Tutorial]

According to techopedia, a smart city is a city that utilizes information and communication technologies so that it enhances the quality and performance of urban services (such as energy and transportation) so that there’s a reduction in resource consumption, wastage, and overall costs.

In this article, we will look at components of a smart city and its AI-powered- IoT use cases, how AI helps with the adaption of IoT in Smart cities, and an example of AI-powered-IoT solution.

Deakin and AI Waer list four factors that contribute to the definition of a smart city:

Using a wide range of electronic and digital technologies in the city infrastructure

Employing Information and Communication Technology (ICT) to transform living and working environment

Embedding ICT in government systems

Implementing practices and policies that bring people and ICT together to promote innovation and enhance the knowledge that they offer

Hence, a smart city would be a city that not only possesses ICT but also employs technology in a way that positively impacts the inhabitants.

Artificial Intelligence (AI), together with IoT, has the potential to address the key challenges posed by excessive urban population; they can help with traffic management, healthcare, energy crisis, and many other issues. IoT data and AI technology can improve the lives of the citizens and businesses that inhabit a smart city. Let’s see how.

Smart city and its AI-powered-IoT use cases

A smart city has lots of use cases for AI-powered IoT-enabled technology, from maintaining a healthier environment to enhancing public transport and safety. In the following diagram, you can see some the of use cases for a smart city:

Smart city components

Let’s have a look at some of the most popular use cases that have already been implemented in smart cities across the world.

Smart traffic management

AI and IoT can implement smart traffic solutions to ensure that inhabitants of a smart city get from one point to another in the city as safely and efficiently as possible.

Los Angeles, one of the most congested cities in the world, has implemented a smart traffic solution to control the flow of traffic. It has installed road-surface sensors and closed-circuit television cameras that send real-time updates about the traffic flow to a central traffic management system. The data feed from the sensors and cameras is analyzed, and it notifies the users of congestion and traffic signal malfunctions. In July 2018, the city further installed Advanced Transportation Controller (ATC) cabinets at each intersection. Enabled with vehicle-to-infrastructure (V2I) communications and 5G connectivity, this allows them to communicate with cars that have the traffic light information feature, such as Audi A4 or Q7. You can learn more about the Los Angeles smart transportation system from their website.

The launch of automated vehicles embedded with sensors can provide both the location and speed of the vehicle; they can directly communicate with the smart traffic lights and prevent congestion. Additionally, using historical data, future traffic could be predicted and used to prevent any possible congestion.

Smart parking

Anyone living in a city must have felt the struggle of finding a parking spot, especially during the holiday time. Smart parking can ease the struggle. With road surface sensors embedded in the ground on parking spots, smart parking solutions can determine whether the parking spots are free or occupied and create a real-time parking map.

The city of Adelaide installed a smart parking system in February 2018, they are also launching a mobile app: Park Adelaide, which will provide the user with accurate and real-time parking information. The app can provide users with the ability to locate, pay for, and even extend the parking session remotely. The smart parking system of the city of Adelaide aims to also improve traffic flow, reduce traffic congestion, and decrease carbon emissions. The details of the smart parking system are available in the city of Adelaide website.

The San Francisco Municipal Transportation Agency (SAFTA) implemented SFpark a smart parking system. They use wireless sensors to detect real-time parking-space occupancy in metered spaces. Launched in the year 2013, SFpark has reduced weekday greenhouse gas emissions by 25%, the traffic volume has gone down, and drivers’ search time has reduced by 50%.

In London, the city of Westminster also established a smart parking system in the year 2014 in association with Machina Research. Earlier, drivers had to wait an average of 12 minutes, resulting in congestion and pollution, but since the installation of the smart parking system, there’s no need to wait; drivers can find an available parking spot using the mobile.

These are some of the use-cases mentioned. Other use-cases include smart waste management, smart policing, smart lighting, and smart governance.

What can AI do for IoT adaption in smart cities?

Building a smart city is not a one-day business, neither is it the work of one person or organization. It requires the collaboration of many strategic partners, leaders, and even citizens. Let’s explore what the AI community can do, what are the areas that provide us with a career or entrepreneurship opportunity. Any IoT platform will necessarily require the following:

A network of smart things (sensors, cameras, actuators, and so on) for gathering data

Field (cloud) gateways that can gather the data from low power IoT devices, store it, and forward it securely to the cloud

Streaming data processor for aggregating numerous data streams and distributing them to a data lake and control applications

A data lake for storing all the raw data, even the ones that seem of no value yet

A data warehouse that can clean and structure the collected data

Tools for analyzing and visualizing the data collected by sensors

AI algorithms and techniques for automating city services based on long-term data analysis and finding ways to improve the performance of control applications

Control applications for sending commands to the IoT actuators

User applications for connecting smart things and citizens

Besides this, there will be issues regarding security and privacy, and the service provider will have to ensure that these smart services do not pose any threat to citizens’ wellbeing. The services themselves should be easy to use and employ so that citizens can adopt them.

As you can see, this offers a range of job opportunities, specifically for AI engineers. The IoT-generated data needs to be processed, and to benefit from it truly, we will need to go beyond monitoring and basic analysis. The AI tools will be required to identify patterns and hidden correlations in the sensor data. Analysis of historical sensor data using ML/AI tools can help in identifying trends and create predictive models based on them. These models can then be used by control applications that send commands to IoT devices’ actuators.

The process of building a smart city will be an iterative process, with more processing and analysis added at each iteration. Let’s now have a look at an example of AI-powered-IoT solution.

Detecting crime using San Francisco crime data

The San Francisco city also has an open data portal providing data from different departments online. In this section, we take the dataset providing about 12 years (from January 2003 to May 2015) of crime reports from across all of San Francisco’s neighborhoods and train a model to predict the category of crime that occurred. There are 39 discreet crime categories, thus it’s a multi-class classification problem.

We will use make use of Apache’s PySpark and use its easy to use text processing features for this dataset. So the first step will be to create a Spark session:

The first step is to import the necessary modules and create a Spark session:

Now the dataset we have has textual data, so we will need to perform text processing. The three important text processing steps are: tokenizing the data, remove the stop words and vectorize the words into vectors. We will use RegexTokenizer which will uses regex to tokenize the sentence into a list of words, since punctuation or special characters do not add anything to the meaning, we retain only the words containing alphanumeric content. There are some words like the, which will be very commonly present in the text, but not add any meaning to context. We can remove these words (also called stop words) using the inbuilt StopWordsRemover class. We use standard stop words ["http","https","amp","rt","t","c","the"]. And finally using the CountVectorizer, we convert the words to numeric vector (features). It’s these numeric features that will be used as input to train the model. The output for our data is the Category column, but it’s also textual with 36 distinct categories, and so, we need to convert it to one hot encoded vector; the PySpark’s StringIndexer can be easily used for it. We add all these transformations into our data Pipeline:

AI is changing the way cities operate, deliver, and maintain public amenities, from lighting and transportation to connectivity and health services. However, the adoption can be obstructed by the selection of technology that doesn’t efficiently work together or integrate with other city services. For cities to truly benefit from the potential that smart cities offer, a change in mindset is required. The authorities should plan longer and across multiple departments.

The city of Barcelona is a prime example where the implementation of IoT systems created an estimated 47,000 jobs, saved €42.5 million on water, and generated an extra €36.5 million a year through smart parking. We can easily see that cities can benefit tremendously from the technological advances that utilize AI-powered IoT solutions. AI-powered IoT solutions can help connect cities and manage multiple infrastructure, and public services.

In this article, we looked at use-cases of smart-cities from smart lighting and road traffic to connected public transport, and waste management. We also learned to use tools that can help categorize the data from the San Francisco crime reports done in a period of 12 years. If you want to explore more topics in the book, be sure to check out the book ‘Hands-On Artificial Intelligence for IoT’.