Book Image

Artificial Intelligence for IoT Cookbook

By : Michael Roshak
Book Image

Artificial Intelligence for IoT Cookbook

By: Michael Roshak

Overview of this book

Artificial intelligence (AI) is rapidly finding practical applications across a wide variety of industry verticals, and the Internet of Things (IoT) is one of them. Developers are looking for ways to make IoT devices smarter and to make users’ lives easier. With this AI cookbook, you’ll be able to implement smart analytics using IoT data to gain insights, predict outcomes, and make informed decisions, along with covering advanced AI techniques that facilitate analytics and learning in various IoT applications. Using a recipe-based approach, the book will take you through essential processes such as data collection, data analysis, modeling, statistics and monitoring, and deployment. You’ll use real-life datasets from smart homes, industrial IoT, and smart devices to train and evaluate simple to complex models and make predictions using trained models. Later chapters will take you through the key challenges faced while implementing machine learning, deep learning, and other AI techniques, such as natural language processing (NLP), computer vision, and embedded machine learning for building smart IoT systems. In addition to this, you’ll learn how to deploy models and improve their performance with ease. By the end of this book, you’ll be able to package and deploy end-to-end AI apps and apply best practice solutions to common IoT problems.
Table of Contents (11 chapters)

How it works...

First, we are defining where the files are located. For this recipe, we are using Azure Blob Storage, but any storage system, such as S3 or HDFS, would work as well. Replace the storage_account_name and storage_account_access_key fields with the keys of your Blob Storage account. Read both safe and unsafe images in from our storage account into a Spark image DataFrame. In our example, we have placed safe images in one folder and unsafe images in another. Query the image DataFrame to see if it got the images. Create safe and unsafe test and training sets. We then union our datasets into a training set and a testing set. Next, we create a machine learning pipeline. We use the ResNet-50 algorithm as a featurizer. Next, we use logistic regression as our classifier. We then put it into a pipeline and train our model. Next, we take our pipeline and run our training DataFrame through it to come out with a trained model. We then evaluate the accuracy of our model. Finally, we...