4/11/2025
Lecture 9: Internet of Things and
Artificial Intelligence
Seyed-Hosein Attarzadeh-Niaki
Fundamentals of IoT 1
Review
• Data management in IoT
– Data Ingestion Layer: Collects and routes data.
• Apache Kafka, Apache Nifi, Elastic Logstash
– Data Processing Layer: Analyzes data
• Lambda and Kappa architectures
• Apache Storm, Apache Flink, Apache Spark
– Data Storage Layer: Stores data
• Cold, warm, and hot storage
• SQL and NoSQL databases
• MongoDB, Cassandra, Redis, Elasticsearch
– CAP theorem for choosing DB
Fundamentals of IoT 2
1
4/11/2025
Lecture Objectives
Understand the concept of Artificial Intelligence of Things (AIoT)
Explore how AI enhances IoT capabilities
Identify key AIoT architectures and their applications
Briefly survey AI techniques used in IoT (focus on usage, not deep algorithms)
Discuss challenges and opportunities of AIoT integration
Fundamentals of IoT 3
Defining Artificial Intelligence &
Machine Learning
A broad field of computer science focused
Artificial on creating systems that can perform tasks
Intelligence typically requiring human intelligence
(AI) e.g., learning, problem-solving, perception,
decision-making.
Machine A subset of AI where systems learn from
Learning data without being explicitly programmed.
(ML) ML algorithms identify patterns and build
models to make predictions or decisions.
Deep A subfield of ML using multi-layered neural
Learning networks (deep architectures) to learn
(DL) complex patterns, especially from
unstructured data like images and text.
Fundamentals of IoT 4
2
4/11/2025
What is AIoT?
• AIoT = Artificial Intelligence +
Internet of Things
• Combines AI techniques with
IoT infrastructure for
intelligent systems
• Two forms
– Loosely coupled: AI analyzes
data from non-intelligent IoT
devices (on the cloud)
• IoT devices = data collectors
– Tightly coupled: AI integrated
into IoT devices for on-device
intelligence
• Real-time local processing
• Goal: Enable smarter decision-
making and automation
Fundamentals of IoT 5
Why AI for IoT? The Data Deluge
• IoT generates massive volumes of data from diverse sources (sensors,
devices, interactions).
• This data is often complex, high-dimensional, noisy, and dynamic.
• Traditional data processing methods struggle to handle the scale and
complexity.
➢ AI/ML provides tools to
– Analyze vast datasets automatically.
– Identify hidden patterns and correlations.
– Make predictions and classifications.
– Enable intelligent automation and decision-making.
– Transform raw data into actionable insights.
Fundamentals of IoT 6
3
4/11/2025
AIoT Reference Architecture
• Three-tier model
– End Device Layer:
Cloud
Sensors/actuators, some with AI layer
– Edge/Fog Layer: Local processing,
reduced latency
– Cloud Layer: High-compute tasks, Edge/fog
data storage
layer
• AI units deployed across layers
based on application needs
• Supports both loosely and
AIoT device
tightly coupled AIoT layer
Fundamentals of IoT 7
AI Deployment Scenarios
Centralized: Distributed:
AI on one layer (cloud, edge, or device) AI across multiple layers
• Cloud: High compute, but latency/privacy • Vertical: Training/inference split (e.g.,
issues cloud training, edge inference)
• Device: Fast, secure, but resource-limited • Horizontal: Collaboration within a layer
• Edge: Balanced latency and resources (e.g., device-to-device)
• Hybrid: Combines vertical and horizontal
Fundamentals of IoT 8
4
4/11/2025
Centralized AIoT Scenarios
On-Cloud Processing
• Data sent to cloud for AI analysis
• Pros: Cost-efficient, high compute power
• Cons: Latency, privacy concerns
On-Device Processing
• AI runs on IoT device
• Pros: Fast, secure
• Cons: Limited compute capacity
On-Edge Processing
• Edge nodes process data
• Pros: Low latency, moderate resources
• Cons: High-resource AI still challenging
Fundamentals of IoT 9
Distributed AIoT Scenarios
Vertical Splits AI tasks (e.g., training on cloud, inference on edge)
Distribution Optimizes latency and resource use
Horizontal Collaboration across same-layer devices (e.g., federated learning)
Distribution Handles distributed data efficiently
Hybrid Combines vertical and horizontal for complex applications
Distribution Example: Edge-cloud synergy for real-time analytics
Fundamentals of IoT 10
5
4/11/2025
AIoT Applications
• AIoT enhances IoT in various domains
– Flood Disaster Management: Predictive analytics
– Healthcare: Real-time monitoring (e.g., COVID-19 prevention)
– Elderly Care: Assisted living via AIoT sensors
– Smart Wheelchairs: Autonomous assistance
• Key feature: AI-driven automation and prediction
Application AIoT Role
Flood Management Predict flood risks
COVID-19 Prevention Monitor and control spread
Elderly Living Fall detection, health alerts
Smart Wheelchair Social distancing, vitals
Fundamentals of IoT 11
Major ML Categories:
Supervised Learning
• Concept: Learning from labeled data (input-output pairs).
– The algorithm learns a mapping function to predict outputs for new inputs.
• Tasks
– Classification: Assigning inputs to predefined categories (e.g., spam/not spam,
normal/abnormal sensor reading).
– Regression: Predicting continuous values (e.g., predicting temperature, energy
consumption, remaining useful life).
• IoT Examples
– Classifying sensor data for anomaly detection
– Predicting energy demand in a smart grid
– Identifying activity patterns in smart homes
Fundamentals of IoT 12
6
4/11/2025
Major ML Categories:
Unsupervised Learning
• Concept: Learning from unlabeled data
– The algorithm finds hidden structures or patterns within the data itself.
• Tasks
– Clustering: Grouping similar data points together (e.g., segmenting users
based on behavior).
– Dimensionality Reduction: Reducing the number of variables while preserving
important information (e.g., simplifying complex sensor data).
– Association Rule Mining: Discovering relationships between items (e.g., "if
sensor A reads high, sensor B often fails").
• IoT Examples
– Grouping sensor nodes with similar behavior patterns
– Detecting novel anomalies not seen in training data.
– Feature extraction from high-dimensional sensor inputs
Fundamentals of IoT 13
Reinforcement Learning in AIoT
• Concept: An agent learns to make a sequence of decisions by trying to
maximize a reward signal it receives for its actions.
– Learning occurs through trial and error.
• Key Elements: Agent, Environment, State, Action, Reward.
• IoT Examples
– Optimizing energy consumption in HVAC systems based on real-time
conditions and rewards for saving energy.
– Controlling autonomous robots or drones in dynamic environments
– Adapting communication protocols in wireless sensor networks.
– Resource allocation and task scheduling in IoT systems
Fundamentals of IoT 14
7
4/11/2025
Common ML Techniques in IoT:
Classification Algorithms
• Goal: Categorize IoT data into predefined classes.
• Examples
– K-Nearest Neighbors (KNN): Classifies data based on
the majority class of its 'k' nearest neighbors in the
feature space. Simple, often used for baseline models.
– Support Vector Machines (SVM): Finds an optimal
hyperplane to separate data points into different
classes. Effective in high-dimensional spaces.
– Decision Trees: Tree-like structure where internal
nodes test features, branches represent outcomes,
and leaves represent class labels. Interpretable.
– Naive Bayes: Probabilistic classifier based on Bayes'
theorem with strong (naive) independence
assumptions. Fast and efficient.
• IoT Use Cases: Activity recognition,
fault detection, intrusion detection.
Fundamentals of IoT 15
Common ML Techniques in IoT:
Clustering Algorithms
• Goal: Group unlabeled IoT data points based on
similarity.
• Examples
– K-Means: Partitions data into 'k' clusters by minimizing
the distance between data points and their assigned
cluster centroid. Widely used, computationally efficient.
– DBSCAN: Density-based clustering, groups points that are
closely packed together, marking outliers. Can find
arbitrarily shaped clusters.
• IoT Use Cases
– Identifying patterns in sensor data without prior
knowledge.
– Customer segmentation based on smart device usage.
– Anomaly detection (points not belonging to any cluster).
– Network traffic analysis.
Fundamentals of IoT 16
8
4/11/2025
Common ML Techniques in IoT:
Deep Learning
• Subset of ML with multiple layers (neural networks)
• Key types
– Convolutional Neural Networks (CNNs)
• Used for: Image/video analysis in IoT (e.g., surveillance)
• Features: Convolution, pooling, fully connected layers
– Recurrent Neural Networks (RNNs)
• Designed for sequential data, have internal memory
• e.g., time-series forecasting (energy load, sensor readings)
• Benefits: Handles complex, unstructured IoT data
Fundamentals of IoT 17
Other AI Techniques in IoT:
Fuzzy Logic & Evolutionary Algorithms
• Fuzzy Logic
– Deals with reasoning that is approximate rather than
precise. Uses "degrees of truth" (values between 0 and 1)
instead of binary true/false.
– IoT Use Cases
• Control systems where inputs are uncertain or imprecise (e.g.,
smart thermostats adjusting based on "slightly cold" or "very
warm")
• Decision making in complex environments.
• Evolutionary Algorithms (e.g., Genetic Algorithms - GA)
– Optimization techniques inspired by biological evolution
(selection, crossover, mutation).
– Used to find good solutions in large search spaces.
– IoT Use Cases
• Optimizing sensor placement,
• Network routing protocols
• Task scheduling in resource-constrained devices
Fundamentals of IoT 18
9
4/11/2025
The AI/ML Workflow in
IoT Inference & Action Data Acquisition
•Using the deployed •Collecting data from
model to make diverse IoT sensors
predictions or and devices.
decisions on new IoT
data.
Model Deployment Data Preprocessing
•Integrating the trained •Cleaning, formatting,
model into the IoT system normalizing, handling
(edge, fog, or cloud). missing values, feature
engineering.
Model Evaluation Model Selection
•Assessing the model's •Choosing appropriate
performance using ML algorithms based
metrics and validation on the problem
data. (classification,
regression, etc.) and
data characteristics.
Model Training
•Feeding preprocessed
data to the selected
algorithm to learn
patterns.
Fundamentals of IoT 19
Step 1 & 2: Data Acquisition &
Preprocessing Challenges in IoT
•Heterogeneity: Different data types, formats, sampling rates.
•Volume & Velocity: Massive amounts of data generated rapidly.
Acquisition Challenges
•Connectivity: Intermittent or unreliable network connections.
•Power Constraints: Limited battery life on edge devices affects data transmission frequency.
•Handling Missing Data: Due to sensor failures or transmission issues.
•Noise Reduction: Sensors can be inaccurate or affected by environment.
•Data Synchronization: Aligning data from multiple sensors with different timestamps.
Preprocessing Needs
•Normalization/Standardization: Scaling data to a common range.
•Feature Engineering/Selection: Creating relevant input features from raw data; selecting the
most informative ones.
Embedded Real-Time System 20
10
4/11/2025
Step 3 & 4: Model Selection & Training
Considerations
• Model Selection Factors
– Type of problem (classification, regression, clustering).
– Amount and quality of labeled/unlabeled data.
– Computational resources available (edge vs. cloud).
– Interpretability requirements (is it important to understand why the model
makes a decision?).
– Real-time processing needs.
• Training Considerations
– Data Partitioning: Splitting data into training, validation, and testing sets.
– Hyperparameter Tuning: Optimizing algorithm parameters (e.g., learning rate,
number of clusters).
– Overfitting/Underfitting: Balancing model complexity to generalize well to
new data. (related concept: Regularization)
– Distributed Training: Training models across multiple machines for large
datasets (often in the cloud).
Fundamentals of IoT 21
Step 5 & 6: Model Evaluation &
Deployment in IoT
• Evaluation Metrics (Examples)
– Classification: Accuracy, Precision, Recall, F1-Score,
Confusion Matrix.
– Regression: Mean Squared Error (MSE), R-squared.
– Clustering: Silhouette Score, Davies-Bouldin Index.
• Deployment Strategies
– Cloud: Models run on powerful servers, suitable for
complex tasks requiring large datasets.
– Fog/Gateway: Models run on intermediate nodes
closer to devices, balancing latency and
computational power.
– Edge: Models run directly on IoT devices, enabling
fast, real-time decisions and offline operation.
Requires optimized, lightweight models.
Fundamentals of IoT 22
11
4/11/2025
Step 7 & 8: Inference, Action &
Monitoring
• Inference: The deployed model processes new incoming IoT data to
generate predictions or insights.
• Action: Based on the inference results, the IoT system triggers
actions:
– Alerting users (e.g., security breach detected).
– Adjusting device settings (e.g., thermostat control).
– Initiating control processes (e.g., shutting down faulty machinery).
– Providing recommendations (e.g., optimal farming practices).
• Monitoring & Retraining
– Continuously track model performance in the real world.
– Detect concept drift (when data patterns change over time).
– Periodically retrain or update models with new data to maintain
accuracy.
Fundamentals of IoT 23
Transfer Learning in AIoT
• Transfer Learning (TL): Reusing pre-trained models for new
tasks.
• Benefits: Reduces training time/data needs, adapts to new
domains.
• Types: Inductive TL (different tasks, same domain),
Transductive TL (same task, different domains).
• Usage: Image recognition on resource-limited IoT devices.
Fundamentals of IoT 24
12
4/11/2025
Federated Learning in AIoT
• Distributed ML for privacy-sensitive IoT data
• Types
Horizontal FL Vertical FL Transfer Learning
• Same features • Different features •Adapts across domains
• Different samples • Same samples
• e.g., voice assistants • e.g., e-commerce + bank
• Usage: Edge-based training without data sharing
Fundamentals of IoT 25
AI Model Optimization for AIoT
• Goal: Fit AI into resource-limited IoT devices
• Techniques
– Compact Networks: Fewer parameters (e.g., ShuffleNet)
– Model Compression: Reduce size (e.g., pruning, quantization)
• Examples: Low-rank approximation, knowledge distillation
• Enables on-device AI for real-time IoT tasks
Fundamentals of IoT 26
13
4/11/2025
Tools and Platforms for AI/ML in IoT
Cloud Platforms
• Offer end-to-end services for data storage, model training, deployment, and
management.
• Examples: AWS IoT + SageMaker, Google Cloud IoT + Vertex AI, Microsoft Azure IoT +
Azure ML.
ML Frameworks & Libraries
• Provide tools for building and training models.
• Examples: TensorFlow (incl. Lite for Edge), PyTorch, scikit-learn, Keras.
Edge AI Platforms
• Specific tools and hardware for deploying models on resource-constrained devices.
• Examples: NVIDIA Jetson, Google Coral, Raspberry Pi (with ML accelerators), Edge
Impulse, OpenVINO.
Fundamentals of IoT 27
Challenges in AIoT
Resource Constraints
• IoT devices face limits in compute power, memory, and energy.
• Impact: Complex AI models are hard to run.
• Solutions: Model compression, edge computing.
Data Privacy and Security
• IoT data (e.g., health, location) is sensitive; AI processing raises privacy issues.
• Risks: Data breaches, adversarial attacks.
• Solutions: Federated learning, homomorphic encryption, secure multi-party computation.
Scalability and Heterogeneity
• Challenges: Managing millions of diverse devices, interoperability issues, varying data formats.
• AI Solutions: Automated management, adaptive systems.
Real-time Processing
• Many IoT applications need instant responses.
• Challenges: Cloud latency, bandwidth limits.
• Solutions: Edge AI, optimized protocols.
Fundamentals of IoT 28
14
4/11/2025
Practical Examples
Smart Cities
• Traffic management: AI optimizes flow.
• Waste management: AI schedules collection.
• Public safety: AI detects anomalies.
Industrial IoT
• Predictive maintenance: Failure prediction.
• Quality control: Real-time inspection.
• Supply chain: Demand forecasting.
Healthcare
• Remote monitoring: Wearables with AI.
• Disease prediction: AI on patient data.
• Hospital management: Resource optimization.
Fundamentals of IoT 29
Future Trends in AIoT
Federated Learning TinyML Explainable AI (XAI)
• Training models collaboratively • Running sophisticated ML • Developing techniques to make
across devices without models on extremely low- AI decisions more interpretable
centralizing raw data, improving power microcontrollers. and transparent.
privacy.
AI for Digital Twins Reinforcement Learning AI & Blockchain for IoT
• Using AI to create more for Control • Enhancing security, trust, and
accurate and predictive virtual • Increased use of RL for data provenance.
replicas of physical IoT systems. autonomous optimization and
control in complex IoT
environments.
Fundamentals of IoT 30
15
4/11/2025
Conclusion and Summary
• AI/ML is essential for unlocking the full potential of IoT by
extracting insights from vast amounts of data.
• Key ML paradigms (Supervised, Unsupervised, Reinforcement
Learning) and techniques (Classification, Clustering, DL) are widely
applied in IoT.
• AI helps address critical IoT challenges like resource management,
security, and data analytics.
• Edge AI is a growing trend, enabling real-time processing and
enhancing privacy.
• Numerous tools and platforms facilitate AI/ML implementation in
IoT.
• Ethical considerations (privacy, bias, transparency) are paramount.
• Future trends promise even more integrated and intelligent IoT
systems.
Fundamentals of IoT 31
Next Lecture
• IoT security: Threats and Risks
Fundamentals of IoT 32
16
4/11/2025
Feature Engineering in IoT
Feature Selection Feature Extraction
• Univariate method • Principal component
• Multivariate method analysis (PCA)
• Filter methods
• Wrapper methods
– Forward Selection
– Backward Elimination
• Embedded methods
• Linear discriminant analysis
(LDA)
Fundamentals of IoT 33
17