0% found this document useful (0 votes)
2 views17 pages

CC Module 2 U

The document outlines the Machine Learning (ML) Lifecycle, which includes steps such as data collection, preprocessing, feature extraction, model training, evaluation, deployment, and monitoring. It emphasizes the importance of ML deployment for real-world applications and discusses challenges like data drift and model versioning. Additionally, it covers serialization and deserialization processes for model management and the necessity of model retraining to maintain accuracy over time.

Uploaded by

manish2205pratap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views17 pages

CC Module 2 U

The document outlines the Machine Learning (ML) Lifecycle, which includes steps such as data collection, preprocessing, feature extraction, model training, evaluation, deployment, and monitoring. It emphasizes the importance of ML deployment for real-world applications and discusses challenges like data drift and model versioning. Additionally, it covers serialization and deserialization processes for model management and the necessity of model retraining to maintain accuracy over time.

Uploaded by

manish2205pratap
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CC: Module 2

Saturday, 27 June 2026 11:33 PM

Machine Learning (ML)


is a branch of Artificial Intelligence that enables computers to learn from data and improve their
performance without being explicitly programmed for every task.
Instead of following fixed rules, a machine learning model identifies patterns in data and uses those
patterns to make predictions or decisions. The more relevant data it learns from, the better it can become
at performing its task.
Example:
A spam filter is trained using thousands of emails marked as "spam" or "not spam." It learns the
characteristics of spam emails and can then classify new emails automatically.

Machine Learning Lifecycle


Definition
The Machine Learning (ML) Lifecycle is a systematic process of building, training, deploying, and
maintaining a machine learning model. It begins with data collection and ends with continuous
monitoring and maintenance to ensure the model performs accurately in real-world applications.

Steps of Machine Learning Lifecycle


1. Data Collection
The first step is to collect raw data from various sources such as databases, sensors, websites, APIs, or
application logs. The quality and quantity of data directly affect the performance of the model.
Example: Collecting customer purchase history for a recommendation system.

2. Data Preprocessing
The collected data is cleaned and prepared for analysis.
Tasks involved:
• Removing missing values
• Removing duplicate records
• Handling outliers
• Data normalization and formatting
This ensures the data is accurate and consistent.

3. Feature Extraction & Selection


Features are the important attributes used by the model.
• Feature Extraction: Creating new useful features from raw data.
• Feature Selection: Selecting the most relevant features and removing unnecessary ones.
This improves model accuracy and reduces training time.

4. Training Data Split


The dataset is divided into:
• Training Data: Used to train the model.
• Testing Data: Used to evaluate model performance.
• (Optional) Validation Data: Used for hyperparameter tuning.
A common split is 70% training and 30% testing.

5. Model Selection
An appropriate machine learning algorithm is selected based on the problem.
Examples:
• Linear Regression
• Decision Tree
• Random Forest
• Support Vector Machine (SVM)
• Neural Networks
The goal is to choose the model that best fits the data.

6. Model Training
The selected algorithm learns patterns from the training dataset by adjusting its internal parameters.
The objective is to minimize prediction errors and improve accuracy.
• Decision Tree
• Random Forest
• Support Vector Machine (SVM)
• Neural Networks
The goal is to choose the model that best fits the data.

6. Model Training
The selected algorithm learns patterns from the training dataset by adjusting its internal parameters.
The objective is to minimize prediction errors and improve accuracy.

7. Model Evaluation
The trained model is tested using the test dataset to measure its performance.
Common Evaluation Metrics:
• Accuracy
• Precision
• Recall
• F1-Score
• Mean Squared Error (MSE)
This step checks whether the model performs well on unseen data.

8. Model Deployment & Prediction


After successful evaluation, the model is deployed into a real-world environment such as a web
application, mobile app, or cloud platform.
The deployed model starts making predictions on new data.
Example: A fraud detection model deployed in a banking system.

9. Model Monitoring & Maintenance


After deployment, the model is continuously monitored to ensure it performs correctly.
Activities include:
• Monitoring model accuracy
• Detecting data drift
• Retraining with new data
• Updating the deployed model
This keeps the model accurate and reliable over time.

Machine Learning Lifecycle Diagram


Data Collection

Data Preprocessing

Feature Extraction & Selection

Training Data Split

Model Selection

Model Training

Model Evaluation

Model Deployment & Prediction

Model Monitoring & Maintenance

Example (Hospital Scenario)


A hospital develops an ML model to predict heart disease.
• Data Collection: Collect patient records.
• Data Preprocessing: Remove missing values and clean data.
• Feature Selection: Select age, blood pressure, cholesterol, etc.
• Data Split: Divide into training and testing sets.
• Model Selection: Choose Decision Tree or Random Forest.
• Model Training: Train the model.
• Model Evaluation: Measure accuracy and precision.
• Model Deployment: Integrate into the hospital system.
• Monitoring: Retrain the model regularly using new patient data.
This ensures accurate disease prediction and supports doctors in decision-making.
• Model Evaluation: Measure accuracy and precision.
• Model Deployment: Integrate into the hospital system.
• Monitoring: Retrain the model regularly using new patient data.
This ensures accurate disease prediction and supports doctors in decision-making.

1. Machine Learning (ML) Deployment


Definition
Machine Learning Deployment is the process of integrating a trained machine learning model into a
production environment so that it can make predictions on new, real-world data. It bridges the gap
between model development and practical applications.

Objectives of ML Deployment
• Make the trained model available to end users.
• Generate real-time or batch predictions.
• Integrate the model with web, mobile, or cloud applications.
• Improve business decision-making through automated predictions.
• Monitor and update the model for better performance.

Importance of ML Deployment
• Enables real-world usage of ML models.
• Automates decision-making.
• Supports real-time predictions.
• Creates business value.
• Provides scalability for millions of users.
• Allows continuous monitoring and retraining.

Deployment Methods
1. Batch Deployment – Predictions are generated on large datasets at scheduled intervals.
2. Real-Time (Online) Deployment – Instant predictions using APIs.
3. Edge Deployment – Model runs on local devices (IoT, smartphones).
4. Streaming Deployment – Handles continuous real-time data streams.

2. ML Deployment Architecture
Definition
ML Deployment Architecture is the framework that integrates a trained machine learning model into a
production environment. It defines how data flows from users to the model and back while ensuring
scalability, reliability, and efficient prediction serving.

Components of ML Deployment Architecture


1. Data Source
Collects raw data from databases, sensors, applications, user inputs, or cloud storage.

2. Data Processing Layer


Prepares data before prediction by:
• Data cleaning
• Data transformation
• Feature engineering

3. Model Registry
Stores trained machine learning models with:
• Version control
• Metadata
• Lifecycle tracking
• Feature engineering

3. Model Registry
Stores trained machine learning models with:
• Version control
• Metadata
• Lifecycle tracking

4. Model Serving Layer


Makes the trained model available as a service through:
• REST APIs
• gRPC APIs
• Web services

5. Inference Engine
Receives processed input, executes the ML model, and generates predictions in real-time or batch
mode.

6. Monitoring System
Continuously monitors:
• Model accuracy
• Latency
• Data drift
• Failures
• System performance

7. Logging System
Stores:
• User requests
• Predictions
• Errors
• Performance logs
Useful for debugging and auditing.

8. CI/CD Pipeline
Automates:
• Model testing
• Deployment
• Updates
• Continuous integration and delivery

Workflow of ML Deployment Architecture


1. Data Collection – Gather data from different sources.
2. Data Preprocessing – Clean and prepare the data.
3. Feature Engineering – Select useful features.
4. Model Training – Train the ML algorithm.
5. Hyperparameter Tuning – Improve model performance.
6. Model Evaluation – Measure accuracy using evaluation metrics.
7. Model Deployment – Deploy the model to production.
8. Prediction (Inference) – Generate predictions on new data.
9. Monitoring & Retraining – Monitor performance and retrain when needed.

Workflow Diagram
Data Source

Data Processing

Feature Engineering

Model Training

Hyperparameter Tuning

Model Evaluation

Model Deployment

Prediction (Inference)

Monitoring & Retraining

Model Evaluation

Model Deployment

Prediction (Inference)

Monitoring & Retraining

3. Challenges in Deploying ML Models


Definition
Deploying machine learning models into production is more complex than traditional software because
models depend on continuously changing data, require regular updates, and must provide fast and
accurate predictions.

Major Challenges
1. Data Drift
The statistical properties of input data change over time, reducing model accuracy.
Example: Customer buying behavior changes during festivals.

2. Model Versioning
Managing multiple versions of trained models and enabling rollback when necessary.

3. Scalability Issues
The system must handle increasing numbers of users and prediction requests without affecting
performance.

4. Latency Constraints
Real-time applications require predictions within milliseconds.
Example: Fraud detection during online payments.

5. Integration Complexity
Integrating ML models with existing software, databases, APIs, and cloud platforms can be difficult.

6. Monitoring and Maintenance


Models must be continuously monitored for:
• Accuracy degradation
• Data drift
• Errors
• Performance issues
Regular retraining is required.

7. Security Risks
ML systems must protect:
• Sensitive user data
• Model APIs
• Unauthorized access
Security measures include authentication, authorization, and encryption.
1. Model Inference
Definition
Model Inference is the process of using a trained machine learning model to make predictions on new,
unseen data. After deployment, the model receives input data, processes it, and returns the predicted
output.

Inference Workflow
1. Input Data Received
New data is received from users, applications, sensors, APIs, or databases.
2. Data Preprocessing
The input data is cleaned, transformed, normalized, and converted into the format required by the
model.
3. Model Prediction
The trained model processes the input data and generates a prediction.
4. Output Generation
The prediction is returned to the user or application.
5. Logging & Monitoring
The input, prediction, response time, and errors are recorded to monitor model performance.

Workflow Diagram
Input Data

Data Preprocessing

Model Prediction

Output Generation

Logging & Monitoring

2. Types of Model Inference


A. Offline (Batch) Inference
Definition
In Offline (Batch) Inference, predictions are generated on large batches of data at scheduled intervals
instead of instantly.
Characteristics
• Batch processing
• High latency is acceptable
• Suitable for reports and analytics
• Cost-effective for large datasets
Example
• Daily product recommendations
• Monthly sales prediction
• End-of-day fraud analysis

B. Online (Real-Time) Inference


Definition
In Online (Real-Time) Inference, predictions are generated immediately whenever a request is received.
Characteristics
• Instant prediction
• Very low latency
• Used in live applications
• Requires continuous availability
B. Online (Real-Time) Inference
Definition
In Online (Real-Time) Inference, predictions are generated immediately whenever a request is received.
Characteristics
• Instant prediction
• Very low latency
• Used in live applications
• Requires continuous availability
Example
• Fraud detection during payment
• Face recognition
• Chatbots
• Product recommendations while shopping

Difference Between Offline and Online Inference


Feature Offline (Batch) Online (Real-Time)
Prediction Scheduled Instant
Speed Slow Fast
Latency High Very Low
Use Case Reports, Analytics Live Applications
Example Daily recommendation emails UPI fraud detection

3. How can we see the Input Data in Model Inference?


During inference, the input data comes from external sources such as:
• User input (forms, mobile apps)
• Sensors or IoT devices
• Databases
• APIs
• Web applications
The input data first goes to the Data Preprocessing stage, where it is cleaned and transformed before
being passed to the trained model.
Example:
• Input: Student Marks = 85
• Model: Pass/Fail Prediction Model
• Output: Pass
Or,
• Input: Transaction Amount = ₹50,000
• Model: Fraud Detection Model
• Output: Fraudulent / Genuine
So, the input data is received at the first stage of the inference workflow, then preprocessed, passed to
the model, and finally converted into predictions. All inputs and predictions can also be viewed through
the logging and monitoring system, which records requests and outputs for debugging and
performance tracking.

Serialization
Definition
Serialization is the process of converting a trained machine learning model (including its learned
parameters, architecture, and configuration) into a storable file or byte stream so that it can be saved,
transferred, and reused later without retraining.

What Gets Saved?


• Model architecture
• Learned parameters (weights, coefficients, biases)
• Hyperparameters (if included)
• Preprocessing pipeline (if saved together)

Why is Serialization Needed?


• Avoids retraining the model
• Saves computation time and cost
• Enables deployment in real-world applications
• Allows sharing of models across different systems
• Makes backup and storage easy

Serialization Process
1. Train the ML model.
• Avoids retraining the model
• Saves computation time and cost
• Enables deployment in real-world applications
• Allows sharing of models across different systems
• Makes backup and storage easy

Serialization Process
1. Train the ML model.
2. Convert the model into a byte stream/file.
3. Save it in a file format such as .pkl, .joblib, .h5, or .pt.
4. Store the file for future use.

Common File Formats


• .pkl – Pickle (Scikit-learn)
• .joblib – Large Scikit-learn models
• .h5 – TensorFlow/Keras
• .pt / .pth – PyTorch
• .onnx – Open Neural Network Exchange

Example
After training a fraud detection model, it is serialized and saved as [Link]. Later, the same file is
loaded into a banking application without retraining.

Deserialization
Definition
Deserialization is the process of loading a previously saved machine learning model from a file and
converting it back into a usable model in memory for making predictions.

Deserialization Process
1. Read the saved model file.
2. Convert the byte stream back into a model object.
3. Load the model into memory.
4. Use the model for prediction.

Why is Deserialization Needed?


• Enables real-time predictions
• Avoids retraining the model
• Speeds up deployment
• Reuses previously trained models
• Supports production applications

Challenges
• Compatibility issues between library versions
• Security risks from untrusted model files
• Missing dependencies during loading

Example
A saved [Link] file is loaded into a web application using Joblib or Pickle, allowing users to get
predictions instantly.

Difference Between Serialization and Deserialization


Serialization Deserialization
Converts a trained model into a storable file Converts a saved file back into a usable model
Saves the model to disk Loads the model into memory
Used after model training Used before model prediction
Avoids retraining Enables real-time prediction
Output: .pkl, .joblib, .h5, .pt Output: Ready-to-use ML model

Simple Example
• Serialization: Train a model → Save it as [Link].
• Deserialization: Load [Link] → Use it to predict new data.
Flow:
Training → Serialization → [Link] → Deserialization → Prediction
Simple Example
• Serialization: Train a model → Save it as [Link].
• Deserialization: Load [Link] → Use it to predict new data.
Flow:
Training → Serialization → [Link] → Deserialization → Prediction

Model Retraining
Introduction
Model Retraining is the process of training an already deployed machine learning model again using
new or updated data. It helps the model adapt to changes in data patterns and maintain high prediction
accuracy over time. Retraining is necessary because real-world data changes continuously, causing the
model's performance to degrade (known as data drift).

Prediction
After retraining, the model learns from the latest data and generates more accurate and reliable
predictions on new unseen data.
Example:
• A fraud detection model retrained with recent transaction data can detect new fraud patterns
more effectively.
• A recommendation system retrained with recent user activity provides better product
recommendations.

Accuracy
Over time, model accuracy may decrease because user behavior and data patterns change.
Retraining helps to:
• Improve prediction accuracy.
• Reduce errors caused by data drift.
• Adapt to new trends and patterns.
• Keep the model reliable in production.

Why is Model Retraining Useful?


• Maintains high model accuracy.
• Handles changing data (Data Drift).
• Improves prediction quality.
• Adapts to new business requirements.
• Keeps the deployed model up-to-date.
• Enhances overall system performance and reliability.

Example
A spam email detection model was trained using old email data. As spammers start using new
techniques, the model's accuracy decreases. By retraining the model with recent email data, it learns
the new spam patterns and improves its prediction accuracy.

Model Serving Architecture


Definition
Model Serving Architecture is the process of deploying a trained Machine Learning model so that it can
receive input data, process it, and return predictions to users or applications. It defines how the model
is made available for inference in a production environment.
General Flow:
Input Data → Deployed ML Model → Prediction
Input Data → Deployed ML Model → Prediction

Types of Model Serving Architecture


1. Batch Serving (Offline Inference)
Definition
In Batch Serving, data is collected over a period of time, processed in batches, and then sent to the
deployed ML model. The predictions are stored and used later.
Workflow
Stored Data

Batch Processing

ML Model

Predictions (Stored)

Characteristics
• Processes large amounts of data at once.
• Predictions are not generated immediately.
• Suitable for scheduled jobs.
Applications
• Monthly sales forecasting
• Daily recommendation generation
• Payroll processing
• Business analytics
Advantages
• Efficient for large datasets.
• Lower operational cost.
• Easy to manage.
Limitations
• High latency.
• Not suitable for real-time applications.

2. Online / Real-Time Serving


Definition
In Online or Real-Time Serving, the user sends a request with input data, and the deployed ML model
immediately processes it and returns a prediction.
Workflow
User Request

API (Flask/FastAPI)

ML Model

Prediction

Characteristics
• Instant predictions.
• Very low latency.
• Uses APIs for communication.
Applications

Prediction

Characteristics
• Instant predictions.
• Very low latency.
• Uses APIs for communication.
Applications
• Chatbots
• Fraud detection
• Face recognition
• Recommendation systems
Advantages
• Fast response.
• Real-time decision making.
• Better user experience.
Limitations
• Requires continuous availability.
• Higher infrastructure cost.

3. Edge Deployment
Definition
In Edge Deployment, the ML model runs directly on local devices such as smartphones, IoT devices, or
embedded systems instead of a cloud server.
Workflow
Sensor/Input

Local Device
(ML Model)

Prediction

Characteristics
• Prediction happens on the device itself.
• Does not require continuous internet.
• Very low latency.
Benefits
• Fast response.
• Offline operation.
• Better privacy and security.
• Reduced network usage.
Limitations
• Limited hardware resources.
• Smaller model size required.
• Difficult to update models.
Applications
• Face Unlock
• Self-driving cars
• Smart cameras
• IoT devices

4. Stream Deployment
Definition
In Stream Deployment, the ML model continuously processes incoming data streams and generates
predictions in real time.
Workflow
Continuous Data Stream

Stream Processing Engine

ML Model

Prediction

Characteristics
• Handles continuous real-time data.
• Processes events as they arrive.
• Suitable for high-speed applications.

ML Model

Prediction

Characteristics
• Handles continuous real-time data.
• Processes events as they arrive.
• Suitable for high-speed applications.
Applications
• Sensor monitoring
• Financial transaction analysis
• Stock market prediction
• Real-time traffic monitoring
Advantages
• Continuous prediction.
• Low latency.
• Suitable for live data.
Limitations
• Complex implementation.
• High computational requirements.

Comparison of Model Serving Architectures


Feature Batch Online (Real-Time) Edge Stream
Data Processing Batch One request at a time On-device Continuous stream
Prediction Delayed Immediate Immediate Continuous
Latency High Very Low Very Low Low
Internet Required No Yes Usually No Yes
Best For Reports, Analytics Live Applications IoT, Mobile Sensor & Financial Data
Example Sales Forecast Fraud Detection Face Unlock Stock Market Analysis

Security Consideration in Stored Model Files


Serialized model files, especially Pickle format, can be dangerous if they are loaded from untrusted sources.
During deserialization, the file may execute malicious code, which can lead to:
• System compromise
• Data theft
• Malware installation
Safe Practices
1. Trust Sources
○ Load model files only from trusted sources.
2. Sandboxing
○ Load and test models in a safe environment (e.g., Virtual Machine or Docker container).
3. Use Safer Formats
○ Consider safer formats such as JSON or ONNX instead of Pickle whenever possible.
4. Access Permissions
○ Apply proper access control and file permissions so that only authorized users can access or
modify model files.
Key Point: Never load serialized model files (especially Pickle files) from unknown or untrusted sources,
as they may execute harmful code during deserialization.

Architectural Patterns in ML Deployment


Definition
Architectural Patterns are different ways of designing and organizing a Machine Learning deployment system.
They define how the User Interface (UI), Backend, ML Model, and Database are connected and communicate
with each other. The choice of architecture depends on factors such as scalability, latency, complexity, and
workload.
The three main architectural patterns are:
Architectural Patterns in ML Deployment
Definition
Architectural Patterns are different ways of designing and organizing a Machine Learning deployment system.
They define how the User Interface (UI), Backend, ML Model, and Database are connected and communicate
with each other. The choice of architecture depends on factors such as scalability, latency, complexity, and
workload.
The three main architectural patterns are:
1. Monolithic Architecture
2. Microservices Architecture
3. Serverless Architecture

1. Monolithic Architecture
Definition
In Monolithic Architecture, all components of the application such as the User Interface (UI), Business Logic
(Backend), ML Model, and Database are bundled into a single application.
Architecture
-----------------------------------------
| UI | Business Logic | ML Model | Database |
-----------------------------------------
Working
• User sends a request.
• The application processes the request.
• The ML model generates a prediction.
• The result is returned to the user.
Characteristics
• Single deployable application.
• All components are tightly coupled.
• Easy communication between components.
Advantages
• Easy to develop and deploy.
• Low latency between components.
• Simple testing and debugging.
• Suitable for small applications.
Disadvantages
• Difficult to scale individual components.
• Any update requires redeploying the entire application.
• Failure in one component can affect the whole system.
• Difficult to maintain as the application grows.
Applications
• Small ML projects
• College projects
• Internal business applications

2. Microservices Architecture
Definition
In Microservices Architecture, the application is divided into small, independent services, where each service
performs a specific task and communicates with others using APIs.
Architecture
Frontend

API Gateway

ML Model Service

Database

Working
• User request goes to the API Gateway.
• The gateway forwards the request to the required service.
• The ML model service processes the input.
• Prediction is returned through the API Gateway.
Characteristics
• Independent services.
• API-based communication.
• Each service can be developed and deployed separately.
Advantages
• User request goes to the API Gateway.
• The gateway forwards the request to the required service.
• The ML model service processes the input.
• Prediction is returned through the API Gateway.
Characteristics
• Independent services.
• API-based communication.
• Each service can be developed and deployed separately.
Advantages
• Easy to scale individual services.
• Better fault isolation.
• Flexible technology choices.
• Faster development and deployment.
Disadvantages
• Complex architecture.
• Higher operational and maintenance cost.
• Network latency between services.
• Difficult service management.
Applications
• E-commerce platforms
• Banking systems
• Large enterprise applications
• Cloud-based ML services

3. Serverless Architecture
Definition
Serverless Architecture allows developers to deploy ML applications without managing servers. The cloud
provider automatically handles infrastructure, scaling, and resource management. Code runs only when
triggered by an event.
Architecture
User Request

Cloud Function (AWS Lambda)

ML Model

Prediction

Working
• User sends a request.
• A cloud function (e.g., AWS Lambda) is triggered.
• The function loads the ML model.
• The prediction is generated and returned.
• Resources are released after execution.
Characteristics
• Event-driven execution.
• Automatic scaling.
• No server management.
• Pay only for execution time.
Advantages
• No infrastructure management.
• Automatic scaling.
• Cost-effective (Pay-as-you-go).
• Fast deployment.
Disadvantages
• Cold start latency.
• Limited execution time.
• Vendor lock-in.
• Limited customization.
Applications
• Image processing
• Document processing
• Chatbots
• Event-driven ML applications

Comparison of Architectural Patterns


Feature Monolithic Microservices Serverless
Structure Single application Multiple independent services Event-driven cloud functions
• Image processing
• Document processing
• Chatbots
• Event-driven ML applications

Comparison of Architectural Patterns


Feature Monolithic Microservices Serverless
Structure Single application Multiple independent services Event-driven cloud functions
Scalability Difficult Easy Automatic
Maintenance Difficult for large apps Easy Easy
Deployment Entire application Individual services Cloud function
Cost Fixed Medium Pay-as-you-go
Best For Small projects Enterprise applications Cloud-native applications
Example College ML Project Amazon, Netflix AWS Lambda, Azure Functions

Selection of Architecture
Requirement Recommended Architecture
Small application Monolithic
Large scalable application Microservices
Event-driven or unpredictable workload Serverless
Real-time applications Microservices or Serverless
Cost optimization Serverless

1. Key Requirements for ML Deployment Systems


Definition
A successful Machine Learning Deployment System should provide fast, accurate, secure, and reliable
predictions while handling a large number of users and requests. The four key requirements are Scalability,
Latency, Reliability, and Security.

1. Scalability
Definition
Scalability is the ability of an ML system to handle increasing workloads, users, data, or prediction requests
without reducing performance.
Achieved Using
• Cloud Infrastructure
• Auto-Scaling
• Load Balancing
Example
An e-commerce website receives millions of users during a festival sale. The deployment system
automatically increases computing resources to handle the traffic.
Importance
• Handles high traffic
• Improves performance
• Supports business growth

2. Latency
Definition
Latency is the time taken by the deployed model to return a prediction after receiving a request.
Characteristics
• Very important for real-time applications
• Lower latency means faster predictions
Example
A fraud detection system must identify fraudulent transactions within milliseconds.
Importance
• Faster response time
• Better user experience
• Essential for real-time decision-making
• Very important for real-time applications
• Lower latency means faster predictions
Example
A fraud detection system must identify fraudulent transactions within milliseconds.
Importance
• Faster response time
• Better user experience
• Essential for real-time decision-making

3. Reliability
Definition
Reliability is the ability of an ML deployment system to operate continuously without failures and provide
consistent predictions.
Includes
• High Availability
• Fault Tolerance
• Disaster Recovery
Example
A hospital's disease prediction system should remain available 24×7 without downtime.
Importance
• Continuous service
• Reduced downtime
• Consistent performance

4. Security
Definition
Security protects the ML model, data, APIs, and users from unauthorized access and cyber attacks.
Security Measures
• Authentication & Authorization
• Data Encryption
• Secure APIs
• Access Control
Example
A banking ML system encrypts customer data and allows only authorized users to access prediction APIs.
Importance
• Protects sensitive data
• Prevents cyber attacks
• Ensures data privacy

Summary Table
Requirement Description Example
Scalability Handles increasing users and requests E-commerce website during sales
Latency Fast prediction response time Fraud detection
Reliability Continuous operation with minimal downtime Hospital ML system
Security Protects data and APIs Banking applications

2. Model Deployment Implementations


Definition
Model Deployment Implementation is the process of making a trained ML model available in a production
environment so that applications and users can access it to generate predictions. Depending on the
application requirements, different deployment methods are used.

Types of Model Deployment Implementations


1. API-Based Deployment
Definition
In API-Based Deployment, the trained model is wrapped inside a REST API or web service so that applications
can send input data and receive predictions.
Steps
1. Save the trained model.
2. Build an API using Flask, FastAPI, or Django.
3. Send requests with input data.
4. Return predictions to the application.
Example
Definition
In API-Based Deployment, the trained model is wrapped inside a REST API or web service so that applications
can send input data and receive predictions.
Steps
1. Save the trained model.
2. Build an API using Flask, FastAPI, or Django.
3. Send requests with input data.
4. Return predictions to the application.
Example
A mobile banking app sends customer details to a fraud detection API and instantly receives a prediction.
Advantages
• Real-time predictions
• Easy integration
• Supports multiple applications

2. Container-Based Deployment
Definition
In Container-Based Deployment, the model and all its dependencies are packaged into a container, ensuring
consistent execution across different environments.
Tools
• Docker
• Kubernetes
Benefits
• Easy deployment
• High portability
• Automatic scaling
• Consistent environment
Example
A recommendation system is packaged in a Docker container and deployed on multiple cloud servers.

3. Cloud-Based Deployment
Definition
In Cloud-Based Deployment, the trained model is hosted on cloud platforms that provide scalable
infrastructure and services for prediction.
Common Cloud Platforms
• Amazon Web Services (AWS)
• Microsoft Azure
• Google Cloud Platform (GCP)
Steps
1. Package the trained model.
2. Upload it to the cloud.
3. Deploy using cloud services.
4. Integrate with web or mobile applications.
5. Monitor and update the model.
Example
A hospital deploys its disease prediction model on AWS so doctors can access predictions from anywhere.

Steps in Model Deployment


1. Model Packaging – Save the trained model (.pkl, .h5, etc.).
2. Prediction Interface – Create an API or application interface.
3. Deploy Infrastructure – Host the model on servers or cloud.
4. Application Integration – Connect the model with web/mobile applications.
5. Monitoring & Maintenance – Monitor performance and retrain when necessary.

Comparison of Deployment Implementations


Feature API-Based Container-Based Cloud-Based
Purpose Expose model through API Package model with dependencies Host model on cloud
Tools Flask, FastAPI, Django Docker, Kubernetes AWS, Azure, GCP
Best For Real-time applications Portable deployment Large-scale cloud systems
Scalability Medium High Very High
Example Fraud Detection API Dockerized ML App AWS SageMaker Deployment

You might also like