Machine Learning Note Modul 4 5[1]
Machine Learning Note Modul 4 5[1]
Mishra, Dept-CSE
Introduction to Unsupervised Learning
- Unsupervised Learning is a type of Machine Learning where the model is trained on unlabeled data.
- The goal is to identify patterns, structures, or relationships in data without predefined labels.
2. What is Clustering?
- Clustering is the process of grouping a set of objects in such a way that objects in the same group (cluster)
are more similar to each other than to those in other groups.
3. Applications of Clustering
- Image segmentation
- Document categorization
- Recommender systems
a. Partition-Based Clustering
- Divides the data into non-overlapping subsets (clusters) without any hierarchical structure.
b. Hierarchical Clustering
c. Density-Based Clustering
- Groups data points based on regions of high density separated by regions of low density.
1
By:- B.P.Mishra, Dept-CSE
d. Model-Based Clustering
Steps in K-Means:
5. Repeat steps 3 and 4 until convergence (when centroids no longer change significantly).
Pros:
Cons:
2. Merge the two closest clusters based on a similarity measure (e.g., Euclidean distance).
7. DBSCAN Algorithm
Steps in DBSCAN:
1. Define parameters: **Epsilon (ε)** (radius of neighborhood) and **MinPts** (minimum points required
to form a dense region).
2
By:- B.P.Mishra, Dept-CSE
3. Expand clusters from core points if they have enough neighbors.
Pros:
Cons:
- Silhouette Score: Measures how similar a point is to its cluster compared to other clusters.
Elbow Method (for K-Means): Helps find the optimal number of clusters.
Association Rule Mining is used to discover relationships between variables in large datasets.
It is widely used in market basket analysis, web usage mining, and medical diagnosis.
a. Key Terminology
b. Apriori Algorithm
Steps:
c. FP-Growth Algorithm
Faster alternative to Apriori that uses a tree-based structure to mine frequent itemsets.
Constructs a Frequent Pattern Tree (FP-Tree) to store compressed information.
3
By:- B.P.Mishra, Dept-CSE
9. Evaluation of Clustering & Association Rule Algorithms
Clustering:
o Silhouette Score: Measures how similar a point is to its cluster compared to other clusters.
o Davies-Bouldin Index: Lower values indicate better clustering.
o Dunn Index: Higher values indicate better clustering.
o Elbow Method (for K-Means): Helps find the optimal number of clusters.
Association Rules:
o Support: Measures frequency of an itemset.
o Confidence: Measures the strength of the rule.
o Lift: Measures how much more likely items occur together compared to random chance.
10. Conclusion
Clustering and Association Rule Mining are fundamental techniques in unsupervised learning.
Different clustering algorithms are suited for different types of data.
Association rules help find hidden relationships in data, improving decision-making.
Clustering is the process of grouping a set of objects in such a way that objects in the same group
(cluster) are more similar to each other than to those in other groups.
a. Partition-Based Clustering
4
By:- B.P.Mishra, Dept-CSE
Example: K-Means Clustering
b. Hierarchical Clustering
c. Density-Based Clustering
d. Model-Based Clustering
Association Rule Mining is used to discover relationships between variables in large datasets.
Used in market basket analysis, web usage mining, and medical diagnosis.
Key Terminology
Algorithms
Apriori Algorithm
1. Identify frequent itemsets using a minimum support threshold.
2. Generate candidate itemsets by joining frequent itemsets.
3. Filter itemsets using minimum support and confidence thresholds.
4. Extract strong association rules.
FP-Growth Algorithm
o Uses a tree-based structure to mine frequent itemsets.
o Constructs a Frequent Pattern Tree (FP-Tree) to store compressed information.
9. Evaluation Metrics
For Clustering
Silhouette Score: Measures how similar a point is to its cluster compared to other clusters.
Davies-Bouldin Index: Lower values indicate better clustering.
Dunn Index: Higher values indicate better clustering.
Elbow Method (for K-Means): Helps find the optimal number of clusters.
5
By:- B.P.Mishra, Dept-CSE
Confidence: Measures the strength of the rule.
Lift: Measures how much more likely items occur together compared to random chance.
The Apriori algorithm is used for mining frequent itemsets and discovering association rules in
large datasets.
It is commonly applied in market basket analysis, where it helps find associations between items
frequently bought together.
Key Terminology
9. Evaluation Metrics
6
By:- B.P.Mishra, Dept-CSE
For Clustering
Silhouette Score: Measures how similar a point is to its cluster compared to other clusters.
Davies-Bouldin Index: Lower values indicate better clustering.
Dunn Index: Higher values indicate better clustering.
Elbow Method (for K-Means): Helps find the optimal number of clusters.
Conclusion
Supervised Learning is used when labeled data is available and the goal is prediction.
Unsupervised Learning is used when patterns and relationships need to be discovered without
predefined labels.
Clustering is a fundamental technique in unsupervised learning, with various algorithms suitable for
different data types.
Apriori Algorithm is widely used for discovering association rules in large datasets, improving
decision-making in retail, healthcare, and finance.
7
By:- B.P.Mishra, Dept-CSE
Neural networks are inspired by the functioning of the human brain. The foundation of artificial neural
networks (ANNs) lies in understanding biological neurons and their connections. This class note explores
the biological neuron, its structure, and its role in neural computations, which serve as the basis for
designing artificial neurons in machine learning.
A biological neuron, or nerve cell, is the fundamental unit of the nervous system. The brain consists of
approximately 86 billion neurons, which communicate through electrical and chemical signals to process
information.
Dendrites: These are tree-like extensions that receive signals from other neurons.
Cell Body (Soma): It contains the nucleus and essential organelles for the cell's functioning.
Axon: A long, thin fiber that transmits electrical impulses away from the cell body to other neurons
or muscles.
Axon Terminals: These are branched endings of the axon that release neurotransmitters to
communicate with other neurons.
Synapse: The junction between two neurons where signal transmission occurs.
The operation of a neuron can be understood in terms of signal reception, processing, and transmission:
1. Signal Reception: Neurons receive signals (excitatory or inhibitory) through dendrites from other
neurons.
2. Integration: The soma integrates incoming signals and determines whether the threshold is met to
trigger an action potential.
3. Signal Transmission: If the threshold is reached, an action potential (electrical impulse) is
generated and propagates along the axon.
4. Synaptic Transmission: The action potential reaches the axon terminals, leading to the release of
neurotransmitters that influence the next neuron.
Sensory Neurons: Detect stimuli from the environment and send signals to the brain and spinal
cord.
Motor Neurons: Transmit commands from the brain to muscles and glands.
Interneurons: Connect sensory and motor neurons, facilitating communication within the nervous
system.
Artificial neural networks (ANNs) are inspired by the structure and function of biological neurons. In ANN
models, artificial neurons (also called perceptrons) mimic the way biological neurons receive, process, and
transmit information.
Processing
Chemical transmission at synapses Weighted summation & activation function
Method
4. Conclusion
Understanding the biological neuron provides insight into how artificial neural networks are designed.
While biological neurons operate through chemical and electrical processes, artificial neurons use
mathematical functions to process data. The inspiration drawn from neuroscience has led to the
development of sophisticated AI models capable of learning and making decisions like the human brain.
9
By:- B.P.Mishra, Dept-CSE
References
1. Bear, M. F., Connors, B. W., & Paradiso, M. A. (2015). Neuroscience: Exploring the Brain.
2. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning.
3. McCulloch, W. S., & Pitts, W. (1943). A Logical Calculus of Ideas Immanent in Nervous Activity.
Activation functions play a crucial role in artificial neural networks by introducing non-linearity, enabling
the model to learn complex patterns. Some common types of activation functions include:
1. Step Function:
o Output is binary (0 or 1) based on a threshold.
o Used in early perceptron models.
10
By:- B.P.Mishra, Dept-CSE
6.Softmax Function:
Introduction
Artificial Neural Networks (ANNs) are computational models inspired by the human brain’s neural
structure. Early implementations of ANNs laid the foundation for modern deep learning techniques. The
development of ANNs can be traced back to the 1940s and has undergone significant evolution.
Historical Background
Early Implementations
1. Single-Layer Perceptron
o Architecture: One layer of neurons with adjustable weights.
o Learning: Used a simple weight update rule based on error correction.
o Limitation: Could not solve problems requiring non-linear decision boundaries.
2. Adaline and Madaline (1960s)
o Adaline (Adaptive Linear Neuron): Developed by Bernard Widrow and Marcian Hoff.
Used a continuous activation function instead of a binary one.
Trained using the Least Mean Squares (LMS) algorithm.
o Madaline (Multiple Adaptive Linear Neurons): The first neural network applied to real-
world problems, such as pattern recognition.
3. Multilayer Perceptron (MLP) and Backpropagation (1970s-1980s)
11
By:- B.P.Mishra, Dept-CSE
o Researchers realized that single-layer networks had limitations.
o Backpropagation Algorithm: Developed independently by Paul Werbos (1974) and later
popularized by Rumelhart, Hinton, and Williams (1986).
o Allowed training of multilayer networks by propagating errors backward to adjust weights.
o Enabled ANNs to learn complex patterns and solve problems like XOR.
AI Winter (1970s-1980s): Interest in ANNs declined due to computational limitations and lack of
training methods for deep networks.
Resurgence (1990s-Present): With increased computing power, availability of large datasets, and
advances in learning algorithms (e.g., deep learning), ANNs became widely used in image
recognition, speech processing, and more.
Conclusion
The early implementations of artificial neural networks laid the groundwork for today’s sophisticated AI
models. Despite initial challenges, continuous advancements in learning algorithms and computational
power have led to their widespread adoption in modern applications.
1. Introduction
A neural network architecture defines how neurons are organized and connected within a network. The
choice of architecture significantly impacts the model’s performance, complexity, and suitability for specific
tasks.
1. Input Layer: Takes input features and passes them to the next layer.
2. Hidden Layers: Intermediate layers that extract patterns and representations.
3. Output Layer: Produces final predictions or classifications.
4. Activation Functions: Non-linear functions applied at each node to introduce complexity.
5. Weights & Biases: Parameters adjusted during training to optimize predictions.
6. Connections: Define how neurons from different layers communicate (fully connected,
convolutional, recurrent, etc.).
12
By:- B.P.Mishra, Dept-CSE
Applications: Image classification, object detection, facial recognition.
3.4 Autoencoders
CNN-RNN: Uses CNN for feature extraction and RNN for sequence modeling (e.g., video
captioning).
Attention-based RNNs: Combine attention mechanisms with RNNs for better sequence modeling.
5. Conclusion
Neural network architectures are tailored to specific problem domains. Understanding these architectures
helps in selecting the right model for tasks like image recognition, speech processing, or NLP.
13
By:- B.P.Mishra, Dept-CSE
Learning Process in Artificial Neural Networks (ANNs)
1. Introduction
Artificial Neural Networks (ANNs) are computing models inspired by biological neural networks. The
learning process in ANNs is a crucial aspect that enables them to recognize patterns, make predictions, and
improve performance over time. The learning process involves adjusting weights and biases based on input
data and feedback mechanisms.
The learning process in ANNs can be broadly categorized into three types:
a. Supervised Learning
b. Unsupervised Learning
c. Reinforcement Learning
The network learns through interaction with an environment and receives rewards or penalties.
Used in sequential decision-making tasks.
Examples: Game playing (e.g., AlphaGo) and robotics.
Algorithms used:
o Q-Learning
o Deep Q Networks (DQN)
o Policy Gradient Methods
The learning process in an ANN involves adjusting weights and biases to minimize error. The key learning
mechanisms include:
a. Forward Propagation
14
By:- B.P.Mishra, Dept-CSE
Inputs pass through the network layer by layer.
Each neuron applies an activation function to produce an output.
The final output is compared with the expected output to compute the error.
b. Error Calculation
The difference between predicted and actual output is measured using a loss function.
Common loss functions include:
o Mean Squared Error (MSE)
o Cross-Entropy Loss
c. Backpropagation
Backpropagation (backward propagation of errors) updates weights using the error gradient.
Steps:
1. Compute error at the output layer.
2. Propagate error backward through hidden layers.
3. Adjust weights using gradient descent.
Gradient Descent Variants:
o Batch Gradient Descent
o Stochastic Gradient Descent (SGD)
o Mini-Batch Gradient Descent
o Adam Optimizer
15
By:- B.P.Mishra, Dept-CSE
Mean Absolute Error (MAE), Mean Squared Error (MSE) (for regression problems)
Confusion Matrix (for visualizing classification results)
7. Conclusion
The learning process in ANNs is fundamental to their effectiveness in solving complex problems.
Understanding supervised, unsupervised, and reinforcement learning, along with key mechanisms like
backpropagation and gradient descent, helps in designing efficient neural networks. Addressing challenges
like over fitting, under fitting, and computational efficiency ensures better model performance.
Backpropagation Algorithm
Steps of Backpropagation
1. Forward Propagation:
o Inputs pass through the neural network layer by layer.
o Activation functions apply transformations.
o The output layer generates predictions.
2. Compute Error:
o Calculate the loss function (e.g., Mean Squared Error or Cross-Entropy Loss) comparing
predictions with actual values.
3. Backward Propagation:
o Compute the gradient of the loss function concerning each weight using the chain rule.
o Update the weights and biases using the gradient descent algorithm.
16
By:- B.P.Mishra, Dept-CSE
Challenges
Vanishing Gradient Problem: Occurs with sigmoid/tanh activation functions, causing slow
learning.
Exploding Gradient Problem: Large weight updates lead to instability.
Overfitting: Requires techniques like dropout and regularization.
17
By:- B.P.Mishra, Dept-CSE
Conclusion
Backpropagation is essential for training deep learning models. Understanding its mechanics helps in
optimizing neural network performance.
Deep Learning (DL) is a subset of Machine Learning (ML) that uses neural networks with multiple layers to
model complex patterns in data. It is inspired by the structure and function of the human brain and has
achieved significant breakthroughs in fields like computer vision, natural language processing, and robotics.
A deep neural network consists of multiple layers of interconnected neurons. The key components are:
Neurons: Fundamental units that take input, apply weights, biases, and activation functions to
produce an output.
Weights and Biases: Parameters that adjust during training to minimize error.
Activation Functions: Introduce non-linearity to the network, helping it learn complex
representations.
o Sigmoid
o Tanh
o ReLU (Rectified Linear Unit)
o Leaky ReLU
o Softmax
Loss Function: Measures the difference between predicted and actual values.
Optimizer: Algorithm that updates weights to minimize loss (e.g., SGD, Adam, RMSProp).
Backpropagation: A method for updating weights by calculating the gradient of the loss function
with respect to each weight.
Deep learning models vary depending on the problem type. The major architectures include:
18
By:- B.P.Mishra, Dept-CSE
Used for sequential data like time series and natural language.
Has memory cells that retain past information.
Types of RNNs:
o Simple RNN
o Long Short-Term Memory (LSTM)
o Gated Recurrent Unit (GRU)
d. Transformer Models
f. Autoencoders
1. Data Preparation: Collecting, cleaning, and preprocessing data (e.g., normalization, augmentation).
2. Model Selection: Choosing the right architecture based on the problem.
3. Hyperparameter Tuning: Adjusting parameters like learning rate, batch size, and number of layers.
4. Training: Using optimization techniques to update weights.
5. Evaluation: Testing performance using metrics like accuracy, precision, recall, and F1-score.
6. Deployment: Deploying trained models into production environments.
8. Conclusion
Deep learning continues to evolve, enabling advancements in artificial intelligence. Understanding its
fundamental principles and architectures is crucial for leveraging its potential in various domains.
20