Lecture 6 - AI and ML
Lecture 6 - AI and ML
2
Introduction to Machine learning
A Story by Google Bard
Imagine you're a parent teaching your child how to identify different types of
animals. You show them pictures of various animals, pointing out the
characteristics of each one, such as a dog's floppy ears, a cat's sharp claws, or a
bird's wings. As you show them more examples, your child starts to recognize the
patterns and can eventually identify new animals on their own.
This is similar to how machine learning works. Instead of a parent teaching a child,
we have a computer algorithm learning from data. We feed the algorithm a lot of
examples, labeled with the correct answer, and it starts to recognize the patterns
that separate different types of data. Once the algorithm has learned these patterns,
it can be used to make predictions about new data that it hasn't seen before.
There are two main types of machine learning: supervised and unsupervised. In
supervised learning, we provide the algorithm with labeled examples, meaning the
data is already tagged with the correct answer. This is like teaching a child by
pointing out the different characteristics of each animal. In unsupervised learning,
we don't provide the algorithm with labeled examples, so it has to figure out the
patterns on its own. This is like letting a child explore a zoo and try to figure out
which animals belong to which groups.
3
What is Machine Learning?
Let’s say you want to program a computer to recognize cats in pictures, you would
need to write code that explicitly defines all of the features of a cat. This would be
a very difficult task, as there are many different features that make up a cat, such as
its fur, eyes, ears, and nose.
Machine Learning (ML) algorithms can learn to recognize cats in pictures without
being explicitly programmed. They do this by training on a dataset of images that
are labeled as either containing a cat or not containing a cat. The algorithm then
looks for patterns in the images that are correlated with the labels. Once the
algorithm has learned these patterns, it can be used to predict whether or not a new
image contains a cat.
Definition of ML
4
rules, ML algorithms can analyze data and identify patterns to make predictions or
decisions.
● Supervised learning:
In supervised learning, the computer is given a dataset of labeled
examples. The goal is to train the computer to learn the relationship between
the inputs (features) and the outputs (labels) so that it can make accurate
predictions for new, unseen data. For instance, a supervised learning
algorithm could be trained to classify images of cats and dogs based on a
dataset of labeled images.
Features Labels
House ID Bedrooms Bathrooms Area (sq. ft.) Location Sale Price ($)
5
Labels: Whether each image shows signs of a particular medical condition
● Unsupervised learning:
In unsupervised learning, the computer is given a dataset of unlabeled
data. The goal is to find patterns or structure in the data without being told
what to look for.
Example: Suppose you are given the following set of images. And you are
to cluster them into two groups. How would you group them?
Group by Gender:
Group 1
6
Group 2
Well that is one possible feature to group them. How about this grouping?
Group 1 Group 2
●
7
● Self-supervised learning: Self-supervised learning bridges the gap between
supervised and unsupervised learning by generating labels or supervisory
signals from the data itself. This method has gained traction in recent years
due to its ability to handle large amounts of unlabeled data without relying
on expensive manual annotations.
8
In self-supervised learning, the system is trained to predict hidden parts of
the input (in gray) from visible parts of the input (in green).
As a result of the supervisory signals that inform self-supervised learning,
the term “self-supervised learning” is more accepted than the previously
used term “unsupervised learning.” Unsupervised learning is an ill-defined
and misleading term that suggests that the learning uses no supervision at all.
In fact, self-supervised learning is not unsupervised, as it uses far more
feedback signals than standard supervised and reinforcement learning
methods do.
● Reinforcement learning:
In reinforcement learning, the computer learns through trial and error
by interacting with an environment. The goal is to maximize the reward
signal received by the computer. This is much like how you can train a dog
to do tricks. For example, a reinforcement learning algorithm (usually a deep
neural network) could be used to train a robot to play a game by rewarding it
for making successful moves.
9
In reinforcement learning the issue sometimes is that we set up the rewards
wrong, do not know how to set up the rewards, or the machine finds
unexpected ways to maximize its rewards and does something that was not
what it was designed to do. Many new algorithms are developed very
recently to tackle such problems. This is one of the most exciting areas in
machine learning.
10
Discussion Points and Questions
Application Scenarios:
11
Scenario: Detecting unusual patterns in network traffic to identify potential
cybersecurity threats.
Question: Is supervised, unsupervised, or reinforcement learning better
suited for detecting anomalies in network data?
12
Can the model identify abnormal patterns in the absence of labeled
anomalies (unsupervised)?
13
Machine Learning Models [Optional]
KNN is a simple, yet powerful, machine learning algorithm that can be used for
both classification and regression tasks. It is based on the idea that similar data
points are likely to have similar outcomes.
- Class A (Dog)
- Class B (Cat)
Look at this image, there are two different data points, let’s say they represent two
different classes, class A or red triangles represent images of dogs and class B, blue
squares represent images of cats. But don’t know what the green circle represents,
we have to classify this green circle, is it a cat or a dog?
14
Decision Trees
Below is an example of a machine learning model that is called a decision tree. The
box in the top of the diagram labeled “Age” is called the root of the tree and the
boxes labeled “Granted” or “not Granted” are the leaves. A decision tree is more
like a tree drawn upside down.
This particular decision tree is a simplified model that illustrates how a bank might
use a person's age, income, average monthly savings amount, and credit duration to
decide whether or not to grant them a loan. A set of data like the one below with
the actual loan granting decision made is used in the decision tree.
.
Age Income Average Monthly Credit Decision
Savings Amount Duration
15
35 160000 630 40 Not Granted
… … … … …
See if you can figure out what will happen if the decision tree is asked to make a
decision on the following data:
38 162000 650 37 ?
Artificial Neural Networks are networks of Artificial Neurons which are basically
mathematical models of neurons in the brain. These models have become one of
the most popular and useful models in recent years.
Biological Neurons:
In our brains, we have billions of tiny cells called neurons. These neurons receive
signals from other neurons through connections called synapses. When a neuron
gets enough signals, it "fires" an electrical signal down its own length, passing the
message to the next neuron in the chain.
Artificial Neurons
Artificial neurons are like simplified versions of these biological neurons. They
receive inputs (like the signals in our brains), each with a different importance (like
the strength of the synapses). The artificial neuron then adds up these weighted
inputs and decides whether to "fire" or not, just like a biological neuron.
16
Figure: Biological neuron and artificial neuron
● Inputs: The inputs to an artificial neuron are the values from other artificial
neurons or from external data sources. These are x1, …, xn in the diagram
above.
● Weights: The weights of an artificial neuron determine how much influence
each input has on the neuron's output. These weights are w1, w2, …, wn.
You can also see x0=1 and a bias b in the diagram above. These are used to
compute the weighted inputs (Z) in the following way:
● Z = x1*w1 + x2*w2 + … + xn*wn + b
● Activation function: The activation function of an artificial neuron
determines the neuron's output (y) based on the weighted inputs (Z). An
example of activation function is the step function
○ y = step(z): if z > 0 then y = 1, otherwise y = 0.
17
Check out this artificial neuron. This is supposed to compute the logical AND of
the two binary inputs x1 and x2. Examine for each input pair, how it computes the
desired output.
Can you create an artificial neuron that can compute OR and the NOT operations?
Can you combine them in some way to construct networks of artificial neurons that
can compute NAND and XOR operations of the inputs.
18
Neural networks are typically organized into layers. The first layer of a neural
network is called the input layer. Each neuron in the input layer receives a single
input value. The last layer of a neural network is called the output layer. Each
neuron in the output layer produces a single output value or multiple outputs.
The layers between the input layer and the output layer are called hidden layers.
The hidden layers are responsible for learning the complex relationships between
the data and the output. Learning algorithms set the weights of each neuron in a
way so that the output layer produces the desired output (or something close to it)
for a particular input.
So, while artificial neurons and neural networks are simplified versions of their
biological counterparts, they borrow the concept of interconnected decision-makers
from our brains to perform tasks and learn from experience.
19
Deep Learning
Deep learning is a type of machine learning that involves using artificial neural
networks with many layers, often referred to as deep neural networks. The term
"deep" comes from the idea of having multiple layers (deep architectures) in the
network.
Deep learning models are typically very large, with millions or even billions of
parameters. This allows them to learn very complex patterns from data, and to
achieve state-of-the-art performance on a wide range of tasks. For example, deep
learning models have been used to achieve superhuman performance on tasks such
as image recognition, natural language processing, and speech recognition.
Here are some of the most popular types of deep learning models:
20
● Transformer architecture is another significant development in the realm of
deep learning, especially in natural language processing (NLP). Transformer
models are based on the principle of self-attention, which allows them to
learn long-range dependencies between words in a sentence.
These models typically try to represent each input image, text data (words,
sentences, documents) or audio as a list of numbers (vectors) so that similar
images, text data or audio have similar representations. These representations are
called embeddings. This becomes useful when we try to then use neural networks
to classify inputs or reproduce similar inputs. Below is an example visualization of
book embeddings. Embeddings themselves are not two dimensional but are
projected into two dimensions (tSNE is a type of visualization technique) for
visualization. Here we can see that embeddings of books of the same genre are
clustered together quite nicely.
21
Deep learning models are still a relatively new area of research, but they have
already had a significant impact on the field of artificial intelligence. Deep learning
models are now being used in a wide range of applications, including:
Generative Models
A generative model is a type of machine learning model that aims to learn the
underlying patterns or distributions of data in order to generate new, similar data.
In essence, it's like teaching a computer to dream up its own data based on what it
has seen before. The significance of this model lies in its ability to create, which
has vast implications in various fields, from art to science. Examples include
LLMs, Diffusion based image generators.
ChatGPT:
As daylight wanes, a crimson sky unfurls,
Autumn whispers secrets to the world,
Leaves rustle, painting paths in gold,
A crisp embrace, the air's story told,
Twilight's hush in the evening's reign,
A fleeting dance before night's domain.
Asked to translate the first paragraph of this section this is what it produced
22
Prompt: You are an expert translator. Your task is to translate the following text to
Bangla. Please make sure the translated text is natural, easy to follow, and has
literary quality to it.
[...text…]
ChatGPT:
একটি জেনারেটিভ মডেল হল মেশিন লার্নিং মডেলের এক ধরন, যা তথ্যের নিচে লুকিয়ে থাকা প্যাটার্ন বা তথ্যের
বিতর্কি ত বিতর্কি ত ভাগবিভাজন শেখার লক্ষ্যে তার সামনে নতু ন, অনুরূপ তথ্য তৈরি করা। মূলত, এটি হলো যে, যেটি
কোম্পিউটারকে শিখানোর মতো, যাতে তা আগে দেখা তথ্য ভিত্তিক নিজের তথ্য সৃষ্টি করতে পারে। এই মডেলের গুরুত্ব
সেই সৃষ্টিশীলতায় অবদান, যা বিভিন্ন ক্ষেত্রে, শিল্প থেকে বিজ্ঞানে বিশাল প্রভাব ফেলে।
However, these models can produce incoherent images too. See 5 things AI image
generators still struggle with | Digital Trends
23
● Improved decision-making: ML algorithms can analyze large amounts of
data and identify patterns that humans might miss, leading to better
decisions.
● Automation: ML can automate tasks that are repetitive or time-consuming,
freeing up human workers to focus on more creative and strategic work.
● Personalization: ML can personalize products, services, and
recommendations to individual users, providing a more tailored experience.
● Innovation: ML is driving innovation in a wide range of industries, leading
to new products, services, and processes.
24
Distinguishing the terms ML, DL & AI
Artificial Intelligence (AI) is a broad term that refers to the ability of machines to
perform tasks that are typically associated with human intelligence, such as
learning, reasoning, and problem-solving.
Deep Learning (DL) is a subset of ML that uses artificial neural networks to learn
from data. Neural networks are inspired by the human brain, and they are able to
learn complex patterns from data.
25
Why is AI a big deal?
Why now?
26
○ NVIDIA A100 delivers 312 teraFLOPS (trillion floating point
operation per seconds) of deep learning performance.
● The rise of big data, which provides AI systems with more information and
examples to learn from and discover patterns and insights.
○ Big data is a large and complex collection of data that is constantly
growing. It can be structured, unstructured, or semi-structured. Big
data is generated and transmitted from many sources.
○ Sources of big data, including, social media, IoT systems, Banking,
Audio Video, Government and Public Data, Research and Scientific
data, and so on.
● The adoption of cloud-based computing, which enables AI systems to access
and share data and resources across different platforms and devices.
○ Cloud computing is the on-demand availability of computing
resources (such as storage and infrastructure), as services over the
internet. It eliminates the need for individuals and businesses to
self-manage physical resources themselves, and only pay for what
they use.
○ Some cloud computing platforms – Amazon web services (AWS),
Microsoft Azure, Google Cloud Platform (GCP), etc.
27
Ethical issues and other Problems with AI
On the other hand, AI poses more real dangers. Here we discuss a couple of them:
AI, led by large companies, holds immense potential but also raises concerns about
intensifying inequalities. It threatens widespread job displacement, with estimates
suggesting up to 800 million jobs could be automated by 2030. Moreover, the
advantage lies with large companies equipped to develop and deploy superior AI
systems, further widening the wealth gap. To counter these effects, retraining and
reskilling programs are crucial to help displaced workers adapt to the AI-driven job
market. Governments, businesses, and educational institutions must collaborate:
governments can fund training programs, businesses can provide apprenticeships,
and educational institutions can adapt curricula for the AI era.
Bias and discrimination can be introduced at various stages, from data collection
and preparation to modeling and analysis, and even interpretation and
communication. Biased datasets in the context of AI refer to datasets that do not
adequately represent the diversity of the real-world population, leading to skewed
or unfair outcomes when machine learning models are trained on them. For
example, consider facial recognition technology trained predominantly on images
of lighter-skinned individuals. When faced with faces of darker skin tones, this AI
system might struggle.
28
underscore uncertainties—highlighting the evolving nature of data ownership in
AI. Clear data governance, contracts, and legal compliance offer potential solutions
in navigating this intricate issue.
29
AI alignment is the process of ensuring that AI systems are aligned with human
values and goals. It is important because AI systems are becoming increasingly
autonomous and are making decisions that have a significant impact on our lives.
Without AI alignment, there is a risk that AI systems could act in ways that are
harmful to humans.
8. AI singularity?
30
Discussion Points
31
How to build AI systems?
32