1
CHAPTER 8 – IOT ANALYTICS
NES 545-The Internet of Things - Fall 2025
Dr. Omar Banimelhem
Introduction
2
An IoT based system generates data with complex
structures.
Conventional data processing on these data is not sufficient.
Sophisticated data analytics are necessary to identify
hidden patterns.
In this chapter, we discuss a few traditional data analytics
tools that are popular in the context of IoT applications.
These tools include k-means, decision tree (DT), random
forest (RF), k-nearest neighbor (KNN), and density-based
spatial clustering of applications with noise (DBSCAN)
algorithms.
Data Representation
3
How does a computer represent data?
0 and 1 in the aspect of “general” computer science
Vector/Matrix in the aspect of “Machine Learning”
Data Types:
4
Types of Variable
5
A variable is a characteristic that can be measured
and that can assume different values.
Examples:
Height
Age
Income
provinceor country of birth
grades obtained at school
Reference
6
Variables may be classified into two main
categories:
(1) Categorical: A categorical variable (also called
qualitative variable) refers to a characteristic that can’t
be quantifiable. It is classified further into two types:
Nominal: A nominal variable is one that describes a name,
label or category without natural order.
Ordinal: An ordinal variable is a variable whose values are
defined by an order relation between the different
categories
7
Example: Ordinal variable: the variable
“behaviour” is ordinal because the category
“Excellent” is better than the category “Very good,”
which is better than the category “Good,” etc
8
(2) numeric. (also called quantitative variable) is a
quantifiable characteristic whose values are numbers
(except numbers which are codes standing up for
categories). Numeric variables may be either continuous or
discrete.
Continuous: A variable is said to be continuous if it can assume an
infinite number of real values within a given interval. For instance:
the height of a student.
Discrete: can assume only a finite number of real values within a
given interval.
An example of a discrete variable would be the score given by a
judge to a gymnast in competition: the range is 0 to 10 and the
score is always given to one decimal (e.g. a score of 8.5).
9
Features
An individual measurable property of a phenomenon
being observed
May have implicit/explicit patterns to describe a
phenomenon
10
Feature Examples:
Speech recognition
noise ratios, length of sounds, relative power
Spam detection
presence or absence of certain email headers, email
structure, frequency of specific terms
Image recognition
Edges, curves, ..
11
Samples
Items to process (classify or cluster)
Can be a document, a picture, a sound, a video, or a
patient
Features are characteristics of a sample
Machine learning
12
Machine learning (ML) is a “field of study that gives
computers the ability to learn without being explicitly
programmed”.
ML is a powerful tool hat allows a computer to learn from
past experiences and its mistakes and improve itself without
user intervention.
Different ML models play a crucial role in designing
intelligent systems in IoT by leveraging the massive amount
of generated data and increasing the accuracy in their
operations.
The main components of ML are statistics, mathematics, and
computer science for drawing inferences, constructing ML
models, and implementation, respectively.
Types of ML
13
We determine the meaning of labeled- and
unlabeled-data.
As the name suggests, labeled data contain certain
meaningful tags, known as labels.
The labels correspond to the characteristics or
properties of the objects.
On the other hand, the unlabeled dataset does not
have any tags associated with them. For example, a
dataset containing the images of a bird without
mentioning its name.
14
Examples on labeled data:
Image Recognition: Photos of animals with tags like "cat," "dog," "bird".
Spam Filtering: Emails marked as "spam" or "not spam".
Sentiment Analysis: Customer reviews tagged as "positive," "negative," or
"neutral".
Examples on Unlabeled data:
Raw Photos/Videos: A collection of images or video clips without any
descriptions or categories.
Social Media Posts: A stream of tweets or posts without sentiment or topic
tags.
Sensor Data: Raw readings from IoT devices or security logs.
Text Documents: A large archive of news articles or books without topic
classification
15
ML algorithms consist of four categories:
(1) Supervised Learning:
This type of learning supervises or directs a machine to
learn certain activities using labeled datasets.
The labeled data are used as a supervisor to make the
machine understand the relation of the labels with the
properties of the corresponding input data.
Supervised ML algorithms are popular in solving
classification and regression problems.
Classification deals with predictive models that are capable
of approximating a mapping function from input data to
categorical output.
16
On the other hand, regression provides the mapping function from
input data to numerical output.
There are different classification algorithms in ML:
k-nearest neighbor (KNN)
decision tree (DT)
random forest (RF)
We use regression to estimate the relationship among a set of
dependent variables with independent variables,.
The dependent variables are the primary factors that we want to
predict. However, these dependent variables are affected by the
independent variables.
Let x and y be the independent and dependent variables,
respectively. Mathematically, a simple regression model is
represented as:
17
(2) Unsupervised Learning:
Unsupervised learning algorithms use unlabeled datasets to
find scientific trends.
Unsupervised learning algorithms try to create different
clusters based on the features of the formula and relate it
with the input data.
Unsupervised learning is usually applied to solve two types
of problems: clustering and association.
Clustering divides the data into multiple groups.
Association discovers the relationship or association among
the data in a dataset.
18
(3) Semi-supervised Learning:
Semi-supervised learning belongs to a category between
supervised and unsupervised learning.
Algorithms under this category use a combination of both
labeled and unlabeled datasets for training.
Semi-supervised learning uses mostly unlabeled data, which
makes it efficient to use, and capable of overcoming
samples with missing labels.
19
(4) Reinforcement Learning (RL):
RL is more general than supervised/unsupervised
learning.
The learning is achieved from interaction with
environment to achieve a goal.
RL involves training an agent to make decisions in an
environment by rewarding it for good decisions and
punishing it for bad ones.
In RL, the agent receives a reward signal based on its
actions and uses this signal to learn a policy that
maximizes its long-term reward.
20
Reference
Selected Algorithms in ML
21
k-nearest neighbor (KNN)
KNN learning falls under the category of supervised
learning algorithms.
It is also known as lazy or instance-based learning.
Typically, KNN learning is one of the simplest
algorithms, as it needs no explicit training model.
22
23
Selection of k:
In the KNN algorithm, k indicates the number of nearest
neighbors necessary for predicting the outputs in a
particular model.
An appropriate selection of k is crucial to avoid anomalies.
Such anomalies usually lead to wrong outputs as well as
overfitting.
The selection of a small value of k may give rise to a high
variance in the output of the class level of the new dataset,
which affects stability.
However, a high value of k may bias the output in the class
level of the new dataset.
24
Distance Computation:
Typically,the KNN algorithm uses Euclidean, Manhattan, and
Minkowski distance formula for computing the distance
between the unknown data point and the given sample data
points.
Let there be two points A and B; let ai and bi indicate their
coordinates. Then, we compute the distances as follows:
A = (a1, a2,…, ax)
B = (b1, b2,…, bx)
25
26
Example:
Let us consider a dataset consisting of two classes of
objects:
Class M(solid squares), and class N(solid circles).
We apply KNN for splitting these data into their
corresponding classes. Consider an unknown data point
(question mark in the following Figure) that needs
identification of the cluster to which it belongs.
27
Initially,
we set k = 3, which indicates that we need 3
nearest neighbors for the classification process. The
data points with distance d1, d3, and d4 are the
nearest neighbors to the unknown data point. As two of
them are within class M, the unknown data point
belongs to this class.
Similarly, if we set k = 5, the neighbors located at
distances d1, d2, d3, d4, and d5 are nearest to the
unknown data point; as three of them are within class
M, the unknown data point is classified as an object of
class M
28
Decision Trees
29
Decision Tree : Decision tree is the most powerful
and popular tool for classification and prediction.
A Decision tree is a flowchart like tree structure,
where each internal node denotes a test on an
attribute, each branch represents an outcome of the
test, and each leaf node (terminal node) holds a
class label.
Example
Classification
k-means clustering
39
k-means clustering is an unsupervised ML algorithm
used for clustering.
This algorithm follows an iterative process for
dividing the dataset into k distinct clusters.
Typically, k-means clustering uses the Euclidean
distance between a point and the cluster’s centroid
for its operations.
40
Steps for k-means Clustering:
41
Example:
Let us consider a dataset consisting of three types of data.
Different types of data are differentiated using different shapes
(solid circle, solid pentagon, and solid square). We assume
that k = 3, which indicates that the data points are classified
into three clusters.
We follow the aforementioned steps and perform iteration 1.
In iteration 1, the k-means algorithm returns three clusters c1,
c2, and c3.
We then perform iterations 2, 3, and 4. In iterations 3 and 4,
the centroids remain unchanged, and we finally stop the
algorithm.
We obtain the final clusters from iteration 4.
42