Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Intro to Machine Learning

Summer of Science Final Report

Deepak Silaych
22B0660
Intro to Machine Learning Deepak Silaych

Abstract
This descriptive report provides a comprehensive overview of ma-
chine learning, covering various aspects such as the introduction to
machine learning, types of machine learning, the role of Python and
essential libraries in machine learning, classification and regression
techniques, popular algorithms including KNN, Naive Bayes, Logistic
Regression, SVM, Decision Trees, Random Forests, Neural Networks,
and Convolutional Neural Networks (CNN). Additionally, the report
discusses the model testing.

Contents
1 Introduction to Machine Learning 4
1.1 What is Machine Learning? . . . . . . . . . . . . . . . . . . . 4
1.2 How Machine Learning Works . . . . . . . . . . . . . . . . . . 4
1.3 Real-world Applications . . . . . . . . . . . . . . . . . . . . . 5

2 Types of Machine Learning 6


2.1 Supervised Learning . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Unsupervised Learning . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Semi-supervised Learning . . . . . . . . . . . . . . . . . . . . 7
2.4 Reinforcement Learning . . . . . . . . . . . . . . . . . . . . . 7
2.5 Deep Learning . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3 Python in Machine Learning 8


3.1 Why Python is Popular in ML? . . . . . . . . . . . . . . . . . 8
3.2 Python’s Ecosystem for ML . . . . . . . . . . . . . . . . . . . 8
3.2.1 NumPy . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2 Pandas . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.3 Matplotlib and Seaborn . . . . . . . . . . . . . . . . . 9
3.2.4 Scikit-learn . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.5 TensorFlow and Keras . . . . . . . . . . . . . . . . . . 9
3.3 Data Manipulation and Visualization in Python . . . . . . . . 9

4 NumPy in Machine Learning 11


4.1 Introduction to NumPy Arrays . . . . . . . . . . . . . . . . . 11
4.2 Handling Multi-dimensional Data using NumPy . . . . . . . . 12
4.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1
Intro to Machine Learning Deepak Silaych

5 Classification and Regression 13


5.1 Classification Techniques . . . . . . . . . . . . . . . . . . . . . 13
5.2 Regression Techniques . . . . . . . . . . . . . . . . . . . . . . 13

6 Training a Machine Learning Model 15


6.1 Data Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . 15
6.2 Splitting Data into Training and Testing Sets . . . . . . . . . 16
6.3 Model Selection and Evaluation . . . . . . . . . . . . . . . . . 16

7 K-Nearest Neighbors (KNN) 17


7.1 Understanding the KNN Algorithm . . . . . . . . . . . . . . . 17
7.2 Finding the Optimal K Value . . . . . . . . . . . . . . . . . . 17
7.3 KNN for Classification and Regression Tasks . . . . . . . . . . 18

8 Naive Bayes 19
8.1 Bayes Theorem and Naive Bayes Algorithm . . . . . . . . . . 19
8.2 Applications of Naive Bayes . . . . . . . . . . . . . . . . . . . 20
8.3 Laplace Smoothing . . . . . . . . . . . . . . . . . . . . . . . . 20

9 Logistic Regression 21
9.1 Understanding Logistic Regression . . . . . . . . . . . . . . . 21
9.2 Logistic Function (Sigmoid) . . . . . . . . . . . . . . . . . . . 21
9.3 Training Logistic Regression . . . . . . . . . . . . . . . . . . . 22
9.4 Applications of Logistic Regression . . . . . . . . . . . . . . . 22
9.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

10 Support Vector Machine (SVM) 24


10.1 How SVM Works . . . . . . . . . . . . . . . . . . . . . . . . . 24
10.2 When Data is Not Separable . . . . . . . . . . . . . . . . . . . 24
10.3 Applications of SVM . . . . . . . . . . . . . . . . . . . . . . . 24
10.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

11 Decision Trees and Random Forest 26


11.1 Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
11.2 Random Forest . . . . . . . . . . . . . . . . . . . . . . . . . . 26
11.3 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
11.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2
Intro to Machine Learning Deepak Silaych

12 Neural Networks 29
12.1 Understanding Neural Networks . . . . . . . . . . . . . . . . . 29
12.2 Deep Learning and Deep Neural Networks . . . . . . . . . . . 29
12.3 Applications of Neural Networks . . . . . . . . . . . . . . . . . 30
12.4 Challenges and Advancements . . . . . . . . . . . . . . . . . . 30

13 Convolutional Neural Networks (CNN) 31


13.1 Understanding CNN . . . . . . . . . . . . . . . . . . . . . . . 31
13.2 Applications of CNN . . . . . . . . . . . . . . . . . . . . . . . 31
13.3 Project: Sign Language Recognizer . . . . . . . . . . . . . . . 32
13.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

14 Testing and Evaluation 34


14.1 Train-Test Split . . . . . . . . . . . . . . . . . . . . . . . . . . 34
14.2 Evaluation Metrics . . . . . . . . . . . . . . . . . . . . . . . . 34
14.3 Cross-Validation . . . . . . . . . . . . . . . . . . . . . . . . . . 34
14.4 Overfitting and Underfitting . . . . . . . . . . . . . . . . . . . 34

15 Ending and Personal Reflection 35

3
Intro to Machine Learning Deepak Silaych

1 Introduction to Machine Learning


Machine Learning (ML) is a part of artificial intelligence that teaches com-
puters to do things without being explicitly programmed. It helps computers
learn from data, find patterns, and make smart decisions based on that knowl-
edge. ML is used in many areas like language processing, image recognition,
medical diagnosis, and more.

1.1 What is Machine Learning?


Machine learning is all about creating algorithms that learn from data and
improve their performance over time. It’s like teaching a computer to rec-
ognize patterns so it can make better predictions in the future. There are
different types of machine learning, like supervised learning (with labeled
data), unsupervised learning (without labels), reinforcement learning (learn-
ing through rewards), and deep learning (using neural networks).

1.2 How Machine Learning Works


In a machine learning project, we follow these steps:

1. Data Collection: First, we gather data that the computer will learn
from.

2. Data Preprocessing: We clean and organize the data to make it suitable


for training.

3. Model Selection: Next, we choose the right algorithm to train the com-
puter.

4. Model Training: The computer learns from the data and adjusts itself
to improve its performance.

5. Model Evaluation: We test the computer’s performance to see how well


it learned.

6. Model Deployment: Finally, we use the trained computer to make pre-


dictions or decisions in real-world situations.

4
Intro to Machine Learning Deepak Silaych

1.3 Real-world Applications


Machine learning has many practical uses in our lives, such as:

• Language Processing: It helps computers understand and respond to


human language, like chatbots or language translation.

• Image Recognition: Computers can recognize objects or people in im-


ages, used in security or photo organization.

• Healthcare: ML aids doctors in diagnosing diseases and finding the


best treatment options for patients.

• Finance: It’s used for detecting fraudulent activities in banking and


making investment decisions.

• Recommendation Systems: ML suggests products, movies, or songs


based on our interests and past behavior.

• Autonomous Vehicles: It enables self-driving cars to navigate safely on


the roads.

5
Intro to Machine Learning Deepak Silaych

2 Types of Machine Learning


Machine learning can be divided into different types based on how computers
learn and the type of data they use.

2.1 Supervised Learning


Supervised learning is like having a teacher guide the computer. The com-
puter learns from labeled data, which means the input data and the correct
output are given together. It uses this labeled data to make predictions on
new, unseen data. For example, if we want the computer to recognize pic-
tures of cats and dogs, we show it many pictures of cats labeled ”cat” and
dogs labeled ”dog.” The computer learns to differentiate between cats and
dogs and can predict the correct label for new images.

2.2 Unsupervised Learning


Unsupervised learning doesn’t have a teacher; the computer learns by itself.
It deals with unlabeled data, where the computer tries to find patterns or
structures in the data without any predefined categories. Clustering is a com-
mon unsupervised learning technique. For instance, if we give the computer
a bunch of different animals’ pictures without labels, it may group similar
animals together, even though it doesn’t know their names.

6
Intro to Machine Learning Deepak Silaych

2.3 Semi-supervised Learning


Semi-supervised learning is a mix of supervised and unsupervised learning.
Here, the computer uses both labeled and unlabeled data to learn. In some
cases, getting labeled data can be expensive or time-consuming, so using a
combination of labeled and unlabeled data can be more practical.

2.4 Reinforcement Learning


Reinforcement learning is like training a pet. The computer learns by taking
actions in an environment and receiving rewards or penalties based on its
actions. It aims to find the best actions that lead to the most rewards. For
example, in a game, the computer may try different moves and learn which
moves give it higher scores.

2.5 Deep Learning


Deep learning is a specialized form of machine learning that uses artificial
neural networks to learn from data. These networks have layers of intercon-
nected nodes, allowing the computer to learn increasingly complex patterns.
Deep learning is behind many recent breakthroughs in areas like image and
speech recognition.
Each type of machine learning has its strengths and weaknesses, and they
find applications in various fields, making machine learning a powerful and
versatile tool in modern technology.

7
Intro to Machine Learning Deepak Silaych

3 Python in Machine Learning


Python is a popular programming language widely used in machine learning.
It has become the go-to language for data scientists and machine learning
engineers due to its simplicity, versatility, and powerful ecosystem of libraries.

3.1 Why Python is Popular in ML?


Python is beginner-friendly and easy to read and write. It allows developers
to focus on solving problems rather than dealing with complex syntax. Its
extensive community support and rich libraries make it ideal for machine
learning tasks. Moreover, Python’s compatibility with various platforms and
operating systems ensures that machine learning projects can be easily de-
ployed on different devices.

3.2 Python’s Ecosystem for ML


Python’s ecosystem is enriched with several powerful libraries that simplify
and accelerate machine learning development.

8
Intro to Machine Learning Deepak Silaych

3.2.1 NumPy
NumPy is a fundamental library for numerical computations in Python. It
provides support for large, multi-dimensional arrays and matrices, making it
ideal for handling data in machine learning applications.

3.2.2 Pandas
Pandas is a popular library for data manipulation and analysis. It provides
data structures like DataFrames that enable users to clean, transform, and
analyze data efficiently.

3.2.3 Matplotlib and Seaborn


Matplotlib and Seaborn are used for data visualization in Python. They allow
developers to create various types of plots and charts to better understand
the data and communicate findings.

3.2.4 Scikit-learn
Scikit-learn is a powerful library for machine learning tasks. It includes a
wide range of algorithms for classification, regression, clustering, and more.
Additionally, it provides utilities for model evaluation and data preprocess-
ing.

3.2.5 TensorFlow and Keras


TensorFlow and Keras are popular libraries for deep learning. They allow
developers to create and train neural networks efficiently, making complex
tasks like image and speech recognition more accessible.

3.3 Data Manipulation and Visualization in Python


Python’s libraries, like NumPy and Pandas, facilitate data manipulation,
cleaning, and organization. Data visualization is made easy with Matplotlib
and Seaborn, allowing developers to create insightful plots and charts for
better understanding and presentation of data.
Using Python’s libraries, data scientists and machine learning engineers
can efficiently preprocess the data before training machine learning models,
which significantly impacts the model’s performance.

9
Intro to Machine Learning Deepak Silaych

Python’s role in machine learning is substantial, and its widespread adop-


tion in the field makes it a crucial tool for those entering the world of data
science and AI.

10
Intro to Machine Learning Deepak Silaych

4 NumPy in Machine Learning


NumPy is a powerful library for numerical computations in Python. It
plays a vital role in machine learning as it provides support for large, multi-
dimensional arrays and matrices, making it ideal for handling and processing
data efficiently.

4.1 Introduction to NumPy Arrays


NumPy arrays are similar to Python lists but much more powerful. They
allow us to perform operations on entire arrays, which significantly improves
the performance compared to traditional loops
• Array Operations for ML
• Element-wise Operations
• Broadcasting
• Aggregation Functions

11
Intro to Machine Learning Deepak Silaych

4.2 Handling Multi-dimensional Data using NumPy


In machine learning, datasets often come in the form of multi-dimensional
arrays. NumPy simplifies handling such data with ease. For instance, images
in computer vision are represented as multi-dimensional arrays, and NumPy
allows manipulation and transformation of these arrays efficiently.
Using NumPy, data scientists can perform data preprocessing tasks, such
as feature scaling and data normalization, which are crucial for training ac-
curate machine learning models.

4.3 Conclusion
NumPy is a fundamental library for any machine learning project in Python.
Its powerful array operations and efficient handling of multi-dimensional data
make it indispensable for data manipulation and mathematical computations.

12
Intro to Machine Learning Deepak Silaych

5 Classification and Regression


In machine learning, two common types of tasks are classification and regres-
sion. Let’s explore each of them:

5.1 Classification Techniques


Classification is used to predict the category or class of a given input data
point. The output of a classification model is discrete and belongs to a
predefined set of classes. Some popular classification techniques are:
• Support Vector Machine (SVM)
• K-Nearest Neighbors (KNN)
• Naive Bayes Classifier
• Logistic Regression

5.2 Regression Techniques


Regression is used when the output we want to predict is a continuous value
rather than a category. In regression, the model learns to map input data to
a continuous output. Some popular regression techniques are:
• Linear Regression: Linear regression is one of the simplest regression
algorithms. It fits a straight line to the data points, aiming to minimize
the difference between the predicted and actual values.

13
Intro to Machine Learning Deepak Silaych

• Polynomial Regression: Polynomial regression extends linear regres-


sion by fitting higher-degree polynomials to the data. It can capture
more complex relationships between input and output.

• Decision Trees

• Random Forests

Both classification and regression techniques find extensive applications


in various domains, such as predicting customer churn, stock prices, medical
diagnosis, and image recognition. By choosing the right technique for a
specific problem, machine learning models can provide valuable insights and
make accurate predictions.

14
Intro to Machine Learning Deepak Silaych

6 Training a Machine Learning Model


Training a machine learning model is the process of teaching the computer
to make predictions based on the provided data. In this section, we’ll go
through the steps involved in training a model:

6.1 Data Preprocessing


Before training a model, we need to prepare the data for effective learning.
Data preprocessing involves several essential steps:

• Data Cleaning: We check for missing or inconsistent data and handle


them appropriately. Cleaning ensures that the data is reliable and
accurate.

• Feature Scaling: Features in the data may have different scales. Fea-
ture scaling brings all features to a similar scale, avoiding bias towards
certain features during training.

• Feature Engineering: Sometimes, existing features may not be suf-


ficient for accurate predictions. Feature engineering involves creating
new features or extracting useful information from existing ones to im-
prove model performance.

15
Intro to Machine Learning Deepak Silaych

6.2 Splitting Data into Training and Testing Sets


To evaluate the model’s performance, we split the data into two sets: the
training set and the testing set. The training set is used to train the model,
while the testing set is used to assess how well the model generalizes to new,
unseen data. A common split ratio is 70-30 or 80-20

6.3 Model Selection and Evaluation


Choosing the right model for the task is crucial. We select an appropri-
ate algorithm based on the problem type (classification or regression) and
the characteristics of the data. After training, we evaluate the model’s per-
formance using various evaluation metrics like accuracy, precision, recall,
F1-score, and more. Cross-validation helps in better estimating the model’s
performance and prevents overfitting.

16
Intro to Machine Learning Deepak Silaych

7 K-Nearest Neighbors (KNN)


K-Nearest Neighbors (KNN) is a simple and intuitive algorithm used for
both classification and regression tasks. It is a type of supervised learning
algorithm where the data points are classified based on the majority class
among their nearest neighbors.

7.1 Understanding the KNN Algorithm


In KNN, the ”K” stands for the number of nearest neighbors we consider
when making predictions. To predict the class of a new data point, we find
the K closest data points (neighbors) based on a distance metric, commonly
Euclidean distance. The class with the majority of neighbors is assigned to
the new data point. For example, if K=5 and the majority of the five nearest
neighbors are labeled ”cat,” the new data point will be classified as ”cat.”

7.2 Finding the Optimal K Value


Choosing the right value for K is essential in KNN. A small K may lead to
overfitting, where the model becomes sensitive to noise in the data. On the
other hand, a large K may result in underfitting, where the model fails to
capture the underlying patterns in the data. Finding the optimal K value
involves experimenting with different values and evaluating the model’s per-
formance using techniques like cross-validation.

17
Intro to Machine Learning Deepak Silaych

7.3 KNN for Classification and Regression Tasks


KNN is versatile and can be used for both classification and regression tasks.
In classification, the class label is predicted, while in regression, the algorithm
predicts a continuous value based on the average of the K nearest neighbors’
values. KNN is a non-parametric algorithm, meaning it doesn’t make any
assumptions about the underlying data distribution. This makes it useful in
scenarios where the data is not linearly separable.

18
Intro to Machine Learning Deepak Silaych

8 Naive Bayes
Naive Bayes is a simple and effective classification algorithm based on Bayes’
theorem. Despite its simplicity, it performs well in various real-world appli-
cations, especially in natural language processing and text classification.

8.1 Bayes Theorem and Naive Bayes Algorithm


Bayes’ theorem is a fundamental concept in probability theory that provides
a way to update the probability of an event based on new evidence. In the
context of machine learning, Bayes’ theorem helps us calculate the probability
of a data point belonging to a specific class given its features.
The Naive Bayes algorithm assumes that all features are independent of
each other, even though this might not be entirely true in practice. This
simplifying assumption is where the term ”naive” comes from. Despite this
naive assumption, the algorithm often performs surprisingly well.
The algorithm works by calculating the probabilities of each class given
the input features and then choosing the class with the highest probability
as the predicted class.

19
Intro to Machine Learning Deepak Silaych

8.2 Applications of Naive Bayes


Naive Bayes is particularly well-suited for text classification tasks. It is widely
used in:

• Spam Filtering: Naive Bayes can classify emails as spam or non-spam


based on their content.

• Sentiment Analysis: It can determine the sentiment of a text (posi-


tive, negative, or neutral) based on the words used.

• Document Categorization: Naive Bayes can categorize documents


into predefined topics based on their content.

• News Article Classification: It can classify news articles into dif-


ferent categories like sports, politics, technology, etc.

8.3 Laplace Smoothing


A potential issue with Naive Bayes arises when a certain feature value in
the testing data was not present in the training data. This can result in a
probability of zero for a particular class, making the prediction impossible.
To overcome this problem, we use Laplace smoothing, also known as add-
one smoothing. It adds a small value (usually 1) to all feature occurrences,
ensuring that no probability becomes zero.

20
Intro to Machine Learning Deepak Silaych

9 Logistic Regression
Logistic Regression is a widely used classification algorithm, despite its name,
it is used for binary classification tasks, where the output can be one of two
classes (e.g., yes/no, spam/not spam).

9.1 Understanding Logistic Regression


In Logistic Regression, the algorithm predicts the probability of an input data
point belonging to a specific class. The output of the model is a value between
0 and 1, which represents the probability. To convert this probability into a
class prediction, we set a threshold (usually 0.5). If the predicted probability
is above the threshold, the data point is classified as one class; otherwise, it
is classified as the other class.

9.2 Logistic Function (Sigmoid)


The Logistic Regression model uses a logistic function, also known as the
sigmoid function, to transform the output into the desired probability range
(0 to 1). The sigmoid function is defined as:
1
σ(z) =
1 + e−z
where z is the linear combination of input features and their correspond-
ing weights.

21
Intro to Machine Learning Deepak Silaych

9.3 Training Logistic Regression


The training process in Logistic Regression involves finding the best set of
weights that minimize the difference between the predicted probabilities and
the actual class labels in the training data. This is done using optimization
algorithms like gradient descent.

9.4 Applications of Logistic Regression


Logistic Regression finds applications in various fields, including:

• Medical Diagnosis: It can predict the likelihood of a patient having


a disease based on medical test results and patient information.

• Credit Risk Assessment: Logistic Regression helps in determining


the probability of a customer defaulting on a loan based on their credit
history and other factors.

• Customer Churn Prediction: It can predict the likelihood of a


customer leaving a service or product based on their behavior and in-
teractions with the company.

22
Intro to Machine Learning Deepak Silaych

• Image Segmentation: Logistic Regression can be used to classify


pixels in an image as part of the foreground or background in image
segmentation tasks.

9.5 Conclusion
Logistic Regression is a fundamental classification algorithm that is simple,
interpretable, and often works well for binary classification tasks. Its use
of the sigmoid function to produce probabilities makes it a valuable tool in
various applications, such as medical diagnosis, finance, and image process-
ing. By understanding the logistic function and training process, we can
utilize Logistic Regression to make accurate predictions in binary classifica-
tion problems.

23
Intro to Machine Learning Deepak Silaych

10 Support Vector Machine (SVM)


Support Vector Machine (SVM) is a powerful algorithm used for classification
tasks. It helps us draw a line (or a boundary) between different groups of
data points.

10.1 How SVM Works


Imagine we have two groups of data points on a 2D graph, like blue circles
and red crosses. SVM tries to find the best line that separates these two
groups with the biggest gap (margin) between them. This line is called the
”decision boundary.” The data points closest to the decision boundary are
called ”support vectors.” These support vectors help us define the boundary
between the groups.

10.2 When Data is Not Separable


Sometimes, the data points are not easily separable with a straight line. In
such cases, SVM uses a trick called ”kernel” to transform the data into a
higher-dimensional space where it can find a separating boundary.

10.3 Applications of SVM


SVM has many practical uses, like:

24
Intro to Machine Learning Deepak Silaych

• Email Spam Detection: SVM can help identify spam emails and
separate them from regular emails.

• Handwriting Recognition: It is used to recognize handwritten let-


ters or digits, like those in postal codes.

• Image Classification: SVM can categorize images into different groups,


like identifying animals in pictures.

10.4 Conclusion
Support Vector Machine is a powerful tool for classification tasks. It helps
us draw a line between different groups of data points.

25
Intro to Machine Learning Deepak Silaych

11 Decision Trees and Random Forest


Decision Trees and Random Forest are popular machine learning algorithms
used for both classification and regression tasks. They are easy to understand
and interpret, making them valuable tools for various applications.

11.1 Decision Trees


A Decision Tree is a flowchart-like structure where each internal node rep-
resents a test on a feature, each branch represents the outcome of the test,
and each leaf node represents a class label or a prediction value. The tree is
built by finding the best feature and the best value to split the data at each
node. The goal is to create simple and meaningful rules that can predict the
target variable accurately. Decision Trees are great for explaining how the
model makes decisions. We can follow the path from the root to a leaf node
to understand how the features influence the final prediction.

11.2 Random Forest


Random Forest is an ensemble learning technique that combines multiple De-
cision Trees to improve prediction accuracy and reduce overfitting. To create
a Random Forest, we build several Decision Trees using different subsets of
the training data and different subsets of features. Each tree gives its pre-
diction, and the final prediction is determined by taking a vote from all the
trees. Random Forest is robust against noisy data and can handle a large
number of features. It also provides feature importance scores, indicating
which features are more influential in making predictions.

26
Intro to Machine Learning Deepak Silaych

11.3 Applications
Decision Trees and Random Forest find applications in various domains:

• Customer Churn Prediction: They can predict whether a customer


is likely to churn (leave) a service based on their interactions with the
company.

• Medical Diagnosis: They help in diagnosing diseases based on pa-


tient symptoms and medical test results.

• Credit Risk Assessment: They can assess the risk associated with
lending money to a customer based on their financial history.

• Object Detection: They are used in computer vision tasks to detect


objects in images or videos.

27
Intro to Machine Learning Deepak Silaych

11.4 Conclusion
Decision Trees and Random Forest are powerful and easy-to-understand ma-
chine learning algorithms. They can be used for classification and regres-
sion tasks, making them versatile tools in various applications. Decision
Trees provide transparent models, while Random Forests improve accuracy
by combining multiple trees. Understanding their principles and advantages
can help us make informed decisions about using them effectively in real-
world machine learning projects.

28
Intro to Machine Learning Deepak Silaych

12 Neural Networks
Neural Networks are a class of powerful machine learning algorithms inspired
by the human brain’s neural connections. They excel in solving complex
problems and have led to significant advancements in various fields.

12.1 Understanding Neural Networks


A Neural Network is composed of interconnected nodes, called neurons, orga-
nized into layers. The three main types of layers are the input layer, hidden
layers, and the output layer. Each neuron takes inputs, applies weights to
them, and passes the result through an activation function to produce an
output. The activation function introduces non-linearity, allowing Neural
Networks to model complex relationships in data.

12.2 Deep Learning and Deep Neural Networks


When a Neural Network has multiple hidden layers, it is known as a Deep
Neural Network, and the technique is called Deep Learning. Deep Learn-
ing has revolutionized various domains, including computer vision, natural

29
Intro to Machine Learning Deepak Silaych

language processing, and speech recognition The term ”deep” comes from
the depth of the network, which refers to the number of hidden layers. Deep
Neural Networks can learn hierarchical representations of data, making them
more capable of handling intricate patterns.

12.3 Applications of Neural Networks


Neural Networks have found applications in a wide range of fields:

• Image and Speech Recognition: They are used to recognize objects


in images and transcribe speech into text.

• Natural Language Processing (NLP): Neural Networks power lan-


guage translation, sentiment analysis, and chatbots.

• Autonomous Vehicles: They enable self-driving cars to perceive the


environment and make decisions in real-time.

• Healthcare: Neural Networks help in diagnosing diseases from medi-


cal images and predicting patient outcomes.

• Finance: They are used for stock market prediction and fraud detec-
tion.

12.4 Challenges and Advancements


Training Neural Networks can be computationally expensive and requires a
large amount of labeled data. To address these challenges, researchers have
developed techniques like transfer learning, data augmentation, and more
efficient architectures.

30
Intro to Machine Learning Deepak Silaych

13 Convolutional Neural Networks (CNN)


Convolutional Neural Networks (CNN) are a specialized type of Neural Net-
works designed for computer vision tasks. They have revolutionized im-
age and video processing, achieving state-of-the-art results in various visual
recognition tasks.

13.1 Understanding CNN


CNNs are inspired by the visual processing of the human brain. They have
learnable filters, called kernels or feature detectors, that slide over the input
image to detect patterns and features. The output of this process is called
feature maps, highlighting important regions in the image. In CNNs, we stack
multiple layers of convolutions, non-linear activations, and pooling operations
to learn and represent hierarchical features in the data. The final layers often
consist of fully connected layers for classification.

13.2 Applications of CNN


CNNs find applications in various computer vision tasks:

• Image Classification: They can classify images into different cate-


gories, like identifying objects or animals.

31
Intro to Machine Learning Deepak Silaych

• Object Detection: CNNs can locate and identify multiple objects in


an image or video.

• Semantic Segmentation: They help in segmenting an image into


different regions and labeling each pixel with the corresponding class.

• Facial Recognition: CNNs are used in facial recognition systems for


biometric identification.

13.3 Project: Sign Language Recognizer

In the context of sign language recognition, Convolutional Neural Networks


have proven to be highly effective. They can automatically learn the visual
patterns and gestures present in sign language images, enabling accurate
recognition.
My project, a Sign Language Recognizer built using CNN, is an excellent
example of how CNNs can be applied to real-world applications. Utilizing
libraries like MediaPipe, TensorFlow, and OpenCV, you successfully devel-
oped a system that can understand sign language gestures and convert them
into meaningful text.
Here is the link to my project video: https://shorturl.at/cmGP9
My work in this project showcases the power of Convolutional Neural
Networks can enhance accessibility and improving the lives of individuals

32
Intro to Machine Learning Deepak Silaych

who use sign language as their primary means of communication.

13.4 Conclusion
Convolutional Neural Networks have significantly advanced the field of com-
puter vision, and your project is a testament to their potential for solving
real-world problems. By utilizing CNNs and other related technologies, we
can continue to innovate and develop intelligent systems that positively im-
pact society in various ways. Keep up the great work in leveraging machine
learning and computer vision to create meaningful applications like your Sign
Language Recognizer!

33
Intro to Machine Learning Deepak Silaych

14 Testing and Evaluation


Testing and evaluation are essential steps in machine learning to assess how
well our models perform on new, unseen data.

14.1 Train-Test Split


To evaluate a machine learning model, we split our dataset into two parts:
the training set and the testing set. The training set is used to train the
model, and the testing set is used to measure its performance.

14.2 Evaluation Metrics


There are various evaluation metrics to measure the model’s performance,
depending on the task type. For classification tasks, we use metrics like ac-
curacy, precision, recall, and F1-score to measure how well the model predicts
the correct class labels. For regression tasks, we often use mean squared error
(MSE) or mean absolute error (MAE) to measure the difference between the
predicted values and the actual target values.

14.3 Cross-Validation
Cross-validation is a technique used to get a more robust estimate of a model’s
performance. Instead of a single train-test split, we perform multiple splits
and average the results. Common cross-validation methods include k-fold
cross-validation and stratified k-fold cross-validation.

14.4 Overfitting and Underfitting


Overfitting occurs when a model performs well on the training data but
poorly on unseen data. It means the model has learned noise and does not
generalize well. Underfitting, on the other hand, occurs when the model is
too simple to capture the underlying patterns in the data, resulting in poor
performance on both the training and testing sets.

34
Intro to Machine Learning Deepak Silaych

15 Ending and Personal Reflection


As I conclude this report on Machine Learning, I am filled with a sense of
accomplishment and excitement. Building this report for the Summer of
Science event has been a rewarding experience, allowing me to delve deeper
into the fascinating world of machine learning.
Throughout this journey, I have gained valuable insights into various ma-
chine learning algorithms and their applications. From the basics of super-
vised and unsupervised learning to advanced techniques like Convolutional
Neural Networks, I have explored the diverse landscape of machine learning.
Creating sections on different algorithms, their implementations, and real-
world use cases has not only enhanced my technical skills but also improved
my ability to communicate complex ideas in a clear and concise manner. It
has been a wonderful platform to engage with like-minded individuals, learn
from their projects, and inspire each other in the field of machine learning.
As I look forward to the future, I am eager to continue my learning journey
and explore the latest advancements in machine learning. I am excited to
apply the skills and knowledge I have gained to tackle new and exciting
projects that contribute to the advancement of artificial intelligence.
In conclusion, building this report has been an enriching experience, and
I am grateful for the support and encouragement I received throughout this
process. I hope that this report serves as a valuable resource for those in-
terested in machine learning and inspires others to embark on their journey
into this dynamic and ever-evolving field.
Deepak Silaych

35

You might also like