NN Bnu3
NN Bnu3
Networks
Lecture (3) _ Learning Schemes
Learning Schemes
Learning is the process by which a neural system acquires ability to carry out certain
tasks by adjusting its internal parameters according to some learning scheme.
Depending on the particular neural architecture considered, learning can be supervised,
unsupervised or reinforced.
                                      Learning Schemes
                                         2
                                                                                          2
Neural Networks
Learning Schemes
                       3
    Neural Networks
    Learning Schemes
In a Neural Network, the learning (or training) process is initiated by dividing the data into three
different sets:
•     Training dataset – This dataset allows the Neural Network to understand the weights between
      nodes.
•     Validation dataset – This dataset is used for fine-tuning the performance of the Neural Network.
•     Test dataset – This dataset is used to determine the accuracy and margin of error of the Neural
      Network.
                                                 4
Once the data is segmented into these three parts, Neural Network algorithms are applied to them for
training the Neural Network. The procedure used for facilitating the training process in a Neural
Network is known as the optimization, and the algorithm used is called the optimizer. There are
different types of optimization algorithms, each with their unique characteristics and aspects such as
memory requirements, numerical precision, and processing speed.
                                                                                                         4
 Neural Networks
Learning Schemes
Supervised Learning
As the name suggests, this type of learning is done under the supervision of a teacher.
This learning process is dependent.
With supervised learning, the algorithm is given a set of particular targets to aim for.
Supervised learning uses labeled data set, one that contains matched sets of observed
inputs, X’s, and the associated outputs, Y’s. The algorithm is “trained,” i.e., the machine
learning algorithm is applied to this data set to infer the patterns between the inputs and
                                         5
outputs. In other words, the algorithm works out fin the equation:
                                         Y=f (X )
The dependent variable (Y ) is the target, while the independent variables (X’s) are
known as features.
                                                                                              5
 Neural Networks
Learning Schemes
Supervised Learning
During the training of ANN under supervised learning,
1. The input vector is presented to the network, which will give an output vector.
2. This output vector is compared with the desired output vector.
3. An error signal is generated, if there is a difference between the actual output and the
   desired output vector.
                                         6
4. Depending on this error signal, the weights are adjusted until the actual output is
   matched with the desired output.
                                                                                              6
 Neural Networks
Learning Schemes
Supervised Learning
Types of Supervised Learning
Supervised learning can be categorized into two problems, depending on the nature of
the target (Y) variable. These include classification and regression.
Classification focuses on sorting observations into distinct categories. It is when the
target (Y) is a category, such as “blue” or “red” or “disease” and “no disease.” An
example of a classification problem is a spam filter that classifies emails into two
                                         7
    Learning Schemes
Supervised Learning
Supervised learning deals with or learns with “labeled” data. This implies that some data is already tagged
with the correct answer.
                                                                                                              8
Neural Networks
Learning Schemes
Supervised Learning
                          9
Neural Networks
Learning Schemes
Supervised Learning
1- Regression                                                2- Classification
Regression is a type of supervised learning that is used     Classification is a type of supervised learning that is used
to predict continuous values, such as house prices,          to predict categorical values, such as whether a customer
stock prices, or customer churn. Regression algorithms       will churn or not, whether an email is spam or not, or
learn a function that maps from the input features to the    whether a medical image shows a tumor or not.
output value.                                                Classification algorithms learn a function that maps from
Some common regression algorithms include:                   the input features to a probability distribution over the
                                                             output classes.
•   Linear Regression                                   10
    Learning Schemes
Supervised Learning
Evaluating Supervised Learning Models
Evaluating supervised learning models is an important step in ensuring that the model is accurate and
generalizable. There are a number of different metrics that can be used to evaluate supervised learning
models, but some of the most common ones include:
For Regression
•    Mean Squared Error (MSE): MSE measures the average squared difference between the predicted
     values and the actual values. Lower MSE values indicate better model performance.
•    Root Mean Squared Error (RMSE): RMSE is the square root of MSE, representing the standard
                                                 11
     deviation of the prediction errors. Similar to MSE, lower RMSE values indicate better model
     performance.
•    Mean Absolute Error (MAE): MAE measures the average absolute difference between the predicted
     values and the actual values. It is less sensitive to outliers compared to MSE or RMSE.
•    R-squared (Coefficient of Determination): R-squared measures the proportion of the variance in the
     target variable that is explained by the model. Higher R-squared values indicate better model fit.
                                                                                                          11
    Neural Networks
Learning Schemes
Supervised Learning
For Classification
•     Accuracy: Accuracy is the percentage of predictions that the model makes correctly. It is calculated by
      dividing the number of correct predictions by the total number of predictions.
•     Precision: Precision is the percentage of positive predictions that the model makes that are actually
      correct. It is calculated by dividing the number of true positives by the total number of positive
      predictions.
•     Recall: Recall is the percentage of all positive examples that the model correctly identifies. It is
      calculated by dividing the number of true positives
                                                    12
                                                          by the total number of positive examples.
•     F1 score: The F1 score is a weighted average of precision and recall. It is calculated by taking the
      harmonic mean of precision and recall.
•     Confusion matrix: A confusion matrix is a table that shows the number of predictions for each
      class, along with the actual class labels. It can be used to visualize the performance of the model and
      identify areas where the model is struggling.
                                                                                                                12
    Neural Networks
Learning Schemes
Supervised Learning
Applications of Supervised learning
Supervised learning can be used to solve a wide variety of problems, including:
•     Spam filtering: Supervised learning algorithms can be trained to identify and classify spam emails based on their
      content, helping users avoid unwanted messages.
•     Image classification: Supervised learning can automatically classify images into different categories, such as animals,
      objects, or scenes, facilitating tasks like image search, content moderation, and image-based product
      recommendations.
•     Medical diagnosis: Supervised learning can assist in medical diagnosis by analyzing patient data, such as medical
      images, test results, and patient history, to identify patterns that suggest specific diseases or conditions.
•     Fraud detection: Supervised learning models can analyze financial transactions and identify patterns that indicate
      fraudulent activity, helping financial institutions prevent fraud and protect their customers.
•     Natural language processing (NLP): Supervised learning plays a crucial role in NLP tasks, including sentiment analysis,
      machine translation, and text summarization, enabling machines to understand and process human language
      effectively.
                                                                                                                                13
    Neural Networks
    Learning Schemes
Supervised Learning
 Learning Schemes
Unsupervised Learning
What is Unsupervised learning?
Unsupervised learning is a type of machine learning that learns from unlabeled data. This means that the
data does not have any pre-existing labels or categories. The goal of unsupervised learning is to discover
patterns and relationships in the data without any explicit guidance.
Unsupervised learning is the training of a machine using information that is neither classified nor labeled
and allowing the algorithm to act on that information without guidance. Here the task of the machine is
to group unsorted information according to similarities, patterns, and differences without any prior
training of data.
Unlike supervised learning, no teacher is provided that means no training will be given to the machine.
Therefore, the machine is restricted to find the hidden structure in unlabeled data by itself.
You can use unsupervised learning to examine the animal data that has been gathered and distinguish
between several groups according to the traits and actions of the animals. These groupings might
correspond to various animal species, providing you to categorize the creatures without depending on
labels that already exist.                                                                                    15
     Neural Networks
 Learning Schemes
Unsupervised Learning
In this paradigm the neural network is only given a set of inputs and it’s the neural network’s
responsibility to find some kind of pattern within the inputs provided without any external aid.
During the training of ANN under unsupervised learning,
1.      The input vectors of similar type are combined to form clusters.
2.      When a new input pattern is applied, then the neural network gives an output response indicating the
        class to which the input pattern belongs.
Hence, in this type of learning, the network itself must discover the patterns and features from the input
data, and the relation for the input data over the output.
This type of learning paradigm is often used in data mining and is also used by many recommendation
algorithms due to their ability to predict a user's preferences based on the preferences of other similar
users it has grouped together.
                                                                                                               16
 Neural Networks
Learning Schemes
Unsupervised Learning
Types of Unsupervised Learning
Two essential types of unsupervised learning are dimension reduction and clustering.
Dimension reduction refers to reducing the number of inputs (features) while retaining
variation across observations to maintain structure and usefulness of the information contained
in the variation. For example, data scientists reduce the number of dimensions in an extensive
data set to simplify modeling and reduce file size.
                                                                                                  17
 Neural Networks
                             Learning Schemes
Unsupervised Learning
Types of Unsupervised Learning
On the other hand, clustering is a type of unsupervised learning that is used to group similar
data points together. Clustering algorithms work by iteratively moving data points closer to their
cluster centers and further away from data points in other clusters.
1.Exclusive (partitioning)
2.Agglomerative                         Clustering Types:-
                                        1.Hierarchical clustering
3.Overlapping                           2.K-means clustering
4.Probabilistic                         3.Principal Component Analysis
                                        4.Singular Value Decomposition
                                        5.Independent Component Analysis
                                        6.Gaussian Mixture Models (GMMs)
                                        7.Density-Based Spatial Clustering of Applications with
                                        Noise (DBSCAN)
                                                                                                     18
    Neural Networks
                            Learning Schemes
Unsupervised Learning
Key Points
•   Unsupervised learning allows the model to discover patterns and relationships in
    unlabeled data.
•   Clustering algorithms group similar data points together based on their inherent
    characteristics.
•   Feature extraction captures essential information from the data, enabling the model to
    make meaningful distinctions.
•   Label association assigns categories to the clusters based on the extracted patterns and
    characteristics.
                                                                                               19
Neural Networks
Learning Schemes
Unsupervised Learning
20
Clustering
                                     20
 Neural Networks
                                       Learning Schemes
Unsupervised Learning
Evaluating Non-Supervised Learning Models
Evaluating non-supervised learning models is an important step in ensuring that the model is effective and useful. However, it can be
more challenging than evaluating supervised learning models, as there is no ground truth data to compare the model’s predictions to.
There are a number of different metrics that can be used to evaluate non-supervised learning models, but some of the most common
ones include:
•Silhouette score: The silhouette score measures how well each data point is clustered with its own cluster members and separated
from other clusters. It ranges from -1 to 1, with higher scores indicating better clustering.
•Calinski-Harabasz score: The Calinski-Harabasz score measures the ratio between the variance between clusters and the variance
within clusters. It ranges from 0 to infinity, with higher scores indicating better clustering.
•Adjusted Rand index: The adjusted Rand index measures the similarity between two clusterings. It ranges from -1 to 1, with
higher scores indicating more similar clusterings.
•Davies-Bouldin index: The Davies-Bouldin index measures the average similarity between clusters. It ranges from 0 to
infinity, with lower scores indicating better clustering.
•F1 score: The F1 score is a weighted average of precision and recall, which are two metrics that are commonly used in supervised
learning to evaluate classification models. However, the F1 score can also be used to evaluate non-supervised learning models, such
as clustering models.
                                                                                                                                        21
 Neural Networks
                             Learning Schemes
Unsupervised Learning
Application of Unsupervised learning
Non-supervised learning can be used to solve a wide variety of problems, including:
•Anomaly detection: Unsupervised learning can identify unusual patterns or deviations from
normal behavior in data, enabling the detection of fraud, intrusion, or system failures.
•Scientific discovery: Unsupervised learning can uncover hidden relationships and patterns in
scientific data, leading to new hypotheses and insights in various scientific fields.
•Recommendation systems: Unsupervised learning can identify patterns and similarities in user
behavior and preferences to recommend products, movies, or music that align with their interests.
•Customer segmentation: Unsupervised learning can identify groups of customers with similar
characteristics, allowing businesses to target marketing campaigns and improve customer service
more effectively.
•Image analysis: Unsupervised learning can group images based on their content, facilitating tasks
such as image classification, object detection, and image retrieval.
                                                                                                     22
 Neural Networks
                                   Learning Schemes
Unsupervised Learning
                                                                                                                      23
Neural Networks
                          Learning Schemes
                  Supervised vs Unsupervised Learning
                                                        24
Neural Networks
                          Learning Schemes
                  Supervised vs Unsupervised Learning
                                                        25
Neural Networks
                                     Learning Schemes
                            Supervised vs Unsupervised Learning
            Parameters            Supervised machine learning                Unsupervised machine
                                                                                   learning
                                 Algorithms are trained using labeled     Algorithms are used against data
            Input Data
                                                data.                            that is not labeled
   Computational Complexity                Simpler method                     Computationally complex
              Accuracy                     Highly accurate                          Less accurate
           No. of classes               No. of classes is known             No. of classes is not known
           Data Analysis                  Uses offline analysis            Uses real-time analysis of data
                                   Linear and Logistics regression,
                                   KNN Random forest, multi-class
                                                                          K-Means clustering, Hierarchical
          Algorithms used        classification, decision tree, Support
                                                                          clustering, Apriori algorithm, etc.
                                  Vector Machine, Neural Network,
                                                   etc.
                                                                                                             27
 Neural Networks
                               Learning Schemes
Deep Learning and Reinforcement Learning
Deep learning and reinforcement learning functions enable a computer to develop rules
on its own to solve problems.
Deep learning is a self-teaching system in which the existing data is used to train
algorithms to establish patterns and then use that to make predictions about new data.
Highly complex tasks, such as image classification, face recognition, speech
recognition, and natural language processing, are addressed by sophisticated algorithms.
                                                                                           28
    Neural Networks
                                        Learning Schemes
Reinforcement Learning
Reinforcement Learning (RL) is a branch of machine learning focused on making decisions to
maximize cumulative rewards in a given situation. Unlike supervised learning, which relies on a
training dataset with predefined answers, RL involves learning through experience. In RL, an agent
learns to achieve a goal in an uncertain, potentially complex environment by performing actions
and receiving feedback through rewards or penalties.
Key Concepts of Reinforcement Learning
•    Agent: The learner or decision-maker.
•    Environment: Everything the agent interacts with.
•    State: A specific situation in which the agent finds itself.
•    Action: All possible moves the agent can make.
•    Reward: Feedback from the environment based on the action taken.
                                                                                                     29
 Neural Networks
                               Learning Schemes
Reinforcement Learning
Reinforcement learning is similar to supervised learning in that some feedback is given,
however instead of providing a target output a reward is given based on how well the
system performed.
The aim of reinforcement learning is to maximize the reward the system receives
through trial-and-error.
This paradigm relates strongly with how learning works in nature, for example an
animal might remember the actions it’s previously taken which helped it to find food
(the reward).
In reinforcement learning, a computer learns from trial and error. It learns dynamically
by adjusting actions based on continuous feedback to maximize an outcome.
                                                                                           30
    Neural Networks
                                       Learning Schemes
Reinforcement Learning
                                                                                             34
Neural Networks
                                  Learning Schemes
Reinforcement Learning
 Difference between Reinforcement learning and Supervised learning:
                                                                                                    39
Neural Networks
                                                           Error Signal
                                                                                   D (Desired output)
                                                            Generator
  Learning Schemes
                                           Neural
                     X (input)                                            Y (Actual output)
                                          Network
Unsupervised
40
                                                           Error Signal
                                                                                     R (Reinforcement signal)
                                                            Generator
                                                                                                                40
Neural Networks
41
                       41
Neural Networks
42