0% found this document useful (0 votes)
3 views34 pages

Machine Learning Module 1

The document discusses various issues in machine learning, including data challenges, overfitting, algorithm selection, interpretability, and ethical concerns. It also outlines the systematic steps for developing a machine learning application, from problem definition to monitoring and maintenance. Additionally, it covers supervised and unsupervised learning concepts, including their characteristics, types, and evaluation metrics.

Uploaded by

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

Machine Learning Module 1

The document discusses various issues in machine learning, including data challenges, overfitting, algorithm selection, interpretability, and ethical concerns. It also outlines the systematic steps for developing a machine learning application, from problem definition to monitoring and maintenance. Additionally, it covers supervised and unsupervised learning concepts, including their characteristics, types, and evaluation metrics.

Uploaded by

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

Machine Learning Module 1

Issues in Machine Learning

Machine Learning (ML) systems are powerful but they face several practical challenges during data
collection, model training, and deployment. These issues affect the accuracy, reliability, and fairness
of ML models.

The major issues in machine learning are explained below.

1. Data Challenges

Machine learning models depend heavily on the quality and quantity of data used for training.
Problems in data can significantly affect model performance.

a) Data Quality

Poor data quality such as missing values, incorrect data, or noisy data can reduce the accuracy of
machine learning models.

Example:

 Incomplete medical data may lead to incorrect disease prediction.

b) Data Quantity

Machine learning algorithms require large datasets for effective training. If the dataset is too small,
the model may fail to learn patterns properly.

Example:

 Training an image recognition system with only a few images leads to poor results.

c) Data Bias

If the training data contains biased or unbalanced information, the model may produce biased
predictions.
Example:

 A hiring model trained mostly on male employee data may unfairly prefer male candidates.

2. Overfitting and Underfitting

These are common problems related to model learning ability.

a) Overfitting

Overfitting occurs when a model learns the training data too well, including noise and unnecessary
details.

Effects:

 Very high accuracy on training data

 Poor performance on new or unseen data

Example:

 A model memorizes training examples instead of learning general patterns.

b) Underfitting

Underfitting occurs when the model fails to learn the underlying patterns in the data.

Effects:

 Poor accuracy on both training and testing data

Example:

 Using a very simple model to solve a complex problem.

3. Algorithm Selection

Choosing the appropriate machine learning algorithm is very important.

Different algorithms are suitable for different types of problems such as:

 classification

 regression

 clustering

If the wrong algorithm is selected, it may result in:

 poor predictions

 inefficient training

 longer computation time

Example:

 Using linear regression for a highly nonlinear dataset.


4. Interpretability (Black Box Problem)

Many machine learning models, especially deep neural networks, are highly complex.

They behave like black boxes, meaning:

 It is difficult to understand how the model made a particular decision.

This lack of interpretability is problematic in critical fields such as:

 healthcare

 finance

 law

Example:

 A medical AI predicting disease without explaining the reasoning.

5. Ethical Concerns

Machine learning systems can raise ethical and social issues when used in real-world applications.

Major ethical concerns include:

 Privacy: ML models often require large amounts of personal data.

 Security: Data leaks or attacks can compromise sensitive information.

 Bias and Fairness: Biased datasets can lead to unfair decisions.

Example:

 Facial recognition systems showing higher error rates for certain groups.

Applications of machine learning


Steps of Developing a Machine Learning Application

Developing a machine learning application involves several systematic steps starting from problem
identification to model deployment and monitoring. Each step ensures that the machine learning
model performs accurately and reliably.

1. Problem Definition

Explanation

The first step in developing a machine learning application is clearly defining the problem to be
solved.
This involves identifying:

 the objective of the system

 the type of prediction required

 the expected output

The problem must also be classified as a machine learning task, such as:

 classification

 regression

 clustering

A clear problem definition helps determine the type of data required and the suitable algorithms.

Example

Predicting whether an email is spam or not spam.

2. Data Collection

Explanation

After defining the problem, relevant data must be collected. Machine learning models learn patterns
from data, so the dataset must be:

 sufficient in quantity

 relevant to the problem

 representative of real-world situations

Data can be collected from sources such as:

 databases

 sensors

 websites

 publicly available datasets


Poor or insufficient data can lead to low model accuracy.

3. Data Preprocessing

Explanation

Raw data usually contains errors, missing values, or noise, so it must be cleaned before training.

Data preprocessing includes:

 handling missing values

 removing duplicates

 eliminating noise

 normalizing or scaling data

 converting categorical data to numerical form

This step ensures that the dataset becomes consistent and suitable for machine learning
algorithms.

4. Feature Engineering

Explanation

Feature engineering involves selecting or creating relevant input variables (features) that help the
model learn patterns effectively.

Important tasks include:

 feature selection

 feature extraction

 feature transformation

Good features improve model accuracy and efficiency.

Example features might include:

 frequency of specific words

 message length

 number of links in an email

5. Model Selection

Explanation

In this step, an appropriate machine learning algorithm is selected depending on the problem type
and dataset characteristics.
Common algorithms include:

 Decision Trees

 Support Vector Machines

 Neural Networks

 Naïve Bayes

 Random Forest

Choosing the correct algorithm improves the performance and efficiency of the system.

6. Training

Explanation

The collected dataset is divided into:

 training dataset

 testing/validation dataset

The training dataset is used to teach the model to recognize patterns.

During training, the model adjusts its internal parameters (weights) to minimize prediction errors.

7. Evaluation

Explanation

After training, the model must be evaluated to determine its performance.

Common evaluation metrics include:

 Accuracy

 Precision

 Recall

 F1-score

 Confusion matrix

Evaluation helps determine whether the model generalizes well to unseen data.

8. Hyperparameter Tuning

Explanation

Hyperparameters are settings that control how the model learns.

Examples include:
 learning rate

 number of layers in neural networks

 depth of decision trees

 number of neighbors in KNN

Hyperparameter tuning improves model performance using techniques such as:

 grid search

 random search

 cross validation

9. Deployment

Explanation

Once the model performs well, it is deployed in a real-world environment.

Deployment allows the model to make predictions on new data.

Examples include:

 integrating the model into websites

 mobile apps

 email filtering systems

10. Monitoring and Maintenance

Explanation

After deployment, the model must be continuously monitored to ensure consistent performance.

Over time, data patterns may change, which can reduce model accuracy. This is called data drift.

Monitoring involves:

 tracking model performance

 retraining with new data

 updating the system regularly


Example: Building a Machine Learning Application to Detect Spam Emails

The same steps can be applied to build a Spam Email Detection System.

Step 1: Problem Definition

The goal is to develop a machine learning model that classifies emails into two categories:

 Spam

 Not Spam (Ham)

This is a binary classification problem.

Step 2: Data Collection

A dataset containing labeled emails is collected.

Example datasets:

 SpamAssassin dataset

 Enron email dataset

Each email is labeled as:

 spam

 ham

Step 3: Data Preprocessing

Email data must be cleaned before training.

Preprocessing tasks include:

 removing punctuation and special characters

 converting text to lowercase

 removing stop words (like "the", "is")

 tokenization (splitting text into words)

Example:

Raw Email:

Congratulations!!! You have won a FREE lottery.

Processed Email:

congratulations won free lottery


Step 4: Feature Engineering

Relevant features are extracted from the email.

Examples of features:

 frequency of spam words (free, win, offer)

 number of hyperlinks

 email length

 presence of attachments

A common technique is TF-IDF (Term Frequency–Inverse Document Frequency).

Step 5: Model Selection

Algorithms suitable for spam detection include:

 Naïve Bayes (very popular for spam filtering)

 Logistic Regression

 Support Vector Machines

 Neural Networks

Naïve Bayes is often chosen because it works well with text classification problems.

Step 6: Training

The dataset is divided into:

 Training set (80%)

 Testing set (20%)

The training data is used to teach the model how to identify spam patterns.

Step 7: Evaluation

The model is evaluated using metrics such as:

 Accuracy

 Precision

 Recall

 F1-score

Example result:

Accuracy = 95%
This means the model correctly classifies 95% of emails.

Step 8: Hyperparameter Tuning

Parameters such as:

 smoothing parameter (for Naïve Bayes)

 regularization strength

are adjusted to improve accuracy.

Step 9: Deployment

The trained model is integrated into an email server or application.

Whenever a new email arrives:

1. The email is processed.

2. Features are extracted.

3. The model predicts spam or not spam.

4. Spam emails are moved to the spam folder.

Step 10: Monitoring and Maintenance

The system must be continuously updated because spammers change their techniques.

Maintenance tasks include:

 collecting new spam data

 retraining the model

 updating features

This keeps the spam detection system effective over time.


Supervised Learning

Definition

Supervised learning is a type of machine learning in which a model is trained using labeled data.
In this method, the dataset contains input-output pairs, and the algorithm learns the relationship
between them to make predictions on new data.

The model learns a mapping function:

[Y = f(X)]

Where:

 X = Input data (features)

 Y = Output or target label

 f = mapping function learned by the model

The goal of supervised learning is to learn patterns from the training data and accurately predict
outputs for unseen data.

How Supervised Learning Works

1. A labeled dataset is provided.

2. The dataset contains:

o Input features

o Correct output labels

3. The algorithm learns the relationship between inputs and outputs during training.

4. The trained model is tested with new unseen data.

5. The model predicts the output based on the learned patterns.

Example

Dataset for House Price Prediction

Size ([Link]) Price

1000 ₹50,00,000

1500 ₹75,00,000

2000 ₹1,00,00,000

The algorithm learns the relationship between house size and price and predicts prices for new
houses.
Characteristics of Supervised Learning

 Uses labeled data

 Requires training dataset

 Provides high accuracy when enough data is available

 Used mainly for prediction and classification tasks

Types of Supervised Learning

Supervised learning is mainly divided into two types:

1. Classification

2. Regression

1. Classification

Definition

Classification is a supervised learning technique used when the output variable is categorical
(discrete).

The model assigns input data into predefined classes or categories.

Examples

 Email spam detection → Spam / Not Spam

 Disease diagnosis → Positive / Negative

 Image recognition → Cat / Dog

Example Dataset

Email Text Label

Win a free lottery Spam

Meeting schedule tomorrow Not Spam

The algorithm learns patterns of spam emails and classifies new emails.

Common Classification Algorithms

 Decision Tree

 Support Vector Machine (SVM)


 K-Nearest Neighbors (KNN)

 Naïve Bayes

 Logistic Regression

 Neural Networks

Types of Classification

Binary Classification

Only two classes.

Example:

 Spam vs Not Spam

 Pass vs Fail

Multiclass Classification

More than two classes.

Example:

 Handwritten digit recognition (0–9)

 Fruit classification (Apple, Mango, Banana)

2. Regression

Definition

Regression is a supervised learning technique used when the output variable is continuous
(numerical).

It predicts real-valued numbers.

Examples

 House price prediction

 Temperature forecasting

 Stock market prediction

Example Dataset

Area ([Link]) House Price

1000 ₹50,00,000
Area ([Link]) House Price

1500 ₹75,00,000

2000 ₹1,00,00,000

The model predicts the price of a house based on its size.

Common Regression Algorithms

 Linear Regression

 Polynomial Regression

 Support Vector Regression

 Decision Tree Regression

 Random Forest Regression

Advantages of Supervised Learning

1. Easy to understand and implement.

2. Provides accurate predictions with sufficient data.

3. Many well-developed algorithms are available.

4. Works well for classification and regression problems.

Limitations of Supervised Learning

1. Requires large labeled datasets.

2. Data labeling can be time-consuming and expensive.

3. Performance depends heavily on data quality.

4. Overfitting may occur if the model memorizes training data.

Applications of Supervised Learning

 Spam email detection

 Image classification

 Speech recognition

 Medical diagnosis

 Fraud detection
Evaluation Metrics for Classification Models

Classification models predict categorical outputs such as spam/not spam, disease/no disease, etc.

1. Accuracy

Definition

Accuracy measures the percentage of correct predictions made by the model.

Formula

Correct Predictions
Accuracy=
Total Predictions
Example

If a model correctly predicts 90 out of 100 emails, accuracy = 90%.

Limitation

Accuracy may be misleading when dealing with imbalanced datasets.

2. Precision

Definition

Precision measures the percentage of predicted positive cases that are actually correct.

Formula

True Positives
Precision=
True Positives+ False Positives
Explanation

Precision answers the question:

"Out of all predicted positives, how many are actually positive?"

Example:
In spam detection, precision tells how many emails predicted as spam are actually spam.

3. Recall (Sensitivity)

Definition

Recall measures the percentage of actual positive cases correctly identified by the model.

Formula

True Positives
Recall=
True Positives+ False Negatives
Explanation

Recall answers the question:

"Out of all actual positive cases, how many did the model detect?"

Example:
In disease detection, recall measures how many sick patients are correctly detected.

4. F1 Score

Definition
F1 score is the harmonic mean of precision and recall.

Formula

Precision × Recall
F 1=2×
Precision+ Recall
Explanation

 Provides a balanced measure of precision and recall.

 Useful when dealing with imbalanced datasets.

5. Confusion Matrix

Definition

A confusion matrix is a table used to evaluate classification models by comparing predicted and
actual values.

Structure

Actual / Predicted Positive Negative

Positive True Positive (TP) False Negative (FN)

Negative False Positive (FP) True Negative (TN)

Explanation

 TP → Correctly predicted positive cases

 TN → Correctly predicted negative cases

 FP → Incorrectly predicted positive cases

 FN → Incorrectly predicted negative cases

It helps visualize where the model is making mistakes.

Unsupervised Learning

Definition
Unsupervised learning is a type of machine learning in which the algorithm is trained using
unlabeled data, meaning that the dataset does not contain predefined output labels.
The goal of unsupervised learning is to discover hidden patterns, structures, or relationships in the
data automatically.

Unlike supervised learning, the model is not told what the correct output should be. Instead, it
analyzes the input data and organizes it based on similarities or patterns.

Mathematically:

Where:

 X = input data

 The algorithm identifies patterns without known outputs.

Characteristics of Unsupervised Learning

 Uses unlabeled datasets

 Finds hidden structures and relationships

 Does not require target variables

 Useful for data exploration and pattern discovery

 Often used as a preprocessing step for other ML models

Example of Unsupervised Learning

Consider a dataset of customers in a shopping mall.

Customer Age Income Spending Score

1 25 30000 70

2 45 60000 40

3 22 25000 80

4 40 70000 30

An unsupervised learning algorithm may automatically group customers into clusters such as:

 Young high-spending customers

 Middle-aged moderate spenders

 High-income low spenders

These patterns are discovered without predefined labels.


Types of Unsupervised Learning

Unsupervised learning mainly consists of the following techniques:

1. Clustering

2. Association

1. Clustering

Definition

Clustering is a technique used to group similar data points into clusters based on their
characteristics.

Data points in the same cluster are more similar to each other than to those in other clusters.

Example

Suppose we have customer purchase data:

Customer Purchase Amount

A 500

B 520

C 100

D 120

The algorithm may group them into clusters:

Cluster 1 → High spenders (A, B)


Cluster 2 → Low spenders (C, D)

2. Association Learning

Definition

Association learning identifies relationships between variables in large datasets.

It finds association rules that describe how items are related.

Example

In a supermarket dataset:
Transaction Items Purchased

1 Bread, Butter

2 Bread, Milk

3 Bread, Butter, Jam

The algorithm may discover the rule:


Bread === Butter
Meaning customers who buy bread often buy butter.

This is known as Market Basket Analysis.

Measures Used in Association Learning

Support

Indicates how frequently an itemset appears in the dataset.

Confidence

Measures how often the rule is correct.

Lift

Measures the strength of the association between items.

Advantages of Unsupervised Learning

1. Does not require labeled data.

2. Useful for discovering hidden patterns.

3. Helps in data exploration and understanding complex datasets.

4. Can handle large datasets efficiently.

Limitations of Unsupervised Learning

1. Results may be difficult to interpret.

2. Hard to measure accuracy because there are no labeled outputs.

3. Sometimes the discovered patterns may not be meaningful.

Applications of Unsupervised Learning

 Customer segmentation
 Market basket analysis

 Fraud detection

 Image compression

 Recommendation systems

 Anomaly detection

 Document clustering

Training, Testing, and Validation Dataset

In machine learning, the available dataset is usually divided into three parts: Training dataset,
Validation dataset, and Testing dataset.
This division helps in building, tuning, and evaluating machine learning models effectively.

1. Training Dataset

Definition

The training dataset is the portion of the data used to train the machine learning model.

During training, the algorithm learns the relationship between input features and output labels by
adjusting its internal parameters.

Purpose

 To teach the model patterns in the data

 To estimate model parameters such as weights

Working

The algorithm processes the training data repeatedly and minimizes prediction errors.

Example:
If we are building a house price prediction model, the training dataset may contain:

House Size Number of Rooms Price

1200 3 ₹50,00,000

1500 4 ₹70,00,000

1800 4 ₹90,00,000

The model learns how house features influence price.

Typical Size

Usually 60–80% of the total dataset.


2. Validation Dataset

Definition

The validation dataset is used to tune the model and select the best parameters during the training
process.

It helps evaluate how well the model performs while it is being trained.

Purpose

 To adjust hyperparameters

 To prevent overfitting

 To compare different models

Hyperparameters include:

 learning rate

 number of layers

 number of trees

 regularization strength

Example

While building a spam detection model, the validation dataset is used to determine:

 the best algorithm

 optimal hyperparameter settings

Typical Size

Usually 10–20% of the dataset.

3. Testing Dataset

Definition

The testing dataset is used to evaluate the final performance of the trained model.

It is not used during training or tuning.

Purpose

 To measure how well the model generalizes to new unseen data

 To estimate real-world performance

Example

After building a spam detection model, the testing dataset contains new emails the model has never
seen before.
The model predicts whether each email is spam or not.
Evaluation metrics such as:

 Accuracy

 Precision

 Recall

 F1 score

are calculated using the testing dataset.

Typical Size

Usually 10–20% of the dataset.

Example of Dataset Splitting

Suppose we have 1000 data samples.

Dataset Percentage Number of Samples

Training Dataset 70% 700

Validation Dataset 15% 150

Testing Dataset 15% 150

Key Differences

Feature Training Dataset Validation Dataset Testing Dataset

Purpose Train the model Tune hyperparameters Evaluate final model

Used during training Yes Yes No

Used for evaluation No Yes (during training) Yes (final evaluation)

Data visibility Seen by model Partially seen Never seen

Importance of Dataset Splitting

Dividing the dataset into training, validation, and testing sets helps:

 avoid overfitting

 improve model generalization

 ensure accurate performance evaluation

Cross Validation
Definition

Cross validation is a technique used to evaluate the performance of a machine learning model by
dividing the dataset into multiple subsets and training/testing the model multiple times.

It helps ensure that the model performs well on different portions of the data and improves the
reliability of model evaluation.

Purpose of Cross Validation

 To assess model performance more accurately

 To reduce overfitting

 To use limited data efficiently

 To select the best model or hyperparameters

K-Fold Cross Validation

The most common type is K-Fold Cross Validation.

Steps

1. The dataset is divided into K equal parts (folds).

2. One fold is used as the testing set and the remaining folds are used as the training set.

3. The model is trained and tested.

4. This process repeats K times, each time with a different fold as the test set.

5. The final model performance is calculated as the average of all K results.

Example

If K = 5

Dataset → divided into 5 parts

Iteration Training Data Testing Data

1 Fold 2,3,4,5 Fold 1

2 Fold 1,3,4,5 Fold 2

3 Fold 1,2,4,5 Fold 3

4 Fold 1,2,3,5 Fold 4

5 Fold 1,2,3,4 Fold 5

Final performance = Average accuracy of all 5 runs


Advantages

 Uses data efficiently

 Gives better performance estimation

 Reduces dependency on a single train-test split

2. Overfitting

Definition

Overfitting occurs when a machine learning model learns the training data too well, including noise
and irrelevant details.

As a result, the model performs very well on training data but poorly on new unseen data.

Characteristics of Overfitting

 High training accuracy

 Low testing accuracy

 Model memorizes training data instead of learning patterns

Example

Suppose a model is trained to detect spam emails.

Training Accuracy = 99%


Testing Accuracy = 60%

This indicates the model has overfitted the training data.

Causes of Overfitting

 Too complex model

 Small training dataset

 Too many features

Methods to Prevent Overfitting

 Cross validation

 Regularization

 Early stopping
 Increasing training data

 Simplifying the model

3. Underfitting

Definition

Underfitting occurs when a model fails to capture the underlying patterns in the data.

The model is too simple to represent the relationship between input and output variables.

Characteristics of Underfitting

 Low training accuracy

 Low testing accuracy

 Model cannot learn important patterns

Example

A linear model used for predicting complex nonlinear data may produce poor results.

Training Accuracy = 60%


Testing Accuracy = 58%

This indicates underfitting.

Causes of Underfitting

 Very simple model

 Insufficient training time

 Poor feature selection

Methods to Reduce Underfitting

 Use more complex models

 Add more relevant features

 Increase training time

 Reduce regularization
Difference Between Overfitting and Underfitting

Feature Overfitting Underfitting

Model complexity Too complex Too simple

Training accuracy Very high Low

Testing accuracy Low Low

Learning behavior Memorizes training data Fails to learn patterns

Generalization Poor Poor

Module 5

1. Biological Neuron

Definition

A biological neuron is a specialized nerve cell in the nervous system that receives, processes, and
transmits information using electrical and chemical signals.
Neurons are the fundamental units of the human brain and nervous system.
Main Parts of a Biological Neuron

1. Dendrites

o Branch-like structures.

o Receive signals from other neurons.

2. Cell Body (Soma)

o Processes incoming signals.

o Decides whether the neuron should fire.

3. Axon

o A long fiber that carries signals away from the cell body.

4. Synapse

o Junction between two neurons.

o Signals are transmitted chemically across synapses.

Working of a Biological Neuron

1. Dendrites receive signals from other neurons.

2. Signals are processed in the cell body.

3. If the signal exceeds a threshold, the neuron fires.

4. The electrical signal travels through the axon.

5. Neurotransmitters pass the signal across the synapse to the next neuron.

Thus, neurons form large interconnected networks in the brain.

2. Artificial Neuron (Artificial Neural Network Model)


Definition

An artificial neuron is a mathematical model inspired by a biological neuron.


It is the basic unit of an Artificial Neural Network (ANN) used to process data and solve problems
such as classification, prediction, and pattern recognition.

Structure of Artificial Neuron

An artificial neuron consists of the following components:

1. Inputs (x₁, x₂, …, xₙ)


Data provided to the neuron.

2. Weights (w₁, w₂, …, wₙ)


Represent the strength or importance of each input.

3. Summation Function
Computes the weighted sum

4. Bias (b)
Adjusts the output of the neuron.

5. Activation Function
Determines whether the neuron should produce an output.

6. Output (y)
Final output of the neuron.

3. Artificial Neural Network (ANN)


An Artificial Neural Network is formed by connecting multiple artificial neurons.

Layers of ANN

1. Input Layer

o Receives input data.

2. Hidden Layer(s)

o Processes data through neurons.

3. Output Layer

o Produces final prediction or classification.

4. Relationship Between Biological and Artificial Neurons

Biological Neuron Artificial Neuron

Dendrites Inputs

Synapse Weights

Cell Body Summation function

Axon Output

Threshold firing Activation function

Artificial neural networks are inspired by the working mechanism of biological neurons.

5. Advantages of Artificial Neural Networks

 Can learn complex patterns

 Handles large datasets

 Works well for classification and prediction

 Used in many real-world applications

6. Applications of Artificial Neural Networks

 Image recognition

 Speech recognition

 Medical diagnosis

 Recommendation systems

 Autonomous vehicles

 Natural language processing


Neural Network (NN) Architecture

A Neural Network Architecture refers to the structure and arrangement of neurons in a neural
network, including how neurons are organized into layers and how they are connected.
It determines how input data flows through the network and how the model learns patterns from
the data.

Neural networks are inspired by the working of biological neurons in the human brain.

1. Basic Structure of Neural Network Architecture

A typical neural network architecture consists of three main layers:

1. Input Layer

2. Hidden Layer(s)

3. Output Layer

2. Input Layer

Definition

The input layer is the first layer of the neural network that receives raw input data.

Each neuron in this layer represents one feature of the input dataset.

Example

For a dataset predicting house prices:

Feature Input neuron

Area x₁

Bedrooms x₂

Location score x₃

Input vector:

[
X = (x_1, x_2, x_3)
]

The input layer does not perform computation, it only passes data to the next layer.

3. Hidden Layer

Definition
Hidden layers are intermediate layers between input and output layers where actual learning and
computation take place.

A neural network may contain one or multiple hidden layers.

Each neuron performs two operations:

1. Weighted Sum

[
z = \sum w_i x_i + b
]

Where

 (x_i) = input

 (w_i) = weight

 (b) = bias

2. Activation Function

The result is passed through an activation function:

[
a = f(z)
]

Activation functions introduce non-linearity, enabling the network to learn complex patterns.

4. Output Layer

Definition

The output layer produces the final prediction or classification result.

The number of neurons depends on the type of problem.

Example

Problem Output neurons

Binary classification 1

Multi-class classification number of classes

Regression 1

5. Weights and Bias


Weights

Weights determine the importance of each input feature.

If a weight is large, the input has greater influence on the output.

Bias

Bias allows the model to shift the activation function and improves learning flexibility.

6. Forward Propagation

Forward propagation is the process where input data moves through the network layer by layer
until the output is produced.

Steps:

1. Input data enters input layer

2. Hidden layer computes weighted sum

3. Activation function is applied

4. Output layer produces prediction

7. Training the Neural Network

Neural networks learn using a process called training.

Steps

1. Initialize weights randomly

2. Perform forward propagation

3. Compute error using a loss function

4. Update weights using backpropagation

5. Repeat until error is minimized

8. Loss Function

Loss function measures difference between predicted output and actual output.

Examples:

 Mean Squared Error (MSE)

 Cross Entropy Loss

Example:
[
Loss = (Actual - Predicted)^2
]

9. Backpropagation

Backpropagation is the process of updating weights by propagating error backward through the
network.

Weights are updated using gradient descent.

10. Types of Neural Network Architectures

Different neural network architectures exist depending on the structure.

1. Feedforward Neural Network

Information flows only forward.

2. Recurrent Neural Network (RNN)

Has feedback connections and memory.

3. Convolutional Neural Network (CNN)

Used for image processing.

4. Deep Neural Network (DNN)

Contains multiple hidden layers.

11. Applications of Neural Network Architecture

Neural networks are widely used in:

 Image recognition

 Speech recognition

 Natural language processing

 Medical diagnosis

 Recommendation systems

 Autonomous vehicles

You might also like