Lets Learn AI Base Module PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 196
At a glance
Powered by AI
The document discusses different roles in NITI Aayog working on AI initiatives like Let's Learn Artificial Intelligence program. It also mentions the estimated global and Indian market size of AI by 2030.

The different roles discussed are of Dr. Rajiv Kumar (Vice Chairman of NITI Aayog), Shri Amitabh Kant (CEO of NITI Aayog), Shri Ramanathan Ramanan (Mission Director at Atal Innovation Mission, NITI Aayog).

It has been estimated that by 2030, the global market in AI is likely to be in the range of 15 – 15.5 trillion dollars out of which India’s share will be close to a trillion.

Let's Learn Artificial Intelligence - Base Module

LET’S LEARN
ARTIFICIAL
INTELLIGENCE
FEBRUARY 2020 | BASE MODULE

1
DR. RAJIV
KUMAR
VICE CHAIRMAN,
NITI AAYOG
SHRI
AMITABH
KANT
CEO,
NITI AAYOG
SHRI
RAMANATHAN
RAMANAN
MISSION DIRECTOR
ATAL INNOVATION MISSSION,
NITI AAYOG
DEBJANI GHOSH
President, NASSCOM

I believe consciousness is imbibed at a very young age. Artificial Intelligence, in this


decade (the “Techade”) AI will truly scale up (in applications) to new heights.
Cliched, as it may have come to pass, I do believe we need to make a big impression
on young minds right now about AI’s inexhaustible potential.

It has been estimated that by 2030, the global market in AI is likely to be in the
range of 15 – 15.5 trillion dollars out of which India’s share will be close to a trillion.
The next generation of young Indians will obviously want to challenge the “status
quo” and there’s no gainsaying, they’ll not remain contented with a trillion-dollar
share. Most certainly, they will aim much higher – 2X, 3X or even 5X – to prove ana-
lysts wrong. Frankly, they will be limited only by the magnitude of their aspiration.

Given its impact, we need to introduce AI to students very early so that the right
foundations are built over time and can be leveraged to take the country on a
high-growth path. Responding to the opportunities that lie ahead, it gives me great
happiness that NITI Aayog and NASSCOM have joined hands to roll out training
resources on AI for K12 students.

Under the aegis of Atal Innovation Mission, we have the Tinkering Labs in thou-
sands of schools across the country. The very name suggests a DIY approach to
innovation that provides an ultimate experience to young minds about what it
takes to innovate. In particular, a sandbox approach is much desired so that stu-
dents learn to regroup themselves quickly and move to the next project while
taking the learnings all along.

This is a tremendous opportunity to prep up young minds to be innovative as they


dabble with cutting-edge technology. As a society, it’s our collective responsibility
to ensure the talent pipeline is high on capabilities.
AMIT AGGARWAL
CEO, SSC NASSCOM & CO-ARCHITECT
NASSCOM FUTURESKILLS

At a recent technology conference, a participant shared how his 8-year-old


daughter explained to the class about robots during a science fair: ‘A robot is
like a miniature human that scientists have designed – it is learns and behaves like
humans. The robot can store information and can keep on learning on its own’.

Impressed that such a young mind could comprehend what we believe is a


complex topic that engineers should study, another gentleman asked ‘My son is
6 years old. When should I start teaching him about the world of technology?’
Pat came the reply ‘Right Now! You are already 6 years late.’

From cars that can drive themselves to smart toys to smart home appliances to
educational robots, there are already multiple instances of children being
surrounded by AI-enabled products. The pace of change is unprecedented and our
children will be sur-rounded by AI-enabled applications as they grow into adults.
Hence, it is imperative that we equip them with the right tools as early as
possible to start understanding the human-tech ecosystem they will live in as
they gradually transform into Generation AI.

For me, nothing is more exciting than seeing our children leverage technology
to fuel their imagination and spark their creativity. The world of technology is
fun; and a little nudge in the form of this AI module is going to create an
environment of l
earning-by-fun, fueled by curiosity & innovation.

This module was developed after numerous interactions with Atal Tinkering Labs
(ATLs) in schools and reviewing the engagement and performance of students with
current ATL set-up. During the process we spoke with teachers and students across
the country along with the subject matter experts from the industry and leading
pedagogy specialists. The module is an outcome of substantial research
undertaken on various models and content deployed across various contexts, both
at national and international level.

At the Tech Sector Skills Council NASSCOM, we earnestly believe that building a
strong foundation in emerging technologies like AI is critical for embarking
upon a journey towards making India a hub of digital talent. Our FutureSkills®
initiative is a step in that direction and our collaboration with Niti Aayog & Atal
Innovation Mission would accelerate our vision to educate and skill 4 million people
in the new, emerging technologies.

We are super excited to have co-created this learning resource together with the
government and as it is formally being rolled out to K-12 students across the
nation, it’s just a matter of time to witness the unfolding of magic in the making.
Preface
To make India, a 5 trillion USD economy India needs to
harness her creative potential to create an innovation-led
growth model to help transform our nation into a New India.
In keeping with this objective, Atal Innovation Mission, NITI
Aayog at the school level, is setting up state of the art Atal
Tinkering Labs (ATL) at schools in all districts across the
country. These ATLs empowering the students with the
‘skills of the future’, which include computational thinking,
Internet of things (IoT), artificial intelligence, design
thinking, advanced robotics.
Artificial Intelligence (AI) is a key driver of the Fourth Industrial Revolution, more
popularly defined as cognitive science with the right mix of interdisciplinary fields
such as science, mathematics, computing, philosophy, and others. The applications
of artificial intelligence are growing everyday as more people are devising new
techniques.
The ATL AI-Base Module is introduced with the objective that students leverage
the full potential of their Atal Tinkering Lab, the latest technologies introduced in
the labs and the various equipment’s installed there. The students can themselves
ideate, create, and thereby self-learn unleashing the ‘Student-Maker’ in them on
their path to game-changing inventions.
The module, contains activities that enable young innovators to interact with
different forms of artificial intelligence, view videos and engage in experiments.
It follows a simple approach with the sheer objective to introduce young minds
to the ‘magic’ of artificial intelligence. The students work through activities and
learn the various concepts of AI. The hands-on module is formulated to propel the
young minds to contribute to the ecosystem of innovation.
My special acknowledgement for the team at NASSCOM, for their endless support
and commitment towards shaping and designing this module. This would not
have been possible without their hard-work and dedication.
This is an initial step to empower students, teachers and the schools, with the latest
technologies. So lets’ all together celebrate curiosity and imagination as the key
pillars to problem solving and innovation.

Happy Tinkering J

(Dr. Ayesha Chaudhary)


Atal Innovation Mission, NITI Aayog
TABLE OF
CONTENTS
UNIT 1 1-18
Introduction to AI
1.1 Human Intelligence
1.2 Artificial Intelligence
1.3 Why Do We Need AI?
1.4 Applications of AI
1.5 What are Key Components of AI?
1.6 Future of AI

UNIT 2 19-46
Learning
2.1 Human Learning Process
2.2 Computer or Machine Learning
2.3 Learning Human Abilities
2.4 Speech Recognition
2.5 Computer Vision

UNIT 3 49-79
Data
3.1 Introduction to Data
3.2 Datasets
3.3 Types of Data
3.4 Database
3.5 Datascience and Big Data
3.6 Computational Data

UNIT 4 81-105
Data Visualisation
4.1 Algebra and Probability
4.2 Role of Statistics
4.3 Data Visualisation
UNIT 5 107-134
Problem Solving and Decision Making
5.1 Introduction to Problem Solving and Algorithms
5.2 Pseudocode - Writing Basic Algorithms
5.3 Searching and Sorting Algorithms

UNIT 6 139-159
AI Languages
6.1 AI and Computer Programming
6.2 Scratch
6.3 Python
6.4 Top AI Languages in 2020

UNIT 7 161-173
Ethics and AI
7.1 Ethics and AI

Here's more for the AI Enthusiast 174-175

Acknowledgement176-177

Disclaimer: The content in this handbook has been curated from various online sources. We do not
intend to infringe on any copyrights.
Note: This document contains several weblinks and associated QR codes. The relevant documents and
video can be accessed either by clicking the weblink or by scanning the QR code using QR code scanner
application, which can be downloaded on any smartphone via the application store. Please note that
there are third party links in this module and Atal Innovation Mission or NITI Aayog or NASSCOM does
not endorse any person(s) or organisations mentioned on or related to these links.
Let's Learn Artificial Intelligence - Base Module

UNIT 1
INTRODUCTION TO AI

Key Learning Outcomes


At the end of the module, you will be able to:
a) Use selected AI applications online to explore various
types of AI
b) Recognize AI applications in everyday life
c) Identify the various types of problems that AI can solve

Topic Covered
Human Intelligence | Artificial Intelligence | Need for AI
Applications of AI | Key components of AI | Future of AI
1.1 HUMAN INTELLIGENCE
What makes us Humans, intelligent? Humans have brains, is that why we are
intelligent or do we become intelligent if we learn to use our brains well?

Here is a question for you to think about:

When are we called intelligent? [Tick the right answer]


When we can give correct answers to people’s questions.
When we solve a difficult problem or puzzle.
When we can decide the correct action to be taken.
When we learn something fast.
When we are able to recognize many things and remember their names.
When we can use clues to guess an answer.

All of these are examples of natural human intelligence!

So, what defines Human Intelligence?

Human intelligence is defined in many ways; some common aspects across various
definitions include:

Ability to observe, Ability to make Ability to learn


recognize and ‘smart’ decisions and increase
understand and solve problems knowledge

Gathering Analyzing
Information Information

Human
Storing
intelligence Decision Making
Information
involves

Retrieving
Taking Action
Information

Any agent who can perform the above is called an Intelligent Agent.

2
Let's Learn Artificial Intelligence - Base Module

1.2 ARTIFICIAL INTELLIGENCE


Computers are man-made and hence they are artificial. They don’t have brains like
ours.
Think about the following:

What do we use a computer for?

List things a computer can do better than humans ?

List things that humans can do, but computers cannot ?

So, can we call computers intelligent?

3
WHAT IS ARTIFICIAL INTELLIGENCE?
It is the ability to imitate humans (such as using language/speech, vision/image
recognition, making predictions, learning, problem-solving, ability to move and
manipulate objects on their own)
An Artificial Intelligence Agent is a computer that can perform these activities.

Artificial Intelligence (AI) is


Teaching the machines to
learn, think, decide and act as
humans would.

How do humans act? List things that humans do.

Now think, which of these things can a computer do?

Do you think an AI can produce Art? Can it write and sing songs, write stories, draw
paintings or interact with humans and have a conversation?

4
Let's Learn Artificial Intelligence - Base Module

EXPLORE

To hear more about what artificially intelligent machines can learn and do
listen to this very interesting Talk by Jeremy Howard, who is a data scientist.
“Get caught up on a field that will change the way the computers around
you behave ... sooner than you probably think.”

https://www.ted.com/talks/jeremy_howard_the_wonderful_and_terrifying_implications_
of_computers_that_can_learn

But how do we impart the ability to think and learn like humans on the machines?
We program computers to enable them to identify things, understand the relationship
between them, predict and decide what to do, in various situations. AI, therefore, is the
application of computing to solve problems in an ‘intelligent’ way using computer
programs. The steps to solve these problems are commonly written in the form of
algorithms, we will learn more about these later.
So, what is an intelligent way?
Well, an intelligent way is how humans use their senses, brain, and abilities to make
decisions that help them towards the goal they want to achieve, autonomously (without
being controlled directly by others). Similarly, AI involves computers completing a
task automatically with very little to no human intervention. Here, a computer uses its
capabilities for gathering information, analyzing it to make decisions and act.
Let us look at the video to understand more:

EXPLORE

This video talks about the development of computer systems to perform tasks that
normally require human intelligence.

https://www.youtube.com/watch?v=xR6j9TLZdAw

If a computer is intelligent, does that mean it has a consciousness of its own, i.e. is it
self-aware?

5
AI doesn’t mean that a computer can feel, or that it has a personality of its own. However,
many researchers have been questioning and studying whether ‘a robot should have
rights’? The Ethics and AI Chapter at the end of this module will explore this further.
Several scientists consider Artificial Intelligence to be somewhat of a misnomer,
suggesting that True AI is still years away. Many believe it will be more accurate to call
the current AI systems ‘Augmented Intelligence’, or the use of machines to extend
human capabilities and what they can do.

EXPLORE

Read more about Augmented and Artificial Intelligence:

https://internetofthingsagenda. https://www.processmaker.com/
techtarget.com/blog/IoT-Agenda/ resources/customer-success/blog/
Augmented-vs-artificial-intelligence- does-augmented-intelligence-
Whats-the-difference enhance-the-customer-experience/

However, there has been a lot of progress made over the years in this field. Now instead
of programming a computer to perform a very narrowly defined specific task, we can
feed it data, let it discover patterns and learn tasks on its own. For example, a computer
may be used to identify pictures of apples or bananas based on color and shape.
Instead of this, we can give the computer lots of pictures of each fruit and program it
to identify apples and bananas based on common features (edges, lines, curves, etc.)
in those images. In other words, we have machines that can make predictions — and
get better at them — based on a library of data. That’s still a far cry from a robot that
can think for itself.

1.3 NEED OF AI?


We need Artificial Intelligence (AI) for many different reasons. These reasons comes
from the fact that now we live in a world where work and its demands are increasing
both in terms of volume and complexity.
Machines can be made to do some functions faster and more accurately than humans.
They can handle large amounts of work. Further, most humans neither like, nor are
particularly good at repetitive tasks.
So, it makes a lot of sense to give all such work to machines, which are
better at these.

6
Let's Learn Artificial Intelligence - Base Module

We can say that we need AI for the following:


To do tasks that humans want to avoid because of the risks involved
To do things faster
To do things that require more power
To be more accurate
To overcome human inefficiency
To achieve consistency
To have machines as companions
To understand how humans function and have evolved

Can you think of anything else?


What if you had a personal AI machine, ‘Your Personal Assistant’?
Name a task that you would want it to do for you?

List the abilities that the machine should have to perform the task for you?

Would your AI need any of the following abilities?

To understand and respond to spoken or written commands


To recognize you and your friends
To see and differentiate between objects, animals, and people
To go from one place to another by themselves
To play games
To do creative work

7
If yes you will be happy to know that we already have AI machines
with these capabilities.

AI Machines have made progress in learning ‘Natural Language Processing’.


They respond to naturally spoken and written language.
AI Machines have made progress in learning ‘Facial Recognition’. They recognize
faces, their gender, age group, ethnicity, and emotions.
AI Machines are developing ‘Computer Vision’ to differentiate between objects
like cats, dogs, trees, walls, people, etc.
AI Machines have made progress in learning to ‘Self-Navigate’. They can select
a route, sense and avoid obstacles like in self-driving cars.
AI Machines have learned Chess, Checkers, Go, Jeopardy, which are very
complex games and beat expert players in these.
AI Machines are learning to do creative work as well like write stories, make
artistic paintings, etc.

EXPLORE

AI, over the years, has developed many new abilities and is being applied
for several new tasks. These include diagnosing diseases, creating art,
driving our cars, flying our aeroplanes, filtering spam from our emails,
doing our laundry, writing stories and translating them, etc. Let’s look
at some of these.
https://www.weforum.org/agenda/2017/10/robots-used-to-feature-in-horror-stories-
now-they-re-writing-them-for-halloween/

EXPLORE

Read, watch and experience some of the AI applications out there.


a) AI to fly planes
https://cai.tools.sap/blog/artificial-intelligence-aviation-introduction/

8
Let's Learn Artificial Intelligence - Base Module

EXPLORE

b) AI and art (paintings, movies, songs, etc.)

https://cai.tools.sap/blog/how-artificial-
intelligence-disrupts-the-art-world/ https://newatlas.com/ai-art-film-
writing-review/46891/

EXPLORE

c) Self-driving/driver-less cars

https://www.youtube.com/
watch?v=EtdNHiV9NMc

https://www.youtube.com/
watch?v=OlLFK8oSNEM

https://www.youtube.com/
watch?v=sRxaMDDMWQQ

1.4 APPLICATIONS OF AI
There are many AI applications, which are growing by the day. Some existing
applications of AI are:
Gaming − AI plays an important role for a machine to think of a large number of
possible positions based on deep knowledge in strategic games. For example, chess.
Natural Language Processing − AI helps us interact with the computer that
understands natural language spoken by humans.
Expert Systems − Machine or software that imitates the decision-making ability of
humans and uses it to provide explanations and advice to the users.

9
Vision Systems − Systems understand, explain and describe visual
input on the computer.
Speech Recognition − There are some AI-based speech recognition systems with
the ability to hear and express in sentences, and understand their meanings when a
person talks to it. For example, Siri, Alexa and Google Assistant.
Handwriting Recognition − The handwriting recognition software reads the text
written on paper and recognizes the shape of the letters and converts them into
editable text.
Intelligent Robots − Robots that are able to perform the instructions given by a human
in an interactive manner.

EXPLORE

To see some of these interesting things


that people are doing with AI, you can
explore the different experiments in
the link provided below:

https://experiments.withgoogle.
com/collection/ai

EXPLORE

Machines are now learning many things


that humans do, such as:
Understanding language
Understanding the emotions behind
the written text and facial expressions
Seeing and understanding images
Analyzing videos to identify people,
keywords and even sentiment
Planning routes
Others
Try out some of them yourself in this site by “Microsoft AI”
https://aidemos.microsoft.com/

10
Let's Learn Artificial Intelligence - Base Module

EXPLORE
Try out the demos in the following link
to see how AI machines can
Describe your pet by just seeing an
image
Paint a beautiful picture as per the
lines drawn by you and much more
https://www.nvidia.com/en-us/research/
ai-playground/

EXPLORE

Want more:
https://lionbridge.ai/articles/10-craziest-ai-
experiments-to-try-online-today/

1.5 KEY COMPONENTS OF AI


The basis of AI is the capability of machines to recognize through visual and auditory
modules, interact through natural language processing modules, reason through
algorithm and store huge data in memory.

EXPLORE

This video talks about the components of AI.

https://www.youtube.com/watch?v=5CKhnw2Zfxw

11
1.6 FUTURE OF AI
See an interesting video on what the future of AI is by clicking the link below:

EXPLORE

“With almost 20 years of business experience, André has a track


record of success with multiple multi-million dollar ventures in several
industries that have spanned across continents. His latest company
works in the field of Artificial Intelligence (AI) and has created a system
that uses evolutionary concepts to self-organize to complete tasks only
previously achievable by humans. Most futurists and experts believe that
by 2035, AI will match and eventually surpass human intelligence. “

https://www.youtube.com/watch?v=xH_B5xh42xc

12
Let's Learn Artificial Intelligence - Base Module

Now let’s do an imagination activity. Think of any device, object or facility. If suddenly
this device or object became intelligent, what do you think it would be able to do?
Write your thoughts on these below.

For example:

13
14
Let's Learn Artificial Intelligence - Base Module

15
16
Let's Learn Artificial Intelligence - Base Module

What have we learned:


Comon aspects of Human Intelligence include:
The ability to observe, recognize and understand
Ability to make ‘smart’ decisions and solve problems
Ability to learn and increase knowledge

Intelligence involves gathering information, storing information, retrieving information,


analysing information, decision making and taking action.

Artificial Intelligence (AI) is teaching the machines to learn, think, decide and act as humans
would.

An Artificial Intelligence Agent is a computer that has the ability to imitate humans (such
as using language/speech, vision/image recognition, making predictions, learning, problem-
solving, ability to move and manipulate objects on their own.

We impart this ability to it by programming it to understand the relationship between things


and decide what to do.

There has been a lot of progress made over the years in this field. Now instead of programming
a computer to perform a very narrowly defined specific task, we can feed it data and let it
discover patterns and learn tasks on its own.

Though currently, AI is able to do all this and more, the real AI is still far away. Many believe it
will be more accurate to call the current AI systems as 'Augmented intelligence' or the use of
machines to extend human capabilities and what they can do.

We still have a long way to go to make a robot that can think for itself.

17
Let's Learn Artificial Intelligence - Base Module

UNIT 2
LEARNING

Key Learning Outcomes


At the end of the module, you will be able to:
a) Breakdown a human action into parts to identify learning
requirements and processes involved
b) Identify the various components of human learning
c) Identify the various ways of machine learning

Topic Covered
Human learning process | Computer or Machine Learning
Learning human abilities | Speech Recognition | Computer Vision

19
2.1 HUMAN LEARNING PROCESS
How do we learn? Think of something you recently learned. How did you learn it?

Can you write down the steps?

Let’s look at an example of how we learn.

I see a flame, I I touch it, I realise I get burnt,


notice the color, it is hot. experience pain
movement, and a change in
flickering, size, the look of my
position, source skin.
and surroundings
of the flame.

1. 2. 3.

Next time I see I don’t like the pain I store the memory
something like the and burnt skin and of the flame, its
flame, I evaluate if decide to avoid it features and
it is a flame, that next time. the surrounding
can burn me and information. I also
cause pain. If it is, I store the feeling of
don’t touch it. heat, pain and burnt
skin in my memory.

6. 5. 4.

20
Let's Learn Artificial Intelligence - Base Module

To understand the human learning process, let us illustrate it through


a simple sequence of activities involved.

Humans see,
Analyze it to
hear or feel Remember it
recognize it
something

1. 2. 3.

Analyze the When


Decide information needed,
(both current and retrieve it
stored)

6. 5. 4.

Human see, Analyze the


Act hear or feel outcome and
the outcome remember it

7. 8. 9.

Now think of something you learned to do and break it down into the steps to match
the sequence outlined above.

21
2.2 COMPUTER OR MACHINE LEARNING
A computer learns in a similar way. However, it needs a lot of information, to ensure
that it recognizes things accurately. Machines need to be trained to make decisions
and to act based on goals.

So, how do you train a computer to identify things? Computers need a lot of informa-
tion to ensure accurate recognition of things.

Now think, how can a computer recognize a flame?

This could be using color, size, shape, origin, temperature, etc.


Once it recognizes the flame, it needs to be trained to make the decision to act, as in
this case, whether it should touch the flame or not?
This is based on the goals set for the computer.
For example, a computer set the goal to extinguish the flame by touching or stamping.
So, it will see a flame and act to touch it and extinguish it, whereas another way to avoid
burning and damage is to see a flame as danger and not to touch it.
Now think, how will a computer differentiate between an actual flame and a photo of
the flame? Write down your thoughts.

22
Let's Learn Artificial Intelligence - Base Module

A wrongly trained computer may try and extinguish the flame in the painting or touch
a live flame again to get damaged. So, is it possible that they can discern based on
temperature, movement, etc?
So, let’s get back to the task you wanted your personal assistant to do for you (From
Unit 1)
Now let us assume you want your personal assistant to cook for you. What do you
think a robot should be able to know and do in order to cook?
One way of arriving at this list is that instead of thinking of what a robot needs, let us
first think of what a human would need to do this.

What are the things one needs to know and be able to do in order to cook?

For example, some of these could be:

Needs to know Able to do


Different types of foods and their recipes Switch On, Switch Off the gas/stove and
regulate the flame
Different types of ingredients Use various types of utensils

Various cooking methods Put and remove utensils from the gas

How to evaluate if food is cooked properly Assess the stage of cooking so as not to
undercook or overheat the food
How to spot spoilage for both raw ingredi- Stir food
ents and food which is being cooked
Wash the ingredients clean

Cut the ingredients as required

Perform cooking by adding the ingredients


in the right sequence at the right time

Evaluate the seasoning by tasting

23
Now select some of these tasks and try and see what senses does a robot need to do
this?

TASKS SENSES

As you may have guessed, in cooking we use the senses, such as:
Sight
Sound
Smell
Taste
Touch

We can provide machines with these capabilities through:


Cameras for capturing images.
Receivers for capturing sound.
Convertors and Speakers to produce sound.
Like we have skin, eyes, ears, mouth, and noses, we provide them with sensing
devices that can act like these. Some of these are called sensors.
Sensors are man-made (artificial) devices, usually made of specific materials and
connected using electronic signals. They sense chemicals, waves, light, and other
things and interpret them.
How will a machine use these senses and the information provided by it? For example,
How will a machine recognize a potato?
How will a machine evaluate the taste of the food? Or smell?

24
Let's Learn Artificial Intelligence - Base Module

The clue is that you will train it. But how?


Let us now carry out an activity to learn how to train a computer.

PROJECT

Open Google chrome and copy this address in it.


https://teachablemachine.withgoogle.com/
Click to 'Get Started'

Start a new project.


Click on Image Project

25
Click the Pen sign (Edit) in front of Class 1
Name Class 1 as Cats
Click the Pen sign (Edit) in front of Class 2
Name Class 2 as Dogs

DOWNLOAD

Access image folders for this activity at the following link.


https://www.aim.gov.in/imagerecognition/catsanddogs

Upload pics Upload pics Click Train


Step 1 given in Part I Step 2 given in Part I Step 3 Model Button
of Folder A in of Folder B in in the Centre
Cats Dogs Widget

Do not switch Now from the


Step 5 tabs or the preview panel, Step 4
screen till the select File from
training is the dropdown.
complete. Ensure Input is on.

Now upload an Now look at


Step 6 image from Folder the output. Step 7
C by clicking on
choose images
from your files or
drag and drop here.

26
Let's Learn Artificial Intelligence - Base Module

The output is the prediction of machine based on the set of data uploaded as training
images of Cats and Dogs. It tells whether the image uploaded from Table C is more
like those in Folder A (Cats) or Folder B (Dogs). The result is given in the output section
as percentages of the likelihood that the image is similar to Class 1 (Cats) or Class 2
(Dogs).
The larger and more accurate the dataset of images in Class 1 and Class 2, the better
the prediction. Let us see how this will happen.

Now take Now let us Now take an


Step 1 images from Step 2 train the Step 3 Image from
Part II of Table model again. Table C and
B and upload upload to the
these in Dogs Preview section
as before.

See the change in output percentages. The closer the result is to 100%, surer the
computer is of the classification. Except for the Cat image, the Cat image is closer to
classification as a Dog than a Cat. This is because the data set is richer on the Dog
side and not on the Cat side. Thus, we got a percentage that indicate the machine is
less sure of the output. Inaccuracies happen when the image data that the computer
receives is not very well defined and distinct.
Now just because more images are uploaded doesn’t automatically translate into
more accuracy. The quality and accuracy of the images is also a factor. In order to
understand this, let us take the following steps:

Input Images Now let us Now upload


Step 1 from Part II of Step 2 train the Step 3 Image from
Table A into model again. Table C into the
Cats and Part preview section
III of Table B and view the
into the Dogs output.

Note that, the bigger and better the Dataset is, the more accurate is the prediction.
This is very important to understand from a ‘bias’ perspective, you will read about it in
the final Unit of this module.
Now you can practice the same using the Burger and Sandwich images provided as well
in the burgersandwiches folder at the same link given earlier, along the catsanddogs
folder. You can also use the voice and pose projects as given at the same link.

27
To understand how the machines learn, let us first look at three common ways that
humans learn. These are:

Through
Instructions

By Trial and Error


or Punishment By Observation
and Rewards

Can you think of some examples for each of these types of learning?
Here is an example of each.

A child is told to cross the


Through
road only when the traffic is
Instructions
stopped on a red light and
the walking sign is green. A
child is told about accidents
and how it can cause pain,
loss and death. This can be
By Trial and Error classified as Supervised
or Punishment By Observation Learning, wherein someone
and Rewards is telling the learners, what is
right and what is wrong.

28
Let's Learn Artificial Intelligence - Base Module

A child sees someone kick a


ball, throw a ball, sit on a ball
Through and hit a ball with a bat.
Instructions
The child then sees different
types of play balls. Without
anyone teaching the child he/
she can then see a ball and
knows the options of what is
By Trial and Error possible to do with the ball.
or Punishment By Observation
This type of learning can be
and Rewards
classified as Unsupervised
Learning, because the child is
learning on his or her own.

Like when you play a game,


By Observation
you learn from failures and
from successes. You avoid
making the same mistakes
and repeat the things that
get you success, practicing
each time to get better. By Trial and Error Through
This is called Reinforcement or Punishment Instructions
Learning. When the results and Rewards
of your action teach you,
what may be the best thing
to do to get the desired
result.

29
Machine Learning takes place in an almost similar manner.
The methods of learning are:
Supervised Learning
Unsupervised Learning
Reinforcement Learning

SUPERVISED LEARNING

In Supervised learning,
the computer is trained
using example inputs
and the correct output.
We feed the features
and their corresponding
labels into the machine in
a process called training.
As you observed in the
exercise involving Cat and
Dog images.
During training, the
rules programmed into
a computer (algorithms)
gradually determine the
relationship between
features and their
corresponding labels without any human intervention. The computer in this case
compared the images we fed into it and their features. It used this comparison to
understood and differentiate features of Dogs and Cats.
This relationship is called the model.
The model, when applied for solving real-world problems can often become very
complex. The number of rules to identify, learn, predict features and outputs can be
many. Complex models with many inter-related rules are called Neural Networks
based on Human Brain Cells known as neurons. But we will learn about these in
later modules.
Once the model provides an output, we determine if more training is required
based on the results it is providing. Every time the machine is trained more as we
did in the activity, the model keeps adjusting itself, to work out the relationship
between the input and output.
The model uses a training data set and a test data set to train and then test the
model, before it is deployed for actual use.

30
Let's Learn Artificial Intelligence - Base Module

UNSUPERVISED LEARNING

Unsupervised learning
only trains using inputs,
and the computer must
figure out how the various
inputs relate to each
other and then it bunches
similar inputs together.
Therefore, the goal is to
identify meaningful and
common patterns in the
data.
To achieve this, the
machine must learn from an unlabelled data set. Unlike supervised data where the
labels on training data provide the machine information on the various input, the
model here has no support on how to categorize each piece of data and makes its
own rules for doing it.

REINFORCEMENT LEARNING

Reinforcement Learning models learns by watching a teacher’s actions where it


gets rewards for achieving the right results.
The idea behind it is that an agent will learn from the environment by interacting
with it and receive rewards for getting the right results and taking the right actions.
Every time it makes a mistake or fails there is a cost associated with it.
So, the machine works out the smallest cost and tries to achieve the goals by working
out how to match the smallest cost in the future. A simple way to think of this is as
“carrot and stick” learning (learning what rewards good behavior and punishes bad
behavior).

EXPLORE

To learn more about Reinforcement Learning watch the video given below.hh

https://www.youtube.com/watch?v=TnUYcTuZJpM

31
ACTIVITY

Now let’s do an activity for understanding how these three learning methods work.
We will do this activity in stages, so do not jump the steps and peep ahead. Follow
instructions as stated.

EXPLORE

Go to this link and download and print


the 16 cards given here. These cards are
printed with individual patterns.

http://www.stoeckl.ai/wp-content/
uploads/2019/12/MLcards_part1.pdf

Ensure you have multiple sets, and if you are printing multiple cards on one sheet, use
a scissor to cut these into individual cards.
Now your task is to mix the cards.
Form groups of 4 persons each and each playing group takes a set of the 16 playing cards.
The task is to divide the cards into 4 groups, which the group thinks belongs together.
Then write down which characteristics or features were used to make the distinction.
Once successfully done, you will know that this is how the machine-learning algorithm
functions, to learn the correct features and characteristics of the features. The
representation of the data as values of the characteristics is crucial. It also shows how
Unsupervised Learning (and a component in it called Clustering) works.

EXPLORE

Now let us see how Supervised Learning


works.
Go to the link below and download and
print the next set of 16 cards.
http://www.stoeckl.ai/wp-content/
uploads/2019/12/MLcards_part2.pdf

32
Let's Learn Artificial Intelligence - Base Module

Like in the first case, ensure the cards and cut out into individual cards.
You will notice that in addition to the pattern already noted in the first set of cards,
these cards have 4 different “objects” to see:
“A”, “B”, “C” and “D”
The task of the groups is now to assign which of the 4 groups from task 1 belongs to
which class of objects (A, B, C or D). The additional cards stand for a set of labeled data,
and the task clarifies the principle of Supervised Learning.
Now for reinforcement learning, we must do the third task. The objective of this task is
to find out in a different way which objects belong to a particular class that is “stronger”
than the other objects. There is no data in the form of a set of “labeled data” that shows
the affiliation to this class. This special property of the objects must be derived by the
group purely from the game behavior.
The rules of the game are as follows:
2 of the 4 players in a group fix one of the 4 categories (A, B, C or D) as a special
category (“trump”) without telling the other two.
The goal of the task is that the other two players find out which cards are of the
“trump category” in the further course of the game.
The 16 cards with the markers are played (second set).
The cards are divided by the 4 players, and each player receives 4 cards.
Each of the 4 players places one card on the table in one round.
The player with the card with the highest number of vertical lines wins the round
and receives all 4 cards. Except when one of the cards involved is from the
“trump” category, it wins. (This can be judged by 2 of the players.)
If there are more cards of the trump category in the round, the trump card with
the most lines wins.
If several players with the same number of lines win, the cards are split.
From the results of the rounds of the game, it must be tried to recognize the “trump”
attribute.
The form of learning which cards (objects) are trumps, practiced in this game, is a form
of reinforcement learning. After each round, a theory of the players is given, which
category is a trump by the round result or is discarded.
With these 3 tasks, the different variants of machine learning can be shown with the
help of the cards.
Source: (Stöckl, 2019)

33
As you will see the 3 basic stages of ML across all forms include

Input Processing Output


(Data) (Algorithms) (Prediction)

Actions may be taken on the output manually or through various connected systems.
In case there is an action based on the output that is taken by an attached device,
then these devices are called actuators, such as the limb of a robot.

EXPLORE

To know more about the difference between “Artificial Intelligence”,


“Machine Learning” and “Neural Networks” watch the video given below:
https://www.youtube.com/watch?v=whlODvf-SVk

2.3 LEARNING HUMAN ABILITIES


As discussed earlier, we are trying to look at how machines can learn the way humans
do. For example, using language/speech, vision/image recognition, making predictions,
learning, problem-solving, ability to move and manipulate objects on their own.

34
Let's Learn Artificial Intelligence - Base Module

So, let us explore some of these and see where we have reached in making the
machines learn these capabilities.
Now, let us look at using language and speech for communicating as humans. Think
about this.

Where are the computer’s ears and mouth?

Do they have a brain to understand?

How do they know which answer to give?

How does a computer provide you with an answer?

How do we get machines to develop some of these abilities that humans have?
Let us take the example of human interactions. When we talk to someone, not only
does the person understand what we are saying, they remember it and respond.

Form a
Listen Understand Respond
Response

The ability to do this in artificial intelligence terms is called Conversational AI.


Conversational AI is the term given to a set of technologies that allow automated
messaging and speech-enabled applications producing human-like interactions
between humans and computers.

35
Conversational AI agents carry out the following functions in order
to communicate like a human:

Recognizing text and speech


Understanding and predicting intent
Interpreting different languages, dialects, and accents
Responding in a way that mimics human conversation

The set of technologies


used in AI to do these are:

Automated Natural
Speech Language
Recognition Processing
Advanced
Dialog
Management

Natural Language Processing may include Natural Language Understanding and


Natural Language Generation.
For now, let us explore Speech Recognition as a part of this.

36
Let's Learn Artificial Intelligence - Base Module

2.4 SPEECH RECOGNITION


EXPLORE

To know the working and use of Speech Recognition, read the following
articles:

https://electronics.howstuffworks. https://www.globalme.net/blog/
com/gadgets/high-tech-gadgets/ the-present-future-of-speech-
speech-recognition.htm recognition

https://www.processmaker.com/ https://chatbotsmagazine.com/
resources/customer-success/ conversational-ai-what-to-
blog/how-artificial-intelligence- expect-in-the-next-five-years-
will-disrupt-speech-recognition/ 26518c8cd385

HOW DO WE LEARN TO UNDERSTAND LANGUAGE?

From the time we are born, we hear words and sounds around us. Even before we can
speak, we hear some words that we start responding to words like Mama, Dada, Yes,
No.
Our brain tries to find patterns to differentiate various sounds and words, and categorize
them. It may seem as though humans are pre-programmed to listen and understand,
but it is not so. We have been trained to develop this ability.
Speech recognition technology has been developed on the same lines. Computers are
also trained in the same way.
Like, we may still make mistakes when we hear new words or the words are not said
properly, computers also make mistakes. In fact, more than humans, usually.
Perfecting these speech recognition systems takes a lot of practice.

37
HAVE YOU USED THE SPEECH RECOGNITION
FEATURE IN YOUR COMPUTER?
Let us see how the computer can recognize what you say and reproduce it on a docu-
ment in a basic speech recognition application.
Windows 10 has a Speech Recognition feature that allows you to perform common
tasks hands-free. Speech Recognition is an easy-to-use experience letting you control
your computer on Windows 10 entirely with speech commands.
You can set up and use this feature to navigate, launch applications, dictate text, and
perform a number of other tasks. Speech Recognition though was primarily designed
to help people with disabilities who can't use a mouse or keyboard.
We will now go through the steps to configure and start using Speech Recognition to
control your computer only with voice. Let us do an activity to experience this.

ACTIVITY

How to configure Speech Recognition on Windows 10

Use the following steps to set up Speech Recognition on your device:


1. Open Control Panel.
Select the Start button.
Type Control Panel.
If you are not using a keyboard, scroll to the bottom of the list of Start options
and open the Windows System folder.
Select Control Panel from the list.
2. Click on Ease of Access.
3. Click on Speech Recognition.

38
Let's Learn Artificial Intelligence - Base Module

Before you set up voice recognition, make sure you have a microphone set up.

Set up a microphone
Select the Start button, then select Settings > Time & Language > Speech.
Under Microphone, select the Get Started button.

4. Click the Start Speech Recognition link.

39
5. In the “Set up Speech Recognition” page, click Next

EXPLORE

Now go to the following link and train your computer to do the task
mentioned below the link.

https://www.windowscentral.com/how-set-speech-recognition-windows-10

40
Let's Learn Artificial Intelligence - Base Module

Task:
Configure Speech Recognition on Windows 10
Train Speech Recognition to improve accuracy
Change Speech Recognition settings
Use Speech Recognition on Windows 10

This is just the start!


You have taken the first step in making your machine just a little smarter. It can
now understand your spoken commands and respond to that. But this is still not AI.
For this speech recognition involves a pre-programmed set of words and actions.
It does not involve evaluating intent, it does not involve the computer choosing its
own appropriate answer to respond.
To experience Conversational AI, you can interact with various Virtual Assistants AIs
like, Alexa, Cortana, Google Home, and Siri.

EXPLORE
To learn more about voice recognition and Virtual Assistants see the video below:

https://www.youtube.com/watch?time_continue=129&v=1e8q_LtH0_o&feature=emb_
logo

2.5 COMPUTER VISION


Speech recognition or Voice recognition enables Conversational AI and other related
applications. Computer Vision is linked to Image and Video Recognition and analysis.
In simple terms, this is a technology of AI with which the robots can see.
In order to understand this, first let us see how humans see. Do you know how human’s
see?

41
You are making noise in You register a person approaching,
the corridor of your school, the image passes through your
and you suddenly notice eyes, followed by the visual signal
your Principal approaching hitting your eye’s retina.

Then this person’s image After being briefly scanned by


is perceived by the rest of your retinas, the data transfers
the cortex and compared to through to the visual cortex in
people’s images in your brain’s your brain for a finer analysis of
database – the person is thus the person’s features (such as
identified, classified, and their height, shape, face and body
dimensions are determined. structure, etc.)

What you get as an output is


an impulse to quickly quieten
down and behave, in order
Yes, Principal is coming.
to not be called out by your
Principal or you duck into the
classroom, just to be safe space
which too has been identified
by your brain as a strategy to
avoid getting caught.

Let’s understand how we function:


Imagine all this has happened in a moment.
Now for machines to do the same with images at a quick speed and with accuracy,
is one of the most challenging tasks. It requires carrying out the functions of the eye
(data capture), the visual cortex (feature extraction), and the rest of our brain (transfer,
matching, etc.) Computer Vision is a combination of all this and teaches machines
how to extract and interpret content from images.

42
Let's Learn Artificial Intelligence - Base Module

Cameras today are well advanced to perform the function of the eye with great
precision, capturing the light variations and transferring and storing these as visual
images.
The real challenge is to write algorithms or software programs that can identify what
the image is and extract meaning from these images. Image capture and processing
device hardware cannot identify and differentiate between even a man and a dog.
Our brains use data of past images, exposure and experiences as context to classify
and identify what we see, so how are we expecting machines to do this?
When a computer sees an image, for example, of a cow, it only sees a massive array
(list) of numbers that represent various intensities and colors of the image, but not the
image itself. There is no context to it, and that is why computers need to get algorithms
to comprehend an image the same way a human does.
This is where machine learning is required to come in and use various statistical
techniques to allow algorithms to learn and improve as they come across new data,
so eventually, they are able to decipher the numbers in a particular sequence which
actually brings out the meaning. In the case of Computer Vision, this data is image
data.
Machines interpret images very simply: as a series of pixels, each with their own set of
color values. Consider the simplified image above, and see how grayscale (Grayscale
is a range of gray shades without apparent color. Black is the darkest possible shade
and white is the lightest shade possible) values are converted into a simple array of
numbers:

Source: Openframeworks

43
By feeding a Machine Learning model enough data, we can make it highly accurate
as we have seen in our Dogs and Cats exercise previously. Presently, Computer Vision
accuracy for image recognition that is achieved in some applications is approximately
95% which is similar to human standards.
The discipline that allows us to somewhat recreate our brain’s system of using
knowledge to make sense of objects is called Deep Learning. We will learn about this
is in detail later, for now, think of it as a large and complex neural network that is used
for the most complex AI tasks.
These special types of neural networks break down each picture into pixels and slide
filters (mathematical objects) across them to detect patterns. At the first level, much
like our brain, these determine things like rough curves and edges within an image. A
few runs after, however, they start piecing together surfaces, info about depth, layers,
gaps in the visual spaces, and, finally, begin to make out objects such as faces, cars,
animals, boxes, etc.

EXPLORE

To learn more, explore the following video:

https://video.sas.com/detail/videos/advanced-analytics/video/5410893556001/face-
recognition-using-sas-viya?autoStart=true

SOME POPULAR COMPUTER VISION APPLICATIONS?


Computer Vision is being used for various purposes in healthcare, agriculture,
insurance, automotive industries, and many other industries.
Healthcare: Computer vision in many cases is providing better detection of diseases
than doctors based on analysis of images of patient anatomy. Machines are becoming
better at predicting diseases such as tumors or cancers looking at images of affected
areas.
Agriculture: The drone technology is providing the opportunity to capture aerial
imagery to help farmers spot intrusions, crop diseases, predict the amount of crop
production, and saves time and avoids the difficulties of physical manual inspections.

44
Let's Learn Artificial Intelligence - Base Module

Automotive: Self-driving cars are the most common example of using computer vision
in the automotive sector, but it is also being used for automatically detecting lanes,
setting speed limits, interpret traffic signage, etc.

EXPLORE

To see an interesting demo of how Computer Vision uses images for


prediction try this demo. Upload a picture of yourself or someone to see
how the computer predicts a 3D face of the person.
https://cvl-demos.cs.nott.ac.uk/vrn/index.php

45
What have we learned
The human learning process involves the following cycle:
Humans see,
Analyze it to
hear or feel Remember it
recognise it
something

1. 2. 3.

Analyze the When


Decide information needed,
(both current and retrieve it
stored)

6. 5. 4.

Human see, Analyze the


Act hear or feel outcome and
the outcome remember it

7. 8. 9.

A computer learns in a similar way. It needs a lot of information to recognize things


accurately. It needs to be trained to make a decision and act based on goals.
Apart from that, we give the machines devices called sensors.
We provide them cameras for capturing images
Receivers for capturing sound
Convertors and Speaker to produce sound.
Sensing devices or sensors can sense chemicals, waves, light, and other things and interpret them.
There are three methods of Machine Learning:
Unsupervised Learning Supervised Learning Reinforcement Learning
The three basic steps of all forms of Machine learning are:
Input (Data) Processing (Algorithms) Output (Prediction)
Conversational AI is the term given to a set of technologies that allow automated messaging
and speech-enabled applications producing human-like interactions between humans and
computers. The set of technologies used in it are Automated Speech Recognition, Advanced
Dialog Management, Natural Language Processing.
Computer Vision is linked to Image and Video Recognition and Analysis. In simple terms, this
is a technology of AI with which the robots can see.
As of now, we have learned how the machine mimics the human learning process and the
components it needs to grow its intelligence. Further, in the next unit, we will explore what
information and how much information is needed to produce accurate output using various
types of data to enhance Artificial Intelligence.

46
Let's Learn Artificial Intelligence - Base Module

UNIT 3
DATA

Key Learning Outcomes


At the end of the module, you will be able to:
a) Identify the use of data in various given activities and applications
b) Recognize different types of data and explore how the same data can
be represented in different ways
c) Capture more than 50 data points for an activity involving multiple
variables
d) Record data across multiple categories in a tabular format
e) Analyze and extract information from represented data as pictures,
symbols and diagrams
f) Convert a simple set of data into binary code
g) Investigate how digital systems represent text, image and audio data
in binary

Topic Covered
Introduction to Data | Datasets | Types of Data | Database
Data Science and Big Data | Computational Data

49
3.1 INTRODUCTION TO DATA
Artificial intelligence is a set of technologies that allows us to extract knowledge from
the data.
It is a system that learns or understands patterns within that data, and can identify
them, and then reproduce them on new information.

WHAT IS ARTIFICIAL INTELLIGENCE?


Data is a collection of facts. The data can be in the form of numbers, words, symbols
or even pictures.
Given below are some examples:

Numbers Words Symbols


70 28 90 YES MAYBE YES

85 100 61 NO NO YES

54 32 97 MAYBE NO NO

As you can see from the above examples it is difficult to extract any information from
this data.

DATA VERSUS INFORMATION


Data consists of raw facts, values and figures, in itself it does not mean anything.
Once it is structured, processed and presented as a response to a question it becomes
information.

DATA PROCESSING
Data processing refers to organizing and performing various operations on collected
data to produce meaningful information.

50
Let's Learn Artificial Intelligence - Base Module

INFORMATION
DATA

PROCESSING
INPUT OUTPUT

LABELING
CLEANING
STRUCTURING
INTERPRETATION
ANALYSIS

To process the data from our earlier example, let us start by providing labels to them.
The labels indicate what the data is and how it is related to other data.

51
The first set of data was, in fact, the data of The second set of data was the result
the marks obtained by some students of declared by the selection committee of
the 5th standard in a maths test. the same set of students for selection in a
dance competition.

Student Name Marks in Maths Test Dance Competition


Student Name
Selection Result
Aarti 70 Aarti YES
Anik 28 Anik MAYBE
Apu 90 Apu YES
Babu 85 Babu NO
Devin 100 Devin NO
Farah 61 Farah YES
Guna 54 Guna MAYBE
Hira 32 Hira NO
Koel 97 Koel NO

The third set of data was of colored geometrical shapes that had to be identified.

RED BLUE GREEN YELLOW BLACK

SQUARE

CIRCLE

TRIANGLE

Then next step is to re-arrange the data in an increasing or decreasing order and then
calculating the totals. This will give a better picture of what the data represents and
we should be able to extract some useful information from it now

Student Name Marks in Maths Test


For example, the information that we can
Devin 100 extract from this data is as follows:
Koel 97
1) 9 students took a test in Maths.
Apu 90 2) 3 of them, namely, Devin, Koel and Apu
Babu 85 got 90 or more.
Aarti 70 3) Devin was the only one who got full
marks and came first
Farah 61
4) 7 out of 9 students got more than 50.
Guna 54 5) Anik got the lowest marks.
Hira 35 6) Total marks of all the 9 students put
Anik 28 together is 620.
7) If the pass marks are 30, then only 1
Total Number
Total Marks: 620 student failed.
of Students: 9

52
Let's Learn Artificial Intelligence - Base Module

ACTIVITY
Student Name Marks in Maths Test
Aarti YES What is the information you can
extract from this data?
Apu YES
Farah YES
Anik MAYBE
Guna MAYBE
Babu NO
Devin NO
Hira NO
Koel NO
Total YES: 3
Total Number
Total MAYBE: 2
of Students: 9
Total NO: 4

YELLOW BLUE RED BLACK GREEN Total

TRIANGLE 4

CIRCLE 3

SQUARE 2

Total 3 2 2 1 1 9

ACTIVITY

What is the information now available from this data?

53
DATA ANALYSIS
Data analysis is about finding useful patterns in data based on the goals or purpose of
the data analysis activity.
Data analysis is very important for Machine Learning. Machines analyze historical and
available data to make predictions and arrive at conclusions for taking action.
It involves the following processes:

Inspecting Segregating Analyzing Making


the data and filtering and making a conclusions
useful data model of the as per the
data to discover goal
meaningful
information

Modelling is the process of finding out the relationships between different parts of
the data and the patterns that can be recognized in it. Models are used to predict
information about new data fed into the system. As we saw in the earlier activity about
Cats and Dogs, the images we fed into the machine was the data. The prediction of
whether the new image was a Dog or a Cat was done by the machine after analyzing
and modeling the earlier data that was fed.

54
Let's Learn Artificial Intelligence - Base Module

Diagnostic Descriptive

Why did it What


happen? happened?

TYPES OF DECISION
How can we BASED ON DATA Predictions
make it happen? ANALYTICS

Prescriptions Predictions

3.2 DATASETS
Artificial Intelligence requires a huge amount of data in order to provide an acceptable
output. When people collectively pool their data, we can collect a huge amount of raw
data. Data is usually organized for the purpose of analysis in Datasets.
Dataset is a collection of related sets of information that is composed of separate
elements but can be manipulated by a computer as a unit.
In the previous example of training the computer on images of Dogs and Cats, we had
two sets of data:
1. Training Data
2. Testing Data

55
A Dataset can be in various forms, such as images, numbers, or texts.
The Dataset lists values for each of the variables, such as the height and weight of an
object, for each member of the Dataset. Each value is known as a datum. Datasets can
also consist of a collection of documents or files.
Let us look at a predictive feature of AI that uses a large Dataset of images received
from numerous people through the internet. It is called “QUICKDRAW”.

ACTIVITY

Let us play a game in pairs.


Draw a shape or picture of an object in the air, and your partner has to guess
what you are making? It requires intelligence to guess, isn’t it?
If the software or a machine has this capability to guess, wouldn’t it have
intelligence?
QuickDraw is a game where you draw a pattern in front of the camera or on a
computer screen and let the computer guess what has been drawn. Although,
it doesn’t always work. However, the more you play with it, the more it will
learn from you. This is a classic example of AI.

https://quickdraw.withgoogle.com/

How to use QuickDraw:


It will ask you to draw a few things within a timeframe of 20 seconds. For
example, it asked me to draw a Bat, Rainbow, Donut, Sun, Basketball, and
Traffic light.

56
Let's Learn Artificial Intelligence - Base Module

If you can see the tick marks under all the drawings, it means that QuickDraw
understood your drawing.
Anyway, the point was that QuickDraw is learning from all the sketches drawn
by human beings. As soon as you start drawing your doodle, QuickDraw starts
guessing it one by one. If it does not understand it, it will reject your drawing
and put a wrong mark there.

The process followed here is:

AI analyzes the The same is Based on these


drawing and compared to comparisons
how one draws all the people the software
Start Sketching
(shapes, order who have predicts
of strokes, done drawings what you are
directions, etc.) in the past drawing

Since many people have probably tried using 'Quick, Draw!' by now, the game is
becoming very good at figuring out what they are drawing, even if the sketches vary
from person to person. The game literally trains itself to guess people’s drawings based
on previous experiences or previous training.
The previous training is done on a Dataset that includes huge amounts of data for
various types of drawings and the final results.

ACTIVITY

A similar application that provides suggestions for your drawing is Autodraw.

https://www.autodraw.com/

57
Now try to attempt to draw a figure such as a bird.

As you will see there will appear various suggestions on the top, which are predictions
of what you are trying to draw. One can select the correct option for a pre-drawn
image of improved quality.
We are selecting the bird here.

58
Let's Learn Artificial Intelligence - Base Module

The predictions are made through machine learning programs working in the backend
that compare your design to previously made designs. It arrives at the closest image
by extracting the features such as individual and combination of shapes, the distance
between lines, edges and curves, etc. These attributes of the image are called features
and the process of identifying those features is known as feature extraction.
In the AI applications discussed above, the Dataset of images in the background holds
all the suggested images that are compared against a drawn Dataset.
So, where are these Datasets and how are they built?
Datasets are owned by organizations. Some are publicly available. You may wonder
that why can’t we keep all data available to the public? We will discuss this in the last
Unit.
Public Datasets or Open Datasets represent the data compiled by various providers
and made public for use in various Big Data or AI applications. Big enterprises such
as Google, Amazon, Microsoft, and others have provided these datasets to the public.
These organizations usually acquire this data from their regular business activity or
work. Some organizations may also purchase data to fill gaps in their own data to
develop required Datasets. This may also add financial value to Datasets.
Explore the various types of data that your school may have and how it has been
collected? Also, think of what information can be derived from this data and what it
can be used for?

59
EXPLORE

Some of the Indian Datasets available can be accessed at the following


link.
http://ml-india.org/datasets/

3.3 TYPES OF DATA


At the highest level, two kinds of data exist, Quantitative (Numerical) and
Qualitative (Non-numerical).

Quantitative Qualitative
Data Data

Numbers and things you Characteristics and


can measure objectively descriptors that can’t be
Dimensions such as Height, easily measured, but can be
Width, and Length observed subjectively
Temperature and Humidity Such as Smells, Tastes,
Prices Textures, Attractiveness, and
Color
Area and Volume

60
Let's Learn Artificial Intelligence - Base Module

Broadly speaking, when you measure something and get a number value, you create
quantitative data, whereas when you measure something and represent it by name,
symbol, etc, you create qualitative data.
So far, so good. But this is just the highest level of data; there are also different types
of quantitative and qualitative data. These data can be further classified into various
types as discussed in the subsequent sections.

ACTIVITY

Collect the following data for at least 10 friends:


Name
Age
Gender (Male/Female)
Height (You can measure this using a scale/ruler)
Hobby
Favorite Subject
Now Identify which part of the data is quantitative and which is qualitative

QUANTITATIVE DATA: CONTINUOUS DATA AND DISCRETE DATA


Qualitative data is the data that is classified based on specific and suitable criteria.
There are two types of quantitative data:
1. Continuous
2. Discrete
Generally, counts are classified as discrete whereas measurements are classified as
continuous.
Discrete data typically involves integers and is a count that cannot be made more
precise. For instance, the number of students in your class or pets in your family is
discrete data, because you are counting whole, indivisible things; you cannot have 21.5
students or 2.3 pets.
Continuous data is can take any value within a range, also called Analog data. A
common example of analog data is the human voice in the air. This is detailed later in
this Unit.
The data that is classified as continuous can be further reduced to finer levels as per
convenience. For example, you can measure the length of a classroom blackboard
more detailed and exact scales i.e. meters, centimeters, millimeters, and beyond — so
length is continuous data.

61
A form of discrete data is Digital data, this is data transmitted in binary format (zeros
and ones). Examples of digital data includes data used in computers, CDs, DVDs, and
related electronic devices.

Here are some examples of discrete data and continuous data for further clarity.

Discrete Continuous
Shoe size Length of foot
Number of Cars one owns Speed of a Car

Number of Dogs A Dog’s Weight


Number of runs scored in a Cricket game Hours of Play in a Game

Number of Questions on a Test Paper Time is taken to complete a Test

ACTIVITY

Going back to the data you collected about your 10 friends earlier, figure out
from the data, which part of the data is Continuous and which is Discrete.

QUALITATIVE DATA: BINOMIAL DATA, NOMINAL DATA, AND


ORDINAL DATA
Qualitative data can be classified into the following types:
1. Binomial Data
2. Nominal Data
3. Ordinal Data
Qualitative also known as attribute data is the data obtained after classification and
categorization based on specific criteria. Let us discuss the types of qualitative data.
Binomial or Binary data places things in one of two mutually exclusive categories:
right/wrong, yes/no, true/false, or accept/reject.
Nominal or unordered data is the type of data that can be separated into discrete
categories that are unique. This category includes any data that is put into groups,
in which there is no inherent order. A common example of nominal data can be a
gender classification i.e. male or female. Some other examples are country of origin,
type of cake, or sport.

62
Let's Learn Artificial Intelligence - Base Module

Ordinal data is the data that is placed in some kind of an order or scale where the
variables have natural and ordered categories. A simple example can be categorization
on the basis of height i.e. short, medium or tall. Another example is ranking an item
on a scale of 10 where 10 is the highest. This implies 10 is better than 9, which is better
than 8 and this trend continues.
The difference between ordinaland nominal data is that the former is placed in some
defined order based on specific criteria whereas the latter names something without
classifying it based on criteria such as numbered objects or pieces of data.

EXPLORE

Here is a brief video that will summarize what we learned about types
of data.

https://www.youtube.com/watch?v=7bsNWq2A5gI

ACTIVITY

Identify Binary and Nominal data from the data you collected and recorded
in a table about your 10 friends.

3.4 DATABASE
Databases offer a convenient and powerful way to store, organize and efficiently
retrieve information.
When you collected the data for 10 friends, you had to write that data down in a
notebook in order. It must have taken a lot of time and effort. What if you had to collect
and store the data for 500 students?
Since AI involves handling large amounts of data, computer programs such as
spreadsheets are used to store, arrange and process that data.

SPREADSHEET
A spreadsheet can be understood as a computer application that allows the users to
organize, analyze and store data in a tabular format. Spreadsheets are commonly used
for applications such as accounting and recording data using rows and columns. The
primary function of this tool is to organize and categorize data into a logical format.

63
See the diagram given below:

Row

Cell
Column

There are 36 cells in the diagram shown above. What if we had to fill data for hundreds
or thousands of cells?
It would be very difficult to draw such a big table. But computers have a software
called “Spreadsheets” which makes our job pretty easy.
You will also find it very easy to use these computer spreadsheets when you start
playing with data.
Spreadsheets have other benefits too:
We can put words, numbers or even pictures in the cells.
We can easily provide them headings or labels
We can very easily re-arrange them in increasing or decreasing order
We can even do calculations much faster than a calculator
We can make multiple pages
Take print outs on paper
Another strength of spreadsheets is that they can produce diagrams, like graphs and
pie-charts, based on the data the user enters. Sometimes the numbers make more
sense when the computer turns them into a picture.
Following are some of the popular spreadsheet formats:

Microsoft Excel Apple Numbers OpenOffice.org Calc Google Spreadsheet

64
Let's Learn Artificial Intelligence - Base Module

Other databases include MS Access, MYSQL, etc. Databases are controlled by Database
Management Systems (DBMS). The data, the DBMS along with applications that are
associated with them are referred to as a Database System. We will learn about these
in later modules.

EXPLORE

This is the right time to practice a little with Spreadsheets. Later,


when you have to train machines with lots of data, you will use
the advanced features of spreadsheets.
In this module, you can start with the basics.
Open Microsoft Excel on your computer
and then use the link given below to
learn the basics of Excel.
https://support.office.com/en-us/article/
excel-for-windows-training-9bc05390-
e94c-46af-a5b3-d7c22f6990bb

KEY ELEMENTS OF A SPREADSHEET


Creating a Database
The home screen is called a worksheet. The rows are numbered, and the columns are
identified by letters. Wherever a row and a column intersect, it is called a cell. The cell
has an address that includes the letter and the number.

ACTIVITY

Remember the information you collected about your 10 friends in the earlier
segment of this unit, enter that data in the spreadsheet.

65
First, keep the information collected by you in front of you.
Then open Excel in your computer

Now enter the details in a spreadsheet with the 6 items mentioned above as
headings in the first cell of the first 6 Columns.

66
Let's Learn Artificial Intelligence - Base Module

Data sorting is the process of arranging the data into a meaningful order so that it can
be analyzed or processed easily. Data sorting can be done in the following ways:

When we say that the data (numbers or characters) is sorted in ascending order,
it means that the arrangement is from the smallest to the largest number e.g.
5, 18, 26, 48 and 72 or A, B, F, L, O, Y, and Z.
Similarly, when the data (numbers or characters) is sorted into descending
order, the arrangement is from the largest to the smallest number e.g. 98, 77,
53, 29 and 2 or Z, Y, O, L, F, B, and A.
Let’s say you had the spreadsheet above and wanted to sort by age. This process
is fairly simple. One can start by either highlighting the whole column at once
or simply clicking on the first cell in the column. Then you will:
Right-click to open the menu
Go down to the Sort option – when hovering over Sort, sub-menu will appear
Click on Largest to Smallest
Select Expand the selection
Click OK

Data filtering can also be done using spreadsheets. The filter feature applies a drop-
down menu to each column heading, allowing you to select specific choices to narrow
a table. Using the above example, let’s say you wanted to filter your table by gender.
Let us find out how this can be done.
Follow the given steps to filter the table by gender:
Go to the Data tab on the Excel ribbon
Select the Filter tool
Click on the arrow next to Gender to bring down the dropdown menu
Select Female and ensure all other boxes are unticked

ACTIVITY

Use the same data of your 10 friends that you have entered in the spreadsheet
and perform the following task:
Sort the data by Name from A to Z
Filter the data to select the only students whose favorite subject is Hindi

67
Now you have some idea about what data is and it’s processing. You will be using what
you learned here in the next two chapters.

3.5 DATA SCIENCE AND BIG DATA


What is Data Science?
Data Science is a set of methods and tools used to extract knowledge and insights
from Datasets that may be highly structured or very unstructured. Data science uses
techniques such as statistics and data analysis.
Statistics- Statistics is a mathematical aid that involves gathering, reviewing, analyzing
the data to draw important conclusions as per the application.
Data Analysis- Data analysis is the method of achieving the required outcome using
techniques such as collecting, cleaning, modeling and transforming data.

What is Big Data?


Many Machine Learning and AI applications require a huge amount of data to get
accurate results. The data that is present may be loaded with complex features.
Big Data refers to a collection of large and complex datasets that may be complex due
to its volume or its variety (example: images, audio, text, numbers, etc.)
Often Big Data Datasets are handled with special software as traditional software does
not have the ability to deal with it.

3.6 COMPUTATIONAL DATA


As we know, a computer can store data of various types including images, sounds,
symbols, text or numbers.
So, how does a computer understand sound or recognize images, since it has no eyes
or ears?
The computer converts all data into binary form and then analyzes it for getting
insights and information.
So, what is binary and how does an image or sound transform into binary?
In order to understand how this works, let us try and understand how computers see
the world.

68
Let's Learn Artificial Intelligence - Base Module

There are a number of very common needs for a computer that includes the need to
store and view data.
Computers use electrical signals that are ON or OFF, so they have to see everything
as a series of binary numbers. This data is represented as a sequence of 1s and 0s (ON
and OFF) which we call as bits in the digital terminology. All the data that we want a
computer to process needs to be converted into this binary format.

WHAT IS BINARY?
The binary system is a number system that only uses two digits: 0 and 1. All the
information that is processed by a computer is in the form of a sequence of 0s and 1s.
Therefore, all the data that we want a computer to process needs to be converted into
binary. Text, images and audio, all types of data are recorded as binary on the computer.
Computers can read only 0s and 1s, but it can use them to make text, images as well as
sounds as illustrated in the image below.

69
The binary system is known as a ‘base 2’ system. This is because:
there are only two digits to select from (1 and 0)
when using the binary system, data is converted using the power of two.

ACTIVITY

Sending Secret Messages

Can you use these cards to communicate a secret message to your friend? If
the numbers 1 – 26 represented the letters of the alphabet as given below.

1 2 3 4 5 6 7 8 9 10 11 12 13

a b c d e f g h i j k l m

14 15 16 17 18 19 20 21 22 23 24 25 26

n o p q r s t u v w x y z

00011 01100 01111 10011 00101


11001 01111 10101 10010
00101 11001 00101 10011
Guess the above message?

Now if each of the zeros (0s) was represented by  and ones by 


The message above can be coded as:
    
   
   
You and your friend can use this technique to form a secret code which no one
else can understand. If you want, you can share this code with more friends by
exchanging the letters.

70
Let's Learn Artificial Intelligence - Base Module

ACTIVITY

COUNT THE DOTS—BINARY NUMBERS:


Data in computers is stored and transmitted as a series of zeros and ones.
How can we represent numbers using just these two symbols?
For this activity, you will need a set of five cards, as shown below, with dots on
one side and nothing on the other.
The cards are positioned in the following order:

Notice that each card has double the diamonds of the card to its right.
We can use these cards to make numbers by turning some of them face down
and adding up the diamonds that are showing in the cards facing up, as seen
below. As you can see, the first card on the right with one diamond and the
first card on the left when added represent 17.

= 17

Similarly, you can make 10 (By counting 8-diamonds and 2-diamonds in the
cards facing up and adding them), as shown below.

= 10

Now, can you make a 6, 18 and 24 on your own?

71
ACTIVITY

Going back to the first example, where we represented 17 (By counting 16-dia-
monds and 1-diamond in the cards facing up) by using cards. Now under each
card showing the side with the diamonds, write 1. Under each card flipped
over, write 0. Now when you read the entire sequence i.e. 10001, this is how 17
can be represented in Binary.

1 0 0 0 1 = 17

When a binary number card is not showing, it is represented by a 0 (zero).


When it is showing, the number of diamonds on it are represented by 1(one).
This is the binary number system. Therefore, in this case, we can represent
numbers from 0 to 31 with a five-digit unique binary code.
So, can you calculate the value of the following binary codes using these 5
cards:
01010 =
10010 =
11111 =
Can you make the binary code for the following?
13
20
We have seen that these 5 cards can represent numbers from 0 to 31, how
many numbers do you think can be represented if there were 6, 7 or 8 digits?

MORE ABOUT BINARY


In binary numbers, the Zero or One being used for representation is called a bit (binary
digit).

72
Let's Learn Artificial Intelligence - Base Module

Bit is the smallest unit for measuring a computer’s memory. These bits are commonly
grouped together in groups of eight that represent numbers ranging from 0 to 255
(as we saw numbers 0 to 31 being represented by 5 digits). A byte is a data storage unit
equivalent to 8 bits. 1024 bytes are equivalent to 1KB or 1 Kilobyte of data. Going further,
the following units can also be used for representing the data stored in a computer in
binary:
1024 Kilobyte = 1 Megabyte (MB)
1024 Megabyte = 1 Gigabyte (GB)
1024 Gigabyte = 1 Terabyte (TB)
1024 Terabyte = 1 Petabyte (PB)
A bit is usually represented in a computer’s main memory by a transistor1 that is
switched ON or OFF or a capacitor2 that is charged or discharged.

When data is transmitted over a telephone line or radio link, high and low-pitched
tones are used for the Zeros and Ones. On magnetic disks (floppy disks and hard disks)
and tapes, bits are represented by the direction of the magnetic field on a coated
surface (either North-South or South-North).

N S N S S N N S S N S N N S

The data within CDs and DVDs are stored optically in the form of Zeros and Ones. The
part of the surface corresponding to a bit either does or does not reflect light.

The speed of a computer can be defined as the number of bits that the machine can
process at a single instant. Suppose we take an example that features two computers
A and B wherein one is a 32-bit machine whereas the other one is a 16-bit machine
respectively. Also, let us assume that we have data that is 32-bit number.
1
Transistor is a miniature electronic device that regulates the flow of current and acts as a switch.
2
Capacitor is an electronic device which stores the electric current when current is allowed through it.

73
During the processing cycle, A will process the data in a single operation but B will
break this data into smaller pieces thereby taking more time. Hence, we would say
that machine A is faster than machine B in this operation.
A computer uses bits and bytes for storing data such as number, text and related in-
formation. Let us see how one can represent the information in various formats on a
computer.

REPRESENTING TEXT THROUGH BINARY


When a user presses any key, the information is converted into a binary number to
help the computer interpret the data. Once the computer has interpreted the data,
the typed character will automatically appear on the screen.

To convert a given text into formats that are readable and understandable for the
computer, commonly, we use ASCII codes. ASCII is an acronym for the American
Standard Code for Information Interchange. ASCII codes are used to represent the 128
English characters (includes English alphabets, numbers and special characters) into
a language that can be easily understood by a computer. In ASCII codes each number
represents a character that can be used to convert text into binary. The ASCII code
takes each character on the keyboard and assigns a binary number for it.

74
Let's Learn Artificial Intelligence - Base Module

Let us study some examples to understand this concept:


The letter ‘a’ has the binary number 0110 0001
The letter ‘b’ has the binary number 0110 0010
The letter ‘c’ has the binary number 0110 0011
The representation of text characters starts at binary number 0 in the ASCII code. This
also covers special characters such as punctuation, the return key, control characters,
capital letters, lower-case letters, and the number keys.
ASCII code only stores up to 128 characters, which is good enough to cover most words
in English but not enough for other languages. If you want to use accents in European
languages, Indian languages or larger alphabets such as Cyrillic (the Russian alphabet)
and Chinese Mandarin, you would need more characters. For this purpose, another
code, called Unicode, was created. This enabled computers to be used by people using
different languages.

REPRESENTING IMAGES THROUGH BINARY


Just as text, images also need to be converted into binary for the computer to pro-
cess them before they can be displayed on the screen. Digital images are made up of
pixels (short for picture elements) and each pixel is further made up of binary num-
bers. A pixel is a single point or a tiny square in a graphic image stored in an ordered
rectangular grid. It is the smallest element in a digital image.
If we say that 1 is black (or ON) and 0 is white (or OFF), then a simple black and white
picture can be created using binary.
To create a picture, a grid is set out and the squares are colored in black and white
(1 is for black and 0 is for white). Before the grid can be created, the size of the grid
needs to be known. This data is called metadata. The computer needs metadata to
know the size of an image. If the metadata for the image to be created is 10x10, this
means the picture will be 10 pixels across and 10 pixels down.
This example shows an image created in this way:

75
Adding color
The above example was for a black and white image now let us look at how colored
images are represented through binary. Instead of using single digits 0 and 1, using
them in two-digit numbers allows four possible numbers that can be used to represent
four colors in an image. As shown below, in the binary number system this can be
represented using two bits per pixel:
00 – white
01 – blue
10 – green
11 – red
We all know that this will not be sufficient to represent a wide range of colors that are
used in images. Hence, if we add another binary digit, the number of colors available
will be doubled as shown below.
1 bit per pixel (0 or 1): 2 possible colors
2 bits per pixel (00 to 11): 4 possible colors
3 bits per pixel (000 to 111): 8 possible colors
4 bits per pixel (0000 – 1111): 16 possible colors
…and so on
16 bits per pixel (0000 0000 0000 0000 – 1111 1111 1111 1111): over 65 000 possible
colors
The number of bits that are used to store each pixel in an image is known as color
depth. Images with more colors need more pixels to store each available color in that
image. This means that images that use lots of colors need more space and are stored
as larger files.
Image quality
Image quality is affected by the resolution of the image. Image resolution describes
the image’s level of detail – higher resolution means more image detail. In digital
imaging, the resolution is often measured as a pixel count. The resolution of an image
defines the closeness of the pixels with one another. This also decides the number of
pixels required to fill the space.
The images that are in low-resolution will feature larger pixels and require fewer pixels
to fill in space. Such type of images seems to be blocky or pixelated. On the other
hand, the images that have high resolution include far more pixels and look better
when zoomed in or stretched. The disadvantage of having more pixels is that the file
size will be bigger.

REPRESENTING SOUND THROUGH BINARY


Sound too needs to be converted into binary for computers to be able to process it.
Sound is captured, usually by a microphone and then converted into a digital signal.

76
Let's Learn Artificial Intelligence - Base Module

Sound is usually in a waveform which is an analog signal. To store sound in a computer


this analog signal needs to be converted into a digital format.
Analog: something physical with continuous change.
Digital: made of numbers.
To convert an analog audio signal into the digital format an analog to digital converter
is used. The converter will sample a sound wave at regular time intervals. For example,
a sound wave like this can be sampled at a periodic sample point.

The samples can then be converted to binary and they will be recorded to the nearest
whole number.

Time 1 2 3 4 5 6 7 8 9 10
sample
Binary 1000 0010 0111 0110 1001 0100 0010 1000 0110 0110

Denary 8 2 7 6 9 4 2 8 6 6
Value

77
If we plot the time samples onto the same graph, we can see that the sound wave
now looks different. This change in the graph is because sampling does not take into
account the change of the sound wave in between each time sample.

This means that the sound loses it’s quality as data has been lost between the time
samples. So, to increase the quality of sound and to store sound which is closer to the
original, we need to have more samples that are closer together. In this way, more de-
tails about the sound can be collected, so now when it is converted to digital and back
to analog again, the sound quality is not lost much.
The frequency at which samples are taken is called the sample rate and is measured
in Hertz (Hz). 1 Hz is one sample per second. Most CD-quality audio is sampled at 44
100 or 48 000 kHz.

78
Let's Learn Artificial Intelligence - Base Module

What have we learned


AI is a system that learns or understands patterns within that data and can identify them and
then reproduce them on new information. Data is a collection of facts. It can be in the form of
numbers, words, symbols or even pictures. Data consists of raw facts, values, and figures. Once
it is structured, processed and presented as a response to a question it becomes information.
Data processing refers to organizing and performing various operations on collected data
to produce meaningful information. Data analysis is about finding useful patterns in data. It
involves the following processes:
Inspecting the data
Segregating and filtering useful data
Analyzing and making a model of the data to discover meaningful information
Making conclusions as per the goal
Machines analyze historical and available data to make predictions and arrive at conclusions
for taking further action.
Dataset is a collection of related sets of information that is composed of separate elements but
can be manipulated as a unit by a computer. Datasets can be available publicly or in private.
At the highest level, two kinds of data exist, Quantitative (Numerical) and Qualitative (Non-
numerical). There are two types of quantitative data, Continuous and Discrete. Analog data
is a continuous form of data that is transmitted in electronic pulses. Digital data is that data
present in discrete form and transmitted in binary format (zeros and ones). There are three
kinds of qualitative data mainly, Binary or Binomial data, Unordered or Nominal data and
Ordered or Ordinal data.
AI involves handling large amounts of data, computer programs such as spreadsheets are
used to store, arrange and process that data. All the data that we want a computer to process
needs to be converted into this binary format.
Data Science is a set of methods and tools used to extract knowledge and insights from
datasets that may be highly structured or very unstructured. Data science uses techniques
such as statistics and data analysis. Now that we have learned about basics of Data and the
important role it plays in AI, let us look at how data is used by machines and how it can be
presented interestingly, through various data visualization methods.

ANSWERS TO ACTIVITY 'To calculate the binary code using 5 cards'.


Can you calculate the value of the following binary codes using these 5 cards?
01010 = 0+8+0+2+0 = 10
10010 = 16+0+0+2+0=18
11111 = 16+8+4+2+1=31
Can you make the binary code for the following?
13 01101
20 10100

79
Let's Learn Artificial Intelligence - Base Module

UNIT 4
DATA VISUALIZATION

Key Learning Outcomes


At the end of the module, you will be able to:
a) Explain the role of Algebra, Probability, and Statistics in AI
b) Explain the need for data visualization in AI
c) Identify the type of graph or chart to be used based on the application
d) Prepare a simple graph from data using a spreadsheet

Topic Covered
Role of Algebra and Probability in AI | Role of statistics in AI |
Data Visualization
4.1 ROLE OF ALGEBRA AND PROBABILITY IN AI
Machines learn differently from us. They use a lot of mathematics and learn by trying
and trying again. To understand how machines learn, let us try to learn like a machine
with the help of this game. In this game, we have to correctly predict what pictures
does a girl called Pari like.
To play this game, we will follow these steps:

You will see You will guess You will You can keep
examples of the features of predict Pari’s trying to predict
pictures that the pictures response to Pari’s response
Pari likes and that Pari likes. some more by trying
dislikes. pictures using out different
the features features that you
you identified. can identify, till
you get it right.

Here are some pictures that Pari likes and dislikes.

_
^ _
` ^
`

82
Let's Learn Artificial Intelligence - Base Module

Write at least 3 features that you noticed about the pictures that Pari likes. You could
look at features such as color, shape, background, border, texture, sides, angles, length,
height, etc.

Feature: A Feature: B Feature: C

To help you notice the features better, we have re-arranged the pictures:

Now see if Pari likes the next 3 pictures based on the features A, B, and C that you have
written down.
Give the picture ‘10 marks’ if that feature is present
Give the picture ’0 marks’ if that feature is not present
Give the picture ’5 marks’ if you are not sure

83
Feature: A Feature: B Feature: C

10 - (feature is present) 10 - (feature is present) 10 - (feature is present)


0 - (feature is not present) 0 - (feature is not present) 0 - (feature is not present)
5 - (not sure) 5 - (not sure) 5 - (not sure)

Feature: A Feature: B Feature: C

10 - (feature is present) 10 - (feature is present) 10 - (feature is present)


0 - (feature is not present) 0 - (feature is not present) 0 - (feature is not present)
5 - (not sure) 5 - (not sure) 5 - (not sure)

Feature: A Feature: B Feature: C

10 - (feature is present) 10 - (feature is present) 10 - (feature is present)


0 - (feature is not present) 0 - (feature is not present) 0 - (feature is not present)
5 - (not sure) 5 - (not sure) 5 - (not sure)

Add up the total marks given to each picture.

A+B+C= Total

A+B+C= Total

A+B+C= Total

From the marks given, try to predict if Pari likes this picture or not.
Check Pari’s answers from the end of this Unit.
Were you correct with your guesses?

84
Let's Learn Artificial Intelligence - Base Module

How confident are you that you have understood what Pari likes?
100 – Very confident
50 – Somewhat confident
0 – Not confident at all
Do you want to change anything about the features you have noticed?
You can keep the same features or write a new set of features for the 3 pictures.

Feature: A Feature: B Feature: C

Now give 10, 8, 5, 2 or 0 marks to each of the next 3 pictures for each of the features
A, B, and C.

Feature: A Feature: B Feature: C


10 - (feature is present) 10 - (feature is present) 10 - (feature is present)
8 - (matches a lot) 8 - (matches a lot) 8 - (matches a lot)
5 - (not sure) 5 - (not sure) 5 - (not sure)
2 - (matches a little) 2 - (matches a little) 2 - (matches a little)
0- (feature is not present) 0- (feature is not present) 0- (feature is not present)

Feature: A Feature: B Feature: C


10 - (feature is present) 10 - (feature is present) 10 - (feature is present)
8 - (matches a lot) 8 - (matches a lot) 8 - (matches a lot)
5 - (not sure) 5 - (not sure) 5 - (not sure)
2 - (matches a little) 2 - (matches a little) 2 - (matches a little)
0- (feature is not present) 0- (feature is not present) 0- (feature is not present)

Feature: A Feature: B Feature: C


10 - (feature is present) 10 - (feature is present) 10 - (feature is present)
8 - (matches a lot) 8 - (matches a lot) 8 - (matches a lot)
5 - (not sure) 5 - (not sure) 5 - (not sure)
2 - (matches a little) 2 - (matches a little) 2 - (matches a little)
0- (feature is not present) 0- (feature is not present) 0- (feature is not present)

85
Add up the total marks given to each
picture.
From the marks given, try to predict if A+B+C= Total
Pari likes this picture or not.
Check Pari’s answers from the end
of this Unit. A+B+C= Total
Were you correct with your guesses?
How confident are you that you have
understood what Pari likes? A+B+C= Total
100 – Very confident
50 – Somewhat confident
0 – Not confident at all

Do you want to change anything about the features you have noticed?
You can keep the same features or write a new set of features for the 3 pictures.

Feature: A Feature: B Feature: C

Now, give marks between 10 and 0 to each of the next 3 pictures. Give marks for each
of the features A, B and C. Assign marks depending on how sure you are that the
feature is present.
(10 marks, if you are fully sure the feature is present. 0 marks, if you are fully sure the
feature is not present)

86
Let's Learn Artificial Intelligence - Base Module

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

87
Add up the total marks given to each
picture. A+B+C= Total
From the marks given, try to predict if
Pari likes this picture or not.
Check Pari’s answers from the end A+B+C= Total
of this Unit.
Were you correct with your guesses?
How confident are you that you have A+B+C= Total
understood what Pari likes?
100 – Very confident
50 – Somewhat confident
0 – Not confident at all

Do you want to change anything about the features you have noticed?
You can keep the same features or write a new set of features for the 3 pictures.

Feature: A Feature: B Feature: C

Now again, give any marks between 10 and 0 to each of the next 3 pictures. Do this
for each of the features A, B and C. Assign marks depending on how sure you are that
the feature is present.
(10 marks, if you are fully sure the feature is present. 0 marks, if you are fully sure the
feature is not present)

88
Let's Learn Artificial Intelligence - Base Module

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

A B C

10 10 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0

89
Add up the total marks given to each
picture. A+B+C= Total
From the marks given, try to predict if
Pari Likes this picture or not.
Check Pari’s answers from the end A+B+C= Total
of this Unit.
So, with each new set, have you
become better at guessing?
A+B+C= Total

In this game, you were learning like a machine. You even used some parts of the
mathematical concepts that machines use to learn such as Algebra and Probability.

Algebra is a branch of mathematics, that uses


ALGEBRA letters that stand for various numbers, that is why
they are called ‘variables’.
For example:
The Letters A, B and C could have any number
from the range – 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, or 0.
T was the letter which stood for ‘Total’ and
could have been any number from 30 to 0.
We are able to create rules and formula using letters
where the numbers can vary. This formula is
called an ‘equation’
For example - A+B+C=T
This can be any of the following and more:
10 + 5 + 0 = 15
3 + 9 + 10 = 22

Letters may stand for unknown quantitites, by


learning methods of determining unknowns, we
develop powerful tools for solving puzzles and
problems.
Machines use complex algebra to make their
predictions.

90
Let's Learn Artificial Intelligence - Base Module

When we use the words ‘likely’, ‘doubt’, ‘most


PROBABILTY probably’, ‘chances are’, ‘not sure’, etc., it means
there is an element of uncertainty.
You may have seen that when you are not
completely sure, but you feel there is a higher
chance that something will happen. In most
such cases that thing happens.
We can measure whether the chances are high
or low.
In other words, we can measure whether
something is more probable or less.
This is the mathematical concept of probability.

Machines use probability to decide how


confident they are of their predictions and to
what extent they can take chances.

These subjects are covered in greater detail in the maths textbooks of standard
6th to 12th.

Why do you think computers use Algebra and Probability so much? It is because
computers need to figure out a lot of unknown stuff on their own as that is the
objective of AI. If we were always telling them what is what, then it wouldn’t really be
learning. It would just be remembering.
Algebra and Probability are wonderful at helping us and computers in figuring out
the unknown.

MORE ABOUT ALGEBRA


So let us start with Algebra.
Here is a very simple example.
Suppose I gave you 1 marble in your hand and then a closed Packet with many marbles and
asked you to tell me how many marbles are there in the Packet without looking inside it.
How would you do that?

91
You cannot look into the Packet, so you cannot count them.
I am not going to tell you the number of marbles in the
Packet.
But I can answer all your other questions about the marbles
in the Packet.

What would you like to ask me?

Well, the color of the marbles or who gave me the marbles will not help you find out
the number of marbles in the box.
You need information that is related to the number of marbles. For example, you need
information about something that changes with the number of marbles in the Packet,
such as the total weight of the Packet containing the marbles.
The more the number of marbles, the more will be the weight of the Packet.
What if I told you the weight of 1 marble and then the total weight of all the marbles
in the Packet. Would you be able to tell me the total number of marbles in the Packet
then?
The weight of 1 marble is 2 grams, and the weight of all the marbles is 24 grams.
Let’s see how algebra makes this very easy to predict.
We have to find out the total number of marbles, which is an unknown number.

92
Let's Learn Artificial Intelligence - Base Module

We know now that the weight of 1 marble is 2 grams.


o So the weight of 2 marbles will be 2x2 = 4 grams
o Weight of 3 marbles will be 3x2=6 grams
o Weight of 4 marbles will be 4x2=8 grams
o Then the weight of an unknown number of marbles will be ‘Unknown number’ X 2.
Let us call this ‘Unknown Number’ N.
Then the total weight of an unknown number of marbles will be equal to N X 2.
We also know that the total weight of all the marbles in the Packet is 24 grams,
o then N x 2 = 24 grams.
o or N x 2 = 12 x 2
Which means N = 12
There are 12 marbles in the Packet.
12 = 24 ÷ 2; So we could also write N = 24 ÷ 2

This is how we, as well as computers, use algebra to find out the unknown.

Now, even if we add or remove some marbles from the Packet, and then tell you the
total weight, you can always tell the number of marbles.
All you will do is ‘Number of marbles in the Packet’ = ‘Total weight of the packet’ ÷ 2
We have already given the symbol N to Number of marbles in the Packet.
Let us call the total weight of the Packet W.
Then we can make a relationship N = W ÷ 2.
o So if W=10, N=W ÷ 2 or 10÷ 2 = 5
o So if W=40, N=W ÷ 2 or 40÷ 2 = 20
Here N and W are variables because they can have varying values.
The relationship N = W ÷ 2 is called an equation.
So, if an intelligent computer can find out the relationships related to unknown
information, it makes equations of it. Then it keeps on trying out different values for
the variables till it guesses the correct one, where all the equations comes true.

To learn more, read the chapter on Algebra in your Mathematics books and do
all the exercises given there. If you wish to teach a machine, you must first know
how they learn.

93
MORE ABOUT PROBABILITY
Probability is used when we are not certain of the result.
In the above example, we could be certain of the number of marbles in the Packet
because we knew the weight of 1 marble as well as of the total marbles correctly.
What if we did not have a weighing machine? Then you would hold one marble in
one hand and the Packet of marbles in another and guess. Then you would say “Most
probably this packet contains …… marbles”.
Artificially Intelligent machines use Probability when they do not have all the
information.
Here is a game that will help you understand how Probability helps computers figure
things out.
Cut a page into 4 equal parts and write down ‘RED’ on one, ‘BLUE’ on another, ‘GREEN’
on another and ‘PINK’ on the last one.

RED BLUE

GREEN PINK

Now fold all the four pieces of paper hiding what you wrote on them. Fold them all in
the same manner, so that no-one can make out which piece carries which color. Then
shuffle the pieces and pick 1 out of the 4.
Now, without opening the piece, can you tell me how likely is it that it carries the color
GREEN.
Are you certain it is going to be GREEN?
Are you certain it is not going to be GREEN?
Do you think it most likely will be GREEN?
Do you think it most likely will not be GREEN?

94
Let's Learn Artificial Intelligence - Base Module

Now open it, see and write down the color in the chart given below:

Pick 1 out of 4 Slips. Write down the Color.


Do this 20 times.
1st try 11th try

2nd try 12th try

3rd try 13th try

4th try 14th try

5th try 15th try

6th try 16th try

7th try 17th try

8th try 18th try

9th try 19th try

10th try 20th try

In 20 tries how many times did you get GREEN?


Then the chance of getting GREEN in the 21st try can be calculated by dividing the
number of times you got GREEN by 20.
For example: if you got GREEN 5 times out of 20.
5 1
Then the chances that you will get GREEN again is 20 or 4

95
Now try the same exercise but with only 3 colors. Destroy the piece of paper containing
PINK.
Now shuffle and pick a piece again and write down the color again in the following table:

Pick 1 out of 3 Slips. Write down the Color.


Do this 20 times.
1st try 11th try

2nd try 12th try

3rd try 13th try

4th try 14th try

5th try 15th try

6th try 16th try

7th try 17th try

8th try 18th try

9th try 19th try

10th try 20th try

How many times did you get GREEN?


Calculate the Probability of getting GREEN from 3 slips in the same manner as we did before.
Did you notice that the chances were higher? But it is still less than 1/2 . which is a 50-
50 chance.
You can understand how the chances of getting GREEN are more or less from the
following diagram:

96
Let's Learn Artificial Intelligence - Base Module

Thus, in a nutshell:
Probability is a numerical measure of how likely an event is to happen.
Probability is measured in fractions between 0 and 1. (0 is impossible; 1 is certain.)
Sometimes, Probability is represented as a percentage -- from 0 percent to 100 percent.

You will learn more about Probability in Mathematics in higher classes. Hope
you look forward to it.

4.2 ROLE OF STATISTICS IN AI


Another tool that humans and computers use to find out interesting information hid-
den in lots of Data is Statistics. Statistics is the subject that concerns the collection, or-
ganization, displaying, analysis, interpretation, and presentation of data. As we know,
AI is heavily dependent on data operations; thus, there is a huge importance of Statis-
tics for AI and Machine Learning.
We have already learned, Data is a collection of pieces of information that may not
mean anything. However, when lots of Data is collected and kept in an ordered man-
ner, then we can find patterns in the data. These patterns can tell us interesting facts.
For example, we have collected the Data for the batting scores of Apu and Pari of all
the matches they played in a week.
Apu: 20, 9, 40, 4, 17 and 0
Pari: 7, 30 and 23
Can you tell me who is the better player, Apu or Pari?
By just looking at the Data, we may not be able to say. However, Statistics can help.
Apu has scored ‘20+9+40+4+17+0=90’ runs in 6 games
Pari has scored ‘7+30+23=60’ runs in 3 games
Now can you tell who is better?
Average score of Apu is ‘90 ÷ 6 = 15’
Average score of Pari is ;60 ÷ 3 = 20’
So, Pari seems to be the better player this week. Next week Apu will play harder, now
that he knows that Pari is scoring better than him.

97
Re-arranging data and taking out the average is part of statistics.
You will learn more about Statistics in higher classes.

Doing Statistical calculations can become very easy if we use spreadsheets, which we
had discussed during the earlier Unit 3 on Data.

PROJECT

Remember the Data you had collected for 10 friends in the earlier unit and
entered it in a spreadsheet. I hope you had saved it. If not enter it again and
this time does not forget to save it.
Name
Age
Gender (Male/Female)
Height (You can measure this using a scale/ruler)
Hobby
Favorite Subject
Now using the tutorial provided earlier, calculate the following, using formulas:
The average age of your 10 friends
The average height of your 10 friends
Sum of the weight of friends put together

4.3 DATA VISUALIZATION


Data visualization is a method to represent information and Data graphically by the
use of images like charts, graphs, and maps, to describe a story in a way that we can
understand.
It is very interesting to see patterns in the Data.
For example, given below are the marks obtained by 10 students in a class test in
Maths and their attendance for the last 2 months.

98
Let's Learn Artificial Intelligence - Base Module

Student Name Marks Days attended in 2 months

Devin 100 55

Koel 97 54

Apu 90 55

Sameer 90 55

Babu 85 53

Aarti 70 54

Farah 61 55

Guna 54 45

Hira 35 51

Anik 28 52

PROJECT

After entering all the data of the 10 students in a spreadsheet in Excel, create
a Bar Chart in relation to the 2 variables (Marks and Days) one-by-one.
A bar graph is a two- or three-dimensional representation of data from the
simplest to the most complex.
1 Open Excel. Locate and open the spreadsheet from which you want to
make a bar chart.
2. Select all the data that you want to include in the bar chart.
3. Be sure to include the column and row headers, which will become
the labels in the bar chart. If you want different labels, type them in the
appropriate header cells.
4. Click on the Insert tab and then on Insert Column or BarChart button in
the Charts group. You’ll see many options when you select this button,
such as 2-D columns and 3-D columns, as well as 2-D and 3-D bars. For
these purposes, we’re selecting 2-D columns.
5. The chart will appear. You’ll also see horizontal bars giving the names of
your headers at the bottom of your graph.

99
6. Next, give your chart a name. Click on the Chart Title section at the top
of the graph and the section becomes editable.
7. Decide where to place the bar chart. You can place it on a separate
sheet, or you can embed it in the spreadsheet. Then save it.
8. If you want to delete the chart and start all over again, place your
cursor on the edge of the chart (you’ll get a pop-up that says “chart
area”) and press your Delete key.
Now try a line graph.

A pie chart is a visual representation of data and is used to display the amounts
of several categories relative to the total value of all categories. Pie charts are
used, for example, to show the individual collections by students in a fund raising
activity, and the individual contributions relative to the overall collections. Use a
bar graph, pie chart or line graph to communicate data and information in an
interesting manner. You can plot your data by hand or use a spreadsheet.
Given below are some types of charts that are commonly used to visualize data.

100
Let's Learn Artificial Intelligence - Base Module

There are four basic presentation types and their examples that you can use to
present your data:
Comparison: To show what is more and what is less
Composition: To show the sub-categories
Distribution: To show clusters
Relationship: To show how the value of one thing changes with
the change in another
Unless you are a statistician or a data analyst, you are most likely to use the two,
most common types of data analysis: Comparison or Composition.

Selecting the Right Chart


To determine which chart is best suited for each of those presentation types, first,
we must answer a few questions:
How many variables do you want to show in a single chart? One, two, three,
many?
How many items (data points) will you display for each variable? Only a few or
many?
Will you display values over a period of time, or among items or groups?
Here are some types of charts:

Bar charts

These are good for comparisons.


Like the given chart is showing
values for the favorite fruit of
various students in a class.

101
Line charts

These are used to show trends. For


example, the improvement in the
batting scores of an individual over
time.

Scatter plot charts

These are good displaying relationships


and distributions. For example, the
relationship and distribution of height
and weight of a group of males and
females.

Pie charts

These should be used for simple compositions and not for comparisons or
distributions. For example, what are the benefits participants received from a
training program.

102
Let's Learn Artificial Intelligence - Base Module

SOME DATA VISUALIZATION TOOLS


EXPLORE

Visit the link given below to explore various other types of data
visualization methods. Try and discuss with fellow students’ various uses
of these along with the advantages and disadvantages of each. Try and
use at least a few of them in different projects and assignments.
https://datavizcatalogue.com/

103
What have we learned
Machines learn differently from us. They use a lot of mathematics and learn by trying and
trying again. Two such mathematical concepts are Algebra and Probability. Algebra and
Probability are wonderful at helping us and computers in figuring out the unknown.
Algebra involves the use of letters that stand for various numbers. These are called ‘variables’.
We can create a formula using letters where the numbers can vary. This formula is called an
‘equation’. Machines use complex algebra to make their predictions.
Probability is a numerical measure of how likely an event is to happen. It is measured in
fractions between 0 and 1. (0 is impossible; 1 is certain.) Sometimes, Probability is represented
as a percentage -- from 0 percent to 100 percent. Machines use Probability to decide how
confident they are of their predictions and to what extent they can take chances.
Another tool that humans and computers use to find out interesting information hidden in
lots of data is Statistics. When lots of data is collected and kept in an ordered manner, then we
can find patterns in the data. These patterns can tell us interesting facts.
Doing statistical calculations can become very easy if we use Spreadsheets.
Data visualization is a method to represent information and data graphically using images
like charts, graphs and maps, to describe a story in a way that we can understand. It is very
interesting to see the pattern in the data.
There are four basic presentation types that you can use to present your data:
Comparison, Composition, Distribution, Relationship
Some commonly used types of charts are:
Bar charts Line charts Scatter plot charts Pie charts
As we have discussed the use of data in AI in this unit, now the next unit will focus on how can
we use huge datasets in AI to solve real-life problems.

104
Let's Learn Artificial Intelligence - Base Module

ANSWERS TO ACTIVITY ‘Which pictures does Pari Like?’

PICTURE SET 2 PICTURE SET 3

PICTURE SET 4 PICTURE SET 5

105
Let's Learn Artificial Intelligence - Base Module

UNIT 5
PROBLEM-SOLVING AND
DECISION MAKING

Key Learning Outcomes


At the end of the module, you will be able to:
a) Explain the problem-solving process of AI
b) Breakdown a daily life activity into steps
c) Identify a problem and break it down into various components
d) Identify a problem and its solution, elaborating the process in discrete steps
e) Identify components of a flowchart
f) Represent the steps of daily life activity in a flowchart
g) Give examples of computer algorithms and algorithms in everyday contexts
h) Prepare a simple algorithm related to a daily life activity
i) Compare and evaluate two algorithms for the same process
j) Write and read simple algorithms in Pseudocode
k) Represent the steps and decisions (algorithms) needed to solve them
in Pseudocode

Topic Covered
Introduction of problem solving and algorithms |
Pseudocode – writing basic algorithms | Searching and sorting algorithms

107
5.1 INTRODUCTION TO PROBLEM SOLVING AND
ALGORITHMS
Through Artificial Intelligence, we ultimately want machines to be able to solve our
problems. Machines use logical reasoning to solve problems. Logical reasoning is the
process of applying rules to problem-solving.

To solve a problem machine, follow the following process:

Identification of
Understanding Choosing the Implementation
various solutions
the problem best solution of the solution.
to the problem

UNDERSTANDING THE PROBLEM


It is important to start by checking that the problem is completely understood. There
are a number of basic things to know to really understand the problem:
What are the inputs into the problem?
What will be the output of the problem?
In what order do the instructions need to be carried out?
What decisions need to be made to solve the problem?
Are any areas of the problem repeated?
For example, if the problem you want to solve is: Which sports team should you join?
The following could be the inputs and output.

INPUTS OUTPUT
The various sports teams that are looking for
players.

The entry criteria for joining the sports teams

The various sports you like. The sports team that you should join.
The various sports you play well.

The various sports teams that are looking for


players.

108
Let's Learn Artificial Intelligence - Base Module

The order in which the instructions have to be carried out will be as follows:
1. Find out the available sports teams and their entry criteria
2. Then find out the best team for you

Decisions to be made will be as follows:


Do you match the entry criteria of various sports teams
Do you like the sport
Do you play the sport well
The area of the problem that will be repeated is as follows:
The decisions will have to be repeated for all the sports one by one

IDENTIFICATION OF VARIOUS SOLUTIONS


There is usually more than one way to solve a problem. At this stage, each way to solve
the problem is broken down into logical steps. This is called an Algorithm that can
then be represented in the form of a flowchart.
Algorithms are step-by-step instructions to solve a problem, created along with rules
that decide which path to take when a decision is faced.
The rule could be:
if a condition is met, the machine will do something
if the condition is not met, the machine will do something else
When trying to solve a problem, it may be that we find more than one solution. A dif-
ferent set of logical steps and rules, or algorithm, can be built from each solution.
Logical reasoning determines if algorithms will work by predicting what happens
when the algorithm’s steps, and the rules they consist of, are followed.

EXPLORE

To understand Algorithms go through this very interesting module which


is part of another related course under AIM.

http://www.aim.gov.in/pdf/Understanding_and_Algorithms.pdf

109
Algorithms are a standard requirement for problem-solving and are used to solve
various problems. Simple algorithms can solve complex problems too based on logic,
sequencing, repetition and writing down the conditions or rules applicable.
The key to any problem-solving task is to guide your process of thinking. We can do
this by asking ‘What if we did it this way?’ Exploring different ways of solving a problem
can help to find the best way to solve it.
When designing an algorithm, consider if there is more than one way of solving the
problem.
When designing an algorithm, there are two main areas to look at:
The big picture - What is the final goal we want to achieve?
The individual stages – What hurdles need to be overcome on the way to the goal?
Going back to our example:
There could be many ways to solve this problem, 3 are suggested below in the form of
algorithms:

START START START

Find available Find available Find available


sport sport sport

Do you Do you Do you Find next


Find next Find next If no
meet If no meet If no meet available
available entry available
entry entry sport
sport sport
criteria criteria criteria

If yes If yes If yes

Do you If no Do you Do you If no


play the If no
like the like the
sport well? sport? sport?

If yes If yes
If yes
Recommend Recommend
sport sport Do you If no
play the
sport well?

If yes

Recommend
sport

110
Let's Learn Artificial Intelligence - Base Module

CHOOSING THE BEST SOLUTION BY COMPARING ALGORITHMS

One can choose the best option by comparing the algorithms. Logical reasoning can
compare how effective and efficient, different solutions are. Another way would be to
input some data and see if the output is as desired or not, for each of the solutions.
Then feedback that input to the computer, which will then select the algorithm that
has the most desired feedback. Going back to our example:
Out of the 3 options provided:

OPTIONS

Option 3
This will give a list of sports
Option 1 Option 2
teams that you are eligible
This will give a list of sports This will give a list of sports for and that you play well as
teams that you are eligible for teams that you are eligible well as like, however if there
and that you play well, but you for and that you like, but you is no such sport where you
may not like. may not be good at. are eligible, you like the sport
and you play it well, then
what will you do.

So, you may go for the best solution which is a combination of options 2 and 3.
First run Option 3, if there are sports that it can recommend, choose those. If there are
no recommendations, then run Option 2.
See the algorithm on next page.

111
However, in case you
are not sure you know START
which sport you like;
then this algorithm Find available
sport
would not be the right
one, you could go for
option 1. Do you
If no Find next
meet
Thus you see, at this entry available
sport
stage, the algorithms criteria

can be accepted,
If yes
rejected, modified and
even combined in order
Do you If no
to get the best results like the
as per our goals. sport?

If yes

Do you
If no
play the
sport well?

If yes

Is there If no
a sport to START
recommend?

Find available
sport
Recommend
sport
Do you
If no Find next
meet
available
entry
sport
criteria

If yes

Do you If no
like the
sport?

If yes
Recommend
sport

112
Let's Learn Artificial Intelligence - Base Module

IMPLEMENTATION OF THE SOLUTION

Here you feed in new data and get the solution for your problem. However, the
computer will also be able to tell how sure it with the solution based on the earlier
feedback provided by you.

LET’S PLAY WITH ALGORITHMS!


Now let us now do an activity. Each student must write a
recipe, step-by-step, for making the best burger or sandwich.

113
Now see how your recipe compares to that of others.

In a group, try and see the various details that you are missing out for someone else to
follow the recipe and make it exactly as you wanted it to be?
Write a few points of what you would like to include in your perfect Burger.

Do you realize how detailed a recipe you will need, to make it the way you like it?
This is exactly why problem-solving algorithms can often become very detailed and
complex. Now if you compare different recipes of the sandwiches or burgers, can you
find a filling that you really like from within the groupand can you incorporate the
filling steps into your recipe?

114
Let's Learn Artificial Intelligence - Base Module

How does your recipe look now?


Can you write it as an algorithm now?

115
Often one may have different algorithms that work for different parts of the problem.
Like in our burger case, one may have a recipe section for the filling and a separate
section for the bread and even a third one for the assembling, garnishing and plating
presentation.
In a similar manner, as you did in this activity, you can breakdown any activity into
steps and write it as an algorithm and then use more data to modify the algorithm to
get the best results.

5.2 PSEUDOCODE – WRITING BASIC ALGORITHMS


An algorithm can be defined as a well-defined sequence of steps that provides a
solution for a given problem, whereas a Pseudocode is one of the methods that can
be used to represent an algorithm.
Pseudocode is a simpler version of programming code in plain English which uses
short phrases to write code for a program before it is implemented in a specific
programming language.
It is one of the methods which can be used to represent an algorithm for a program.
It does not have specific language rules like any of the programming languages and
thus cannot be executed on a computer. There are several formats that are used
to write Pseudocodes, and most of them take down the structures from computer
languages such as C, Lisp, FORTRAN, etc.
Often, algorithms are presented using Pseudocode since they can be read and
understood by programmers who work with different programming languages.
We cannot execute Pseudocode on a computer, but it models the actual programming
code along with a similar level of detail.

COMMON PSEUDOCODE NOTATION


There is no strict set of standard notations for Pseudocode, but some of the most
widely recognized are:
INPUT – indicates a user will be inputting something.
OUTPUT – indicates that output will appear on the screen
REPEAT – UNTIL – a loop (iteration) that has a condition at the end
FOR – a counting loop (iteration)
WHILE – a loop (iteration that has a condition at the beginning)
IF – THEN – ELSE – a decision (selection) in which a choice is made
Any instructions that occur inside a selection or iteration are usually indented

116
Let's Learn Artificial Intelligence - Base Module

Pseudocode is also written using some specific words and characters, which are
shown below:

Read / get / input These are used to give input. If it can have variable values,
then it is given a name.
Write / display / print These are used to give the output.

“//“. The double forward slash is used to begin the comment.

“{and}” Matching braces are used to present blocks where a com-


pound statement (set of simple statements) can be illustrat-
ed as a block and terminated by a semicolon”; “. The body of
a procedure constructs a block as well.

Relational operators: <, ≤, =, These are used to produce the Boolean values (i.e., true and
=, ≥, > false).
Logical operators ‘and’ ‘or’

“if and else” These expressions are used to express a conditional state-
ment.

Along with the above:


All the identifiers start with a letter, and the data type of the variables are not
declared explicitly.
An assignment statement is used for assigning values to the variables.
Input and output are presented by reading and write instructions.

USING PSEUDOCODE
Let us see how pseudo code is written.
Example 1: Given below is a pseudo code that tells if the number entered is not a 2 or a 4.

We use the variable enterednumber.

Pseudo Code:

Begin
Read enterednumber
If (enterednumber = 2) Write “your number is 2” Else if (enterednumber = 4)
Write “your number is 4”
Else Write “your number is not a 2 or 4”
END

117
Example 2: Given below is a pseudo-code that performs the following:
Ask a user to enter a number.
If the number is between 0 and 10, write the word ‘YES’.
If the number is between 10 and 20, write the word ‘MAYBE’.
If the number is between 20 and 30, write the word ‘NO’.
If it is any other number, write that it is not a correct option.
Pseudo Code:
Begin
Write “Please enter a number”
Read num
If (num >0 and num <= 10) Write YES
else If (num >10 and num <= 20) Write MAYBE
else If (num >20 and num <= 30) Write NO
else Write “not a correct option”
End

ACTIVITY

Can you identify what these Pseudocodes are doing?


1. Begin
Write “please enter 2 numbers”
Read num1, num2
If(num1 < num2) Set max to num2
Else Set max to num1
Write “The max is”
Write max
End

118
Let's Learn Artificial Intelligence - Base Module

2. Begin
Write “please enter 2 numbers”
Read num1, num2
Compute sumofnum=num1+num2
Write “The sum is”
Write sumofnum
End

ACTIVITY

Can you write the Pseudocode for the following?


1. Add 3 numbers.

2. Tell whether a number is odd or even.

119
Note: Pseudocode is not an actual programming language.
Program: It is words for instructing and a set of grammatical rules, a computer or
computing device need to perform specific tasks. The machine can’t read a program
directly, because it only understands machine code. But you can write stuff in a
computer language, and then a compiler or interpreter can make it understandable
to the computer.
Have you played the noughts and crosses game?
Let us make an algorithm for this game in Pseudocode.
I am a highly intelligent board. Let’s play noughts and crosses.

I am X, and I go first.
Move 1: Go in a corner.
Move 2: IF the other player did not
go there
THEN go in the opposite corner to
move 1.
ELSE go in a free corner.
Move 3: IF there are 2 Xs and a space
in a line
THEN go in that space.
ELSE IF there are 2 Os and a space
in a line
THEN go in that space.
ELSE go in a free corner.
Move 4: IF there are 2 Xs and a space
in a line
THEN go in that space.
ELSE IF there are 2 Os and a space
in a line
THEN go in that space.
ELSE go in a free corner.
Move 5: Go in the free space.

120
Let's Learn Artificial Intelligence - Base Module

5.3 SEARCHING AND SORTING ALGORITHMS


Now that we know the role of algorithms in AI and a little bit about how to write them,
let us discuss a few common types of algorithms that you will come across often.
There are many types of algorithms used in Artificial Intelligence applications for
problem-solving. The most simple and common problem-solving algorithms used by
AI are:
1. Searching Algorithms: That can be used to help find the data we are looking for.
2. Sorting Algorithms: That can be used to will put items in a list into order.

WHY DO WE NEED SEARCHING ALGORITHMS?


We often need to find one particular item of data amongst many hundreds, thousands,
millions or more. For example, you might need to find your friend’s phone number
from a telephone directory that has thousands of numbers. By yourself, you will take
a very long time. It is like searching for a needle in a haystack.

So, Search algorithms prevent you from going through lots of data to find the
information you are searching for.
There are many different types of searching algorithms. Two of them are:
1. Serial or sequential search
2. Binary search

121
SEQUENTIAL SEARCH
A sequential search is when you look at each piece of data, one by one, and don’t stop
until you find what you are looking for.
For example:
We want to find the word “at” from a long list. Due to a lack of space, we shall take a
small list.
The list:
“he”
“you”
“me”
“this”
“that”
“it”
“is”
“which”
“at”
“from”
“us”
The computer would go to the first word “he” and ask is it the same as “at”.
If it is it will stop searching.
If it isn’t, it will go to the next word and repeat this process until it finds the
matching data.
In this case, it takes 9 guesses to find the word because it guesses as per the sequence.
So, if it was finding “me”, it would have taken just 3 guesses.
But imagine, if there were a million items on the list and our word was way down in
the sequence. Then the sequential method may not be the best option.

BINARY SEARCH
A binary search algorithm tells us how to efficiently find a specific value in an ordered
(sorted) list.
It is called ‘binary’ search because each time it searches a value in the list, it divides
the list into 2 parts. Then it checks if the desired value falls in part 1 or part 2. The one
in which the value falls is kept, and the other part is discarded.

122
Let's Learn Artificial Intelligence - Base Module

Now if we want to search the word “that” from this list, we will first sort it in alphabetical
order.
“at”
“from”
“he”
“is”
“it”
“me”
“that “
this”
“us”
“which”
“you”
First, the computer will go straight to the middle word, “me” and see if that matches
- because it doesn’t, the computer doesn’t need to check the 5 words on the top
because “that” will be alphabetically below “me”.
Now the computer finds the middle word of the bottom 5 of the list:
“this”
“that”
“us”
“which”
“you”
It finds the word “us”. It does not match, and the computer can eliminate the words
after “us” as well. That leaves only 2 words:
“this”
“that”
The computer can locate “that” as the second part of the list.
So, it is able to find the word in 3 guesses.
One of the main advantages of a binary search is that it is much quicker than a serial
search because the data that needs to be searched halves with each step. However,
the biggest problem with a binary search is that you can only use this if the data is
sorted into order.

123
WHY DO WE NEED SORTING ALGORITHMS?
A sorting algorithm will put items in a list into an order, such as alphabetical or
numerical order. For example, a list of student names could be sorted in alphabetical
order by surname, or a list of mobile numbers could be put into numerical order.
Sorting a list of items can take a long time, especially if it is a large list. A computer
program can be created to do this, making it much easier.
There are many types of sorting algorithms. Two of them are:
1. Bubble sort
2. Bucket sort

BUBBLE SORT

A bubble sort algorithm goes through a list of data a number of times, comparing two
items that are side by side to see which is out of order.
It will keep going through the list of data until all the data is sorted into order. Each
time the algorithm goes through the list, it is called a ‘pass’.
For example:
Suppose you have a list of marks obtained by students of a class. You want to sort
them from highest to lowest. A bubble sort can do this.
The list of marks is:
32, 97, 89, 63, 30 and 60

First pass
The highlighted numbers are the numbers that are being compared.
32, 97, 89, 63, 30, 60
This is the list before it is sorted.
32, 97, 89, 63, 30, 60
The first two numbers are compared. 97 is larger than 32, so they switch places.
97, 32, 89, 63, 30, 60
The next two numbers are compared. 89 is larger than 32, so they switch places.
97, 89, 32, 63, 30, 60
The next two numbers are compared. 63 is larger than 32, so they switch places.
97, 89, 63, 32, 30, 60

124
Let's Learn Artificial Intelligence - Base Module

The next two numbers are compared. 32 is larger than 30, so they remain as
they are.
97, 89, 63, 32, 30, 60
The next two numbers are compared. 60 is larger than 30, so they switch places.
97, 89, 63, 32, 60, 30
This is what the list looks like after the first pass.
The list is now more ordered than it was originally, but it isn’t yet fully in order of
youngest to oldest. The list needs to go through another pass to compare the
numbers again so that it can be sorted further.

Second pass
97, 89, 63, 32, 60, 30
The first two numbers are compared. 97 is larger than 89, so they remain as
they are.
97, 89, 63, 32, 60, 30
The next two numbers are compared. 89 is larger than 63, so they remain as
they are.
97, 89, 63, 32, 60, 30
The next two numbers are compared. 63 is larger than 32, so they remain as
they are.
97, 89, 63, 32, 60, 30
The next two numbers are compared. 60 is larger than 32, so they switch places.
97, 89, 63, 60, 32, 30
The next two numbers are compared. 32 is larger than 30, so no change occurs.
97, 89, 63, 60, 32, 30

125
This is how the list looks like after the second pass.
The set of data is now in ascending order from youngest to oldest. The algorithm,
though, does not know this yet as it made some changes in the second pass. The
algorithm will only recognize that the list is in order if it makes no changes in a pass.
The algorithm, therefore, needs to run for a third pass to compare the numbers again.
As no changes will be made, the algorithm will then recognize that the data is in order.
If the data being sorted is a large set of data, it may take several passes to get the data
sorted.
Here is another example: Let us take a stack of the cards with the numbers “7 3 6 1 9”,
and sort in ascending order using this algorithm. In each step, the algorithm compares
the elements written in bold. The top of the stack of cards is on the left-hand side.

First pass
( 7 6 3 1 9 ) ( 6 7 3 1 9 ) Here, the algorithm compares the first two elements
and swaps them.
(67319) (63719)
(63719) (63179)
( 6 3 1 7 9 ) ( 6 3 1 7 9 ) These elements are already in order, so the algorithm
does not swap them.

Second pass
(63179) (36179)
(36179) (31679)
(31679) (31679)
(31679) (31679)
Now, the stack of cards is almost sorted

126
Let's Learn Artificial Intelligence - Base Module

Third pass
(31679) (13679)
(13679) (13679)
(13679) (13679)
(13679) (1 3 6 7 9 )
Since there is no change in the runs now, finally, the array is sorted. But our
algorithm does not know this. The algorithm needs one whole pass without
any swap to know it is sorted.
and the algorithm can stop.

Fourth pass
(13679) (13679)
(13679) (13679)
(13679) (13679)
( 1 3 6 7 9 ) (1 3 6 7 9 )
Now the algorithm can stop.

BUCKET SORT

A bucket sort algorithm, separates a list of data into different collections of data, called
‘buckets’. Empty buckets are set up at the start of the sort and are filled with the
relevant data. Data is finally gathered back into a list after sorting each bucket.
For example:
Imagine that you have a list of people who you want to sort by age, from youngest to
oldest. A bucket sort can do this.
The list of ages is:
39, 12, 17, 36, 20, 47, 78 and 55
1. Set up a series of empty buckets.

1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80

127
2. Put the data into the correct buckets.

1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80

55
12 20 36 47
39 78
17

3. Buckets that have more than one item of data in them will be sorted (e.g. using
bubble sort).

1-10 11-20 21-30 31-40 41-50 51-60 61-70 71-80

12 17 36 39 47 55 78
20

4. The data will then be gathered from each bucket and put back into a list
The final list will be 12, 17, 20, 36, 39, 47, 55, 78.

COMPARISON OF SORTS

It is important to understand that different algorithms might be used in different


situations. For example, sometimes one algorithm will be much quicker or more
efficient than another and in some instances, an algorithm won’t work with a particular
set of data.

MORE SORTING ALGORITHMS


There are lots of different sorting algorithms. These use clever ideas to make sorting
lists much quicker, although the algorithms can get very complicated at times.
Other sorting algorithms include the:
merge sort
insertion sort
shell sort
quick sort

128
Let's Learn Artificial Intelligence - Base Module

CLASSIFICATION ALGORITHMS
We have discussed some basic Searching and Sorting Algorithms. AI uses many
other types of Algorithms as well; some of them can be very complex. Some of these
are called Classification, Regression or Clustering Algorithms. Basic algorithms like
Searching and Sorting could be parts of these AI algorithms.
Classification Algorithms can be somewhat complex, but still are some of the most
used AI Algorithms. The use of Classification Algorithm, for example, is when an AI
machine uses Supervised Learning and defines the rules with a training set and
then when we give it new objects, it classifies them according to the rules defined
previously. These rules could be different for different algorithms.
Let us see an example that will help us understand this better.
Here are is a set of pictures that represent different creatures.

129
What would be the first rule that we create to classify them?
Let us say the first rule is to classify them as having 4 legs or not.
The algorithm will start as follows:

Does it
have 4
legs?

Yes No

The second rule is to classify as having scales or not.


The second rule is to classify as having wings or not.
The algorithm will proceed as follows:

Does it
have 4
legs?

Yes No
Does it Does it
have have
scales? wings?

Yes No
Yes No

130
Let's Learn Artificial Intelligence - Base Module

Then we can keep identifying more rules to classify the creatures by,
such as mentioned shown below:

Does it
have 4
legs?

Yes No

Does it Does it
have have
scales? wings?

Yes No Yes No

Is it Does it Is it Does it
long? have tall? have fins?
horns?
Height is Height is
Length is Length is less Yes No more than less or No
more than than or equal Yes
2 cm 2 cm
2 cm equal to
than 2 cm

This way we can identify each creature as


Animal with Horns
Animal without Horns
Long Reptile
Small Reptile
Tall Bird
Small Bird
Big Fish
Small Fish, etc.

131
The example above shows a simple use of the classification algorithm. Other examples
are the AI that filters your email into SPAM and INBOX using a Classification AIgorithm
or AI.
Examples of some Classification Algorithms are Naïve Bayes, Logistic Regression,
Support Vector Machine (SVM), etc.
We will learn about these as well as Regression and Clustering Algorithms in the Step-
Up module.

ACTIVITY

Now why don’t you try a classification activity.


Here is a picture with various stationery items that you can find in a study table:

Try to classify them the way we classified the animals.


Make a Rule 1, with which you can divide these items in two Groups.
Now make a Rule 2, with which you can divide the first group, further into
2 groups.
Now make a Rule 3, with which you can divide the second group, further
into 2 groups.
Make more rules to further divide the groups.

Draw an algorithm showing these rules of classification.

132
Let's Learn Artificial Intelligence - Base Module

Rules:

Algorithm:

133
Now here is another set of items. Apply the classification algorithm you have
made to each of these items and see which group they fall into.

134
Let's Learn Artificial Intelligence - Base Module

What have we learned


Machines use logical reasoning to solve problems. The process followed is as follows:

Identification of
Understanding Choosing the Implementation
various solutions
the problem best solution of the solution.
to the problem

There are a number of basic things to know to really understand the problem:
What are the inputs into the problem?
What will be the output of the problem?
In what order do the instructions need to be carried out?
What decisions need to be made to solve the problem?
Are any areas of the problem repeated?
To identify the various solutions of the problem, it is broken down into logical steps. This is
called an Algorithm that can then be represented in the form of a flowchart. Simple algorithms
can solve complex problems too based on logic, sequencing, repetition and writing down the
conditions or rules applicable.
One can choose the best option by comparing the algorithms. Logical reasoning can be used
to compare how effective and efficient, different solutions are.
During the implementation of the solution, we can feed new data and get the solution to our
problem. However, the computer will also be able to tell how sure it is that with the solution
based on the earlier feedback provided.
Pseudocode is a simpler version of programming code in plain English which uses short
phrases to write code for a program before it is implemented in a specific programming
language.
There are many types of algorithms used in Artificial Intelligence applications for problem-
solving. The most simple and common problem-solving algorithms used by AI are:
Searching Algorithms: That can be used to help find the data we are seeking.
Sorting Algorithms: That can be used to will put items in a list into an order.
Now that we have learned how AI uses algorithms to solve real life problems, we will step
ahead in the world of AI languages. The medium to talk to a machine is by learning their
language. So the next Unit focuses on coding for AI, which will help instruct our machine

135
AI uses much more complex algorithms such as Classification, Regression or Clustering
Algorithms.
In Classification Algorithms, the AI machine uses supervised learning and defines the rules
with a training set and then when we give it new objects, it classifies them according to the
rules defined previously. These rules could be different for different algorithms.
Now that we have learned how AI uses algorithms to solve our real-life problems, we will step
ahead in the world of AI languages. The medium to talk to your machine is by learning their
language. So, the next unit focuses on coding for AI.

136
Let's Learn Artificial Intelligence - Base Module

UNIT 6
AI LANGUAGES

Key Learning Outcomes


At the end of the module, you will be able to:
a) Observe the use of hit and trial, as well as feedback in the
learning process
b) Train or teach existing AI applications such as voice recognition
or face recognition software
c) Create simple codes using Python language

Topic Covered
AI and computer programming | Scratch | Python |
Top AI languages in 2020

139
6.1 AI AND COMPUTER PROGRAMMING
Do you aim to become a software engineer? Do you want to develop your own
mobile application? Do you want to develop AI? The path that will get you there is
Programming; some people also call it Coding.
A program is a set of instructions that are provided to the computer to perform a
certain function.
The execution of the program involves processing the raw data into the desired output
format.
High-level languages are the ones that are used to write these programs. These are
little complex as compared to the machine language or low-level language that the
computer understands.
Various languages help us in communicating with computers such as C, C++, C#,
Java, Python, R, etc. In between the high-level language and low-level language is
the assembly language which is also referred to as the symbolic machine code. An
assembler is used to convert the assembly code into executable machine code that
can be interpreted by the computer.
The most popular programming languages that are used in the current scenario are
C, Python, C++, Java, SCALA, C#, R, Ruby, Go, Swift and JavaScript. Let us study some
points that provide an idea about how AI and programming relate to each other.

By learning to program, one gets to understand the mathematical concepts


and data analysis. By combining human insights with programming, one can
build successful AI projects.

Al involves finding insights and patterns inside data which is achieved by writing
and understanding complex algorithms.

Through programming, one can design customized solutions for various


businesses.

It has been predicted that AI would serve as an important tool and assist the
programmers in the future. This will be done by robotically controlling the
repetitive tasks, thereby allowing the programmer to focus on more important
strategies.

140
Let's Learn Artificial Intelligence - Base Module

6.2 SCRATCH
Being a free visual programming language, Scratch was developed to create and
program animations, games, music, interactive stories and much more. The Lifelong
Kindergarten Group had developed Scratch at the MIT Media Lab. Currently, the
software is available in 50 different languages. Scratch can run on Windows, Macintosh
and Linux Operating Systems.
Scratch helps you share the creations with other people who are a part of the online
community. The platform is helpful for understanding the essential skills that are
required in the 21st century. Also, it helps young people learn how to think creatively,
reason systematically and work collaboratively.
With Scratch, the process of creating and programming innovative things has become
simplified.
The main motive behind the introduction of Scratch was to teach computational
thinking using a simple yet powerful building-block approach to software development.
The key feature in Scratch is that it focuses more on problem-solving skills rather than
a specific syntax. (Syntax refers to the rules to be followed that specify the correct
combined sequence of symbols that can be used to form a correctly structured
program using a given programming language.)

DOWNLOAD

Download the Scratch programming


platform from the given link:
https://scratch.mit.edu/download

141
TUTORIAL

Start programming using Scratch by


watching the online tutorial through
the given link:

https://scratch.mit.edu/projects/
editor/?tutorial=getStarted

PROJECT
Project Name: Smart Home System using Scratch and IBM Watson API
Project Description: Create AI in Scratch and find out how machine learning really
works!
Learning Outcome:

1. Apply Blocky Coding


2. Experience the full AI Project Cycle
3. Determine Training Data
4. Train an AI Model
In this project, you will make a virtual home that can react to what you say to it. You’ll
be able to control the virtual devices like fan or light in the home by saying what
you want. To start with, you will need to program a list of rules for understanding
commands. Next, you will teach the computer to recognize commands for different
devices by giving it examples of each.
Requirements: We will be using Scratch software and the application given below.
There is no need for any additional hardware for this project. You need to have the
login credential to access this portal, so you can go to the site and create one. The
completion time for this project, for a beginner, should not be more than an hour. You
now need to follow instructions well.

142
Let's Learn Artificial Intelligence - Base Module

EXPLORE

To use this application visit the


following link:
https://machinelearningforkids.co.uk/

PROJECT

Learn and practice how to create a Smart Home System using Scratch
and IBM Watson API. Please find below the link where the module file
(pdf) can be downloaded:
https://www.aim.gov.in/smarthomeproject

6.3 PYTHON
Python is an object-oriented programming language created by Guido Rossum in
the year 1989. The language platform aims at simplifying the complex applications.
The Python scripts are stored in files which are named with the extension .py. Python
has interfaces to many operating systems such as Windows, Linux, Unix, etc. Also, it
is extensible to languages such as C and C++. Giants such as NASA, Google, YouTube,
BitTorrent use Python extensively in various projects.

The latest version of Python, i.e. Python 3, is being widely used in artificial intelligence,
natural language generation, neural networks and other advanced fields of computer
science.

143
WHY PYTHON FOR AI?

Less Coding involved: Python support consists of predefined packages where


we don’t have to code algorithms. AI being a complex field involves a lot of
algorithms. Python includes “check as you code” feature that significantly
facilitates the testing of code.
Pre-built libraries: Python contains 100s of libraries wherein the necessary
packages can be installed and loaded with a single command. Some key
libraries are NumPy, Keras, TensorFlow and PyTorch.
Platform independent: Python is compatible with multiple platforms such as
Windows, MacOS, Linux, Unix, etc.
Easy to learn: Unlike other programming languages, Python uses a simple
syntax which can be used in projects ranging from the addition of strings to
building a machine learning model.
Massive community support: Python has several communities, groups, and
forums that involve programmers and users who help each other.

144
Let's Learn Artificial Intelligence - Base Module

IMPORTANT LIBRARIES IN PYTHON


Tensorflow: An offering by Google, this library is used in writing Machine
Learning algorithms and heavy computations involving neural networks.
Scikit-Learn: Sci-kit is used for dealing with complex data, and it is a library
associated with NumPy and SciPy.
NumPy: Numpy is a python library that is used for computing scientific and
mathematical data.
Theano: Theano is a functional library that helps in the calculation and
computation of mathematical expressions.
Keras: Keras has several functionalities for computing models, evaluating
datasets, visualizing graphs, etc. This library has simplified the implementation
of neural networks.
NLTK: NLTK or Natural Language ToolKit is an open-source Python library to
help in natural language processing, text analysis, and text mining.

ELEMENTS OF PYTHON
A variable in Python is a reserved memory location that store values as entered by the
user. In simpler terms, a variable provides data to the computer for further processing.
There are various ways by which we can represent variables. These can be declared by
any name or even alphabets like a, aa, abc, etc.
If “x” is the variable to be declared with a value “10” then we can write the following
command:
x=10
A convenient way to divide the code into useful blocks is by using what we call as a
function. A function can be understood as block of instructions that performs a single
and related action. The use of functions in a code makes it more readable and saves
the programmer’s time. Functions can be classified as built-in functions and user-
defined functions. Built-in functions as the name suggests are already a part of the
Python library. These are predefined in the Python programming interface. On the
other hand, user-defined functions are the functions that are invoked or called by
the user to be used in a code. These types of functions are not pre-existing and are
defined as per the user’s imagination.

145
Python has many built-in functions such as:
print( ) : Prints an object specified in the code as an output.
int( ) : Converts a string or a number datatype to an integer datatype.
len( ) : Returns the length of an object.
Syntax:
def functionname( parameters ):
“function_docstring”
function_suite
return [expression]
Let us understand how to use a function in a code.

Example:

def printas( str ):


“This prints a passed string into this function”
print(str)
return

# Now you can call printas function


printas(“My Name is Samuel”)
printas(“I love Python programming”)

Output

This code will generate the following output:

My Name is Samuel
I love Python programming

Note that the function “print(str)” is a built-in function whereas “printas( )” is a user-
defined function.

146
Let's Learn Artificial Intelligence - Base Module

STANDARD DATA TYPES


The data stored in the memory can be of several types. This can be understood through
an example. Suppose a person’s age is stored as a numeric value, whereas the address
is stored as alphanumeric characters.
Python consists of various standard data types that are used to define the operations
possible while running a code.
Python has five standard data types −
Numbers
String
List
Tuple
Dictionary

TUTORIAL

Get hands-on experience by learning from the following link:

https://docs.python.org/3/tutorial/introduction.html

Python Numbers
The values stored by Number data types are Numeric values. Number objects are only
valid when they are assigned values. For example:
var1=10
var2=50
In Python, there are four types of numerical types, i.e. int (signed integers), long (long
integers, can be octal or hexadecimal), float (floating point real values) and complex
(complex numbers).

12

147
Python Strings
Strings are sets of characters that are represented in quotation marks. In Python,
strings can be declared in single or double quotes. The subsets of strings can be
declared using the slice operator ( ).

str=’Hello World!’
print(str) # Prints complete string
print(str[0]) # Prints first character of the string
print(str[2:5]) # Prints characters starting from 3rd to 5th
print(str[2:]) # Prints string starting from 3rd character
print(str*2) # Prints string two times
print(str+”TEST”) # Prints concatenated string

Output
This code will generate the following output:
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST

Python Lists
A list in Python contains items that are separated by commas and enclosed within the
square brackets.

list=[‘abcd’,786,2.23,’john’,70.2]
tinylist=[123,’john’]

148
Let's Learn Artificial Intelligence - Base Module

print(list) # Prints complete list


print(list[0]) # Prints first element of the list
print(list[1:3)] # Prints elements starting from 2nd till 3rd
print list[2:] # Prints elements starting from 3rd element
print(tinylist*2) # Prints list two times
print(list+tinylist) # Prints concatenated lists

Output

This code will generate the following output:

[‘abcd’, 786, 2.23, ‘john’, 70.2]


abcd
[786, 2.23]
[2.23, ‘john’, 70.2]
[123, ‘john’, 123, ‘john’]
[‘abcd’, 786, 2.23, ‘john’, 70.2, 123, ‘john’]

Python Tuples
A tuple is another sequence data type that is quite similar to the list. A Python tuple
consists of a number of values that are separated by commas. Tuples and lists are
different in the sense that the lists are enclosed in brackets ( [ ] ) whereas tuples are
enclosed in parentheses ( ( ) ). Also, the elements and size of a list can be changed,
unlike tuples which cannot be updated. Hence, tuples can be understood as read-only
lists. Let us understand tuples from a Python code as given below:
tuple=(‘abcd’,786,2.23,’john’,70.2 )
tinytuple=(123,’john’)

149
print(tuple) # Prints complete list
print(tuple[0]) # Prints first element of the list
print(tuple[1:3]) # Prints elements starting from 2nd till 3rd
print(tuple[2:)]) # Prints elements starting from 3rd element
print(tinytuple*2) # Prints list two times
print(tuple+tinytuple) # Prints concatenated lists

Output
The code will generate the following output:

(‘abcd’, 786, 2.23, ‘john’, 70.2)


abcd
(786, 2.23)
(2.23, ‘john’, 70.2)
(123, ‘john’, 123, ‘john’)
(‘abcd’, 786, 2.23, ‘john’, 70.2, 123, ‘john’)

Dictionary in Python
Dictionary in Python refers to the unordered collection of data that stores data values
(like a map). The dictionaries in Python are written with curly brackets and consist of
keys and values. Let us see an example how a dictionary is used in Python.

Example:
mydict = {
“subject”: “Maths”,
“topic”: “Algebra”,
“marks”: 86
}
print(mydict)

150
Let's Learn Artificial Intelligence - Base Module

Output
The code will generate the following output::

{‘subject’: ‘Maths’, ‘topic’: ‘Algebra’, ‘marks’: 86})

HOW TO INSTALL PYTHON FOR WINDOWS


For installing Python, there is a need to install PyCharm, a cross-platform editor that
has been developed by JetBrains. PyCharm includes all the tools that are needed for
developing programs in Python.

1. For downloading and installing Python go to the webste and choose the
version to be installed

DOWNLOAD

To download Python click on the


following link
http://www.python.org/downloads/

2. As the download completes, click on the “Install Now” tab. The screen will
display the setup progress at this point.

3. Once the process is complete, the screen shows the message “Setup was
successful”.

151
4. Learn more about AI languages by going to the jetbrain website

DOWNLOAD

To download PyCharm click


on the following link and go to
Community Section.
http://www.python.org/downloads/

5. After the download is complete, click on the Run the exe link. Now, click Next
once the setup wizard starts.

6. You will be given an option to choose the installation path. Click “Next” once the
installation path has been selected.

7. In the subsequent screen, you will be given a choice to create a desktop shortcut.
You will be asked whether the shortcut is 32-bit or a 64-bit. Click on the “Next”
icon after you have selected the required option.

8. Next, select “JetBrains” under the start menu folder. Click on “Install” once selected.

9. Wait for the installation process to be complete.

10. Once the installation process is complete, the screen shows a message saying
PyCharm is installed on your computer. To run the program, select “Run
PyCharm Community Edition” box and click on “Finish”.

CREATE YOUR FIRST PROGRAM

1. Open the PyCharm Editor installed on your system. An introductory screen will
show up on your system.

2. Click on “Create New Project” for creating your first project and starting to code
in Python.

152
Let's Learn Artificial Intelligence - Base Module

3. Select the location where you wish the project is to be created. You can change
the name to something meaningful such as “MyFirstProject” or “NewProject”.
Click on “Create”.
4. Next, go to the “File” menu and click on “New”. Click on the option “Python File”.
5. A pop-up window will appear where you can enter the filename such as “Hello
World” and hit “OK”.
6. Next, type a simple program, i.e. print(‘Hello World!’).
print(“Hello World!”)
7. Next, go to the “Run” menu and select “Run” for running the program. The
shortcut for this is Alt+Shift+F10.
8. The output of the program will be displayed at the bottom of the screen. `

How to print a simple string


Example: 1
To print “I love Python”, use the print () function as follows:
print(“I love Python”)

Output
This code will generate the following output:
I love Python

Example: 2
To print the name of five Indian states, use the print () function as follows:
print(“Rajasthan”)
print(“Assam”)
print(“Uttar Pradesh”)
print(“Odisha”)
gp
print(“Jharkhand”) õK
YL[
ôKK
P
PH

};
DE
i CO
{.
uj

153
Output

This code will generate the following output:

Rajasthan
Assam
Uttar Pradesh
Odisha
Jharkhand

How to print blank lines


For printing 10 blank lines in Python/, one should type:
print(10*”\n”) or print(“\n\n\n\n\n\n\n\n\n\n”)
The code would be as follows:
print(“I love Python”)
print(10*”\n”)
print(“This is my first Python project”)

Output

This code will generate the following output:

I love Python
This is my first Python project

To print the value of pi


Here, first, we are going to import the math library,
import math
Then, we will use the print function to print the value of “pi” from the math library,
print(math.pi)
When put together, it becomes:
import math
print(math.pi)
which produces the output,

154
Let's Learn Artificial Intelligence - Base Module

Output

This code will generate the following output:


3.141592653589793

How to declare and use a variable in Python


To assign a value to a variable, use the following command:
X=100

If we want to print the value of the variable, then


print(X)
Also, we can re-declare the variable in the same code,
X=100 #Variable declared initially
print(X)
x= “I love Python”
print(x)

Output

This code will generate the following output:


100
Note: In Python version 2, we use the print function as
print x
whereas in Python version 3, we use the print function as
print(“x”) to print only the variable “x” whereas print(x) will print the value stored in x.

Concatenate variables in Python


Let us see how to concatenate a string and a number together. In this case, we have
taken “Python” as the string and “100” as the number.
If we type the following command,
print(“Python” +100)
there will be an error (type error) since “100” has not been declared as a string.

155
The following program would return an undefined output:
a= “Python”
b=100
print(“a + b”)
For making this program to return a defined output, it should be written as:
a= “Python”
b=100
print(a+str(b))

Here, the “str” function takes variable to be a string.

Output
This code will generate the following output:

Python100

Delete a variable in Python


For deleting a variable in Python, we use the command del “variable name”.
Let us the understand this while using it in a code:

f=11; #Variable f declared and initialized


print(f) #Value 11 is displayed as the output

del f #Variable f deleted


print(“f”) #Will return an error since the given variable had already been deleted

How to print the version of Python being used as an output


import sys
print(“Python version”)
print(sys.version)
print(“Version info.”)
print(sys.version_info)

156
Let's Learn Artificial Intelligence - Base Module

Output
This code will generate the following output:

Python version
3.7.3 (default, Nov 12 2019, 11:53:27
[GCC 5.4.0 20190611]
Version info.
sys.version_info(major=3, minor=5, micro=2, releaselevel=’final’, serial=0)

Print your name in Python


name=input(“Enter your name:”)
print(“Your name is “+name)

>>Enter your name: Andrew


Your name is Andrew

Exercises:
1. Assume the following list and write a program to print all the given elements that
are less than 10.

a = [4, 7, 12, 9, 18, 23, 67, 5, 26, 72, 93]

Sol: print(“4, 7, 9, 5”)

2. Provide a command to output all the prime numbers from the given list.

x = [1, 8, 2, 17, 19, 26, 58, 80, 96]

Sol: print(“1, 17, 19”)

157
6.4 TOP AI LANGUAGES IN 2020
The scientists of Artificial Intelligence are continuously evolving the AI languages
to better suit the needs of developers. Following are some links about lastest AI
language:

EXPLORE

Read more about the programming languages used in Artificial Intelligence


(AI) by visiting the following links:

https://www.rankred.com/best-artificial-
intelligence-programming-language/

https://www.techindiatoday.com/programming-
languages-for-artificial-intelligence/

https://www.springboard.com/blog/best-
programming-language-for-ai/

158
Let's Learn Artificial Intelligence - Base Module

What have we learned


A program is a set of instructions that are provided to the computer to perform a certain
function. Certain languages are used to write these programs such as C, C++, C#, Java, Python,
R, etc. The most popular programming languages that are used in the current scenario are C,
Python, C++, Java, SCALA, C#, R, Ruby, Go, Swift and JavaScript.
Scratch is a free visual programming language that was developed to create and program
animations, games, music, interactive stories and much more by the Lifelong Kindergarten
Group at the MIT Media Lab.
Python is an object-oriented programming language that aims at simplifying the complex
applications. Python has interfaces to many operating systems such as Windows, Linux, Unix,
etc. Also, it is extensible to languages such as C and C++. Giants such as NASA, Google, YouTube,
BitTorrent use Python extensively in various projects.

Important libraries in Python are:

TensorFlow Scikit-Learn NumPy Theano Keras


A variable in Python is a reserved memory location that stores values as entered by the user.
In simpler terms, a variable provides data to the computer for further processing.
Python has five standard data types −
Numbers String List Tuple Dictionary
Strings are sets of characters that are represented in quotation marks. In Python,
strings can be declared in single or double-quotes. The subsets of strings can be
declared using the slice operator. A list in Python contains items that are separated
by commas and enclosed within the square brackets.
A tuple is another sequence data type that is quite similar to the list. They are enclosed
in parentheses ( ( ) ). The difference between lists and tuples is that the elements and
size of a list can be changed, unlike tuples which cannot be updated.
As you begin to get the hang of writing algorithms and programs for AI, there is a need
to be aware of the many risks and pitfalls that one must factor in, while developing
and using AI. The next Unit looks into some of these issues that impact choices of
developers and users alike, within the realm of Ethical and responsbile AI.

159
Let's Learn Artificial Intelligence - Base Module

UNIT 7
ETHICS AND AI

Key Learning Outcomes


At the end of the module, you will be able to:
a) State some of the ethical challenges posed by artificial intelligence
b) Explain the importance of ensuring that the AI is not unfair or
harmful to anyone

Topic Covered
Ethics and AI

161
7.1 ETHICS AND AI
AI is a comparatively new field and is likely to impact humanity in a big way. There are
many things to be considered to ensure that it does not harm us in any way or lead to
any unfair actions.
Given below are some scenarios that will help you understand the kind of ethical is-
sues that are appearing due to AI.

Ethical Issues – Scenario 1


When you were all asked to collect information from your friend about the
height, weight, favorite subject, some of you may have faced people who did
not want to share some of this information about themselves.
If someone does not want to share his or her personal information, what will
you do?
1. Will you force the person to tell?
2. Will you make fun of the person and tease him or her for wanting to hide
things?
3. Will you explain that this information is only for your activity and that
you will take his or her details only if they are providing it willingly?
4. Will you give them the option to give you the data with a promise of not
disclosing who has given the data?
5. You will collect data anonymously, in a manner where you collect data
from everyone, but you cannot identify
who has given what data?
What if your friend is ready to share but asks
you not to show it to anyone? But you know
that you will have to show the results to the
teacher at least.
What will you do?

162
Let's Learn Artificial Intelligence - Base Module

AI relies on data and data can be personal and confidential.


Can you think of various types of data that has the potential to be misused, therefore
can be considered classified or sensitive?

Think of information about yourself that you would not like to share with others. What
would that data or information be?

Think about information about your school or home, that if ended up in the hands of
the wrong type of people can be used to harm students and teachers. What kind of
data might that be?

163
As discussed in Unit 3, Datasets may be public or private. Therefore, people and
organizations have a responsibility to ensure that only safe data finds its way into
public Datasets. Similarly, data in Private Datasets too need some authorization and
permission from those to whom the data belongs for its collection, privacy control,
and use. Laws on Data including its collection, storage, and usage are evolving and
becoming more and more strict, this is another area where there will be a huge need
for experts in the future, including legislators, lawyers, consultants and analysts who
will address controversy, disputes, and risks of data.

Artificial intelligence can cause controversy and put people in danger or at risk of
injustice in many different ways. These risks could be on account of many things apart
from the leakage of data.

EXPLORE

For an introduction to Ethics in AI watch the following video:

https://www.youtube.com/watch?time_
continue=175&v=vgUWKXVvO9Q&feature=emb_logo

Ethical Issues – Scenario 2


If the shop keeper recommends a book saying many people like you are
buying this book and have liked it, you might be inclined to buy it.
However, what if you found out later that the author of the book was paying
a commission to the shop keeper, so he was trying to sell you that book by
saying it was popular.
How would you feel? Would you find it unfair?

164
Let's Learn Artificial Intelligence - Base Module

AI algorithms may do something similar on the internet.

When you are browsing the internet, watching movies, making purchases online, etc.
there are algorithms in the background that are connecting the dots and making
recommendations to you for further content and purchases including advertising
based on your profile and activity information.

On the other hand, there are already instances where organizations are accused of
trying to block and filter content for specific audiences based on people’s political
affiliations, religious beliefs, etc.

Such manipulation is seen as unfair by many people as people’s decision is often


based on the information they have; if the information you are presented with can be
manipulated, your decisions can be influenced.

Here is something to think about:

Every time you access the internet if an AI can make recommendations to you based
on your information available online and can withhold information if it chooses without
you knowing…
How do you think this works?
How can this impact you and others?
What are the potential advantages or risks of this?

165
Ethical Issues – Scenario 3
If the AI algorithm that a robot or car is working on proves to be wrong and
it causes an accident, who will be held responsible?
The owner,
The municipality that allowed these cars on the road
The programmer
The manufacturer

Already there is a debate that if the AI algorithm of self-driving cars or robot had to
choose between two potential accident victims, which one should they choose, or
should they be programmed to choose at all?

Ethical Issues – Scenario 4


Suppose a self-driving car is about to crash and has to choose whether to
crash against a senior citizen or a young person?
Should this be programmed?
On what basis do they choose?
What if the AI classifies the person wrongly? Accuracy is already an issue,
with even the best AI not being able to guarantee 100% accuracy.

This problem is already a widely known ethical problem.


The Ethics of Autonomous Cars

AUTONOMOUS
CAR

166
Let's Learn Artificial Intelligence - Base Module

EXPLORE

To get a view of complexities of self-driving cars and related ethical


issues.

https://www.theatlantic.com/technology/archive/2013/10/the-ethics-of-
autonomous-cars/280360/

People are witnessing artificial intelligence and automation replace several jobs
already and are worried that more and more AI applications will cause large-scale
loss of jobs and increase unemployment. Widespread use of AI in the workplace may
further cause greater inequality as fewer people may find jobs and those companies
which employ more artificial intelligence agents may likely be profitable, making
more money than others. AI companies being more profitable is likely to concentrate
wealth in the hands of fewer companies and people. Thus, adding to the inequality in
the world.

Ethical Issues – Scenario 5


What if your School installs an AI to decide what lunch each student should
eat? They do this to ensure each student has the best nutrition required for
growth. Now you are only allowed to eat what the AI decides.
What do you think about this?
Think about the advantages, disadvantages, and impact of this.
How do you think the school may use this?

An AI works on algorithms that are programmed by humans. It may result in making


people follow a decision made by someone who doesn’t have their best interest at
heart?
Since AI algorithms are very large and often the method used to arrive at decisions is
not visible to others. Usually people cannot know if the decision made is the best and
how the AI arrived at that decision.

167
Thus, if an AI makes wrong decisions for people either by mistake or deliberately,
they may have to follow it without question. Those who have the power to change
the algorithms and the AI can thus create conditions to benefit themselves and put
others are at a disadvantage. Therefore, giving rise to discrimination, exploitation
and injustice. AI Explainability is the common term used for how transparent and
understandable an AI is?

Ethical Issues – Scenario 6


Humans are today the dominant species on the planet due to our intelli-
gence. We can defend ourselves and attack other species, and this makes us
stronger than them.
If we build artificial intelligence capable of thinking like humans, will they
one day, have the same advantage over us?
Will we be able to stop them the day they become as strong and intelligent
as us?
Can we possibly lose control over them, because when we try to over-power
or shut them down, they can fight back and defend themselves by attacking
us?
The point in time when human beings are no longer the most intelligent
beings on earth, this is what some call the “singularity”.

There are groups of people who are considering this possibility too. They are trying to
find out how to stay in control of a complex, intelligent system.
Being fooled by machines is a very real possibility. Several people believe that they
have the right to know if they are chatting with a human or a machine. Artificially
intelligent bots are becoming better and better at modelling human conversation
and relationships.
In 2015, a bot named Eugene Goostman won the Turing Challenge for the first time.
In this challenge, human raters used text input to chat with an unknown entity,
then guessed whether they had been chatting with a human or a machine. Eugene
Goostman fooled more than half of the human raters into thinking they had been
talking to a human being. (Bossmann, 2016)

168
Let's Learn Artificial Intelligence - Base Module

(When you watch the video, keep a pen and paper handy. Do not miss out to record the
words you don’t understand and look these up in the dictionary…such as non-sequitur)

EXPLORE

To know more about the Turing Test and its Challenges click on the link
below.

https://www.youtube.com/watch?time_continue=232&v=3wLqsRLvV-
c&feature=emb_logo

Ethical Issues – Scenario 7

Imagine you meet someone in your neighborhood and become friends. After
spending a year together, you suddenly find out the person you thought
of as a friend is, in fact, an AI machine. A 45-year-old man programs and
operates the machine.
How would you feel, what will be your thoughts and concerns?.

Many times, we chat online on websites with chatbots. Who could be an AI programmed
to respond to various types of queries? Some websites declare it transparently that it
is a “Bot” that you are chatting with. However, some organizations may not do so, and
that may make you uncomfortable.

Ethical Issues – Scenario 8


There was a case where a machine was trained to recognize humans by using
facial features. During training the model, it was given more pictures with
faces of fair-skinned people. Consequently, the machine did not recognize
dark-skinned people as humans when it was finally used. So dark-skinned
people found it difficult to use the services of the AI machine.

169
While training the machine, developers may feed their own biases into it. i.e. their
personal preferences or aversions. A bias programmed into an AI can cause unfair
decision making on the part of the machine.

EXPLORE

To understand Bias in AI more clearly, visit the links below:

https://www.youtube.com/watch?time_ https://www.ted.com/talks/joy_
continue=1&v=ixDHOAOzjd8&feature= buolamwini_how_i_m_fighting_
emb_logo bias_in_algorithms?referrer=playlist-
what_are_we_really_teaching_
ai&language=en

It is not easy to determine if an algorithm is biased or fair, even for experts who
develop AI. In many cases, the details in an algorithm are often considered proprietary
(owned) and confidential, which is a source of financial value to its owners; therefore,
the owners guard it very closely.
For complex applications, the algorithms are also complex, and even those who have
created these don’t know how they exactly work. On top of that, now we are entering
into an area where AI is further creating AI. With the possibility of no transparency and
real control, this is creating a furore among ethicists. Our inability to see the inside of
an algorithm and understand how it arrives at a decision is often called the AI’s Black
Box problem.

Ethical Issues – Scenario 9

What if a talking machine learns to abuse on its own, can we get offended
and sue it?

170
Let's Learn Artificial Intelligence - Base Module

These are legal concerns, where laws will have to be framed.


Very recently, Alexa, a simple AI voice bot, advised a person to stab themselves in the
heart to save the planet from destruction. Who is going to be responsible for such
actions and its consequences?
Even in the case of our earlier scenario with self-driving cars, laws will have to be made
stating what is legally the right thing to program into a self-driving car. For example,
what to do when a car is faced with a situation where it must either hurt a pedestrian
to save its passenger or vice versa? Many such legal challenges will accompany AI,
which will necessitate new laws to be formed, but who is going to decide what is
going to be right?

Ethical Issues – Scenario 10

We are aiming to make machines that can act, think and learn like humans.
We are even making them recognize and respond appropriately to feelings
and emotions. Should at some point in their evolution, they be considered to
have the same rights as humans and be treated accordingly?

Humans are considered conscious beings;


at what stage do we consider artificially
intelligent agents to be conscious?

ACTIVITY

Take one of the above ten ethical concerns and find examples actual or
potential and research what impact could this have in different contexts?
Some of the contexts could be Healthcare, Banking, Insurance and Finance,
Online Matrimony and Dating, Law and Justice, etc. Also, find out what action
can be taken by society to address these? Make a presentation to others in
your class detailing the above.

171
EXPLORE

Preventing bias is essential for success of AI, learn more here:

https://www.ted.com/talks/kriti_sharma_how_to_keep_human_bias_out_of_
ai?referrer=playlist-what_are_we_really_teaching_ai&language=en

EXPLORE

You can access content on AI and Ethics at the links below to explore
various dimensions of it.
https://montrealethics.ai/blog/

EXPLORE

Here are the ten challenges and risks of AI. Click the link below.

https://www.youtube.com/watch?v=1oeoosMrJz4

172
Let's Learn Artificial Intelligence - Base Module

What we have learned


AI is a comparatively new field and is going to impact humanity in a big way. That is why there
are many things to be considered to ensure that it does not harm us in any way or lead to any
unfair actions. Some such issues are discussed below.
AI relies on data and data can be personal and confidential. There are certain types of
data that have the potential to be misused; therefore, they must be considered classified
or sensitive. The privacy of people should also be respected.
An AI works on algorithms that are programmed by humans. It may result in making
people follow a decision made by someone who doesn’t have their best interest at heart.
Since everyone does not understand AI algorithms, often people cannot know if the
decision made is the best and how the AI arrived at that decision.
Data manipulation is seen as unfair by many people as people’s decision is often based
on the information they have; if the information presented can be manipulated, then
people’s decisions can be influenced.
There is a debate that if the AI algorithm of self-driving cars or robots had to choose
between two potential accident victims, which one should they choose, or should they
be programmed to choose at all?
People are witnessing artificial intelligence and automation replace several jobs already
and are worried that more and more AI applications will cause large-scale loss of jobs
and an increase in unemployment. Widespread use of AI in the workplace may further
cause greater inequality.
While training the machine, developers may feed their own biases into it. i.e. their personal
preferences or aversions. A bias programmed into an AI can cause unfair decision making
on the part of the machine.
Then there is the big question that we are aiming to make machines that can act, think
and learn like humans, at what stage do we consider artificially intelligent agents to be
conscious?

Congratulations on completing the base module content in AI. We have some more
exciting areas for you to explore in case you are interested on the next page. The next
module, Step-up AI, will help develop further pracitcal skills through a number of projects
and higher level maths and programming abilities. We hope you will engage and enjoy
this journey for becoming an AI enthusiast.

173
Here’s more for the AI Enthusiast !
To further engage with AI, you can visit the following links where you can find current
developments, learning materials AI-enabled and projects to execute.

EXPLORE

Explore projects, courses, and competitions in AI

https://scratch.mit.edu/search/
projects?q=artificial%20intelligence

https://education.microsoft.
com/en-us/course/9534f9d9/0

https://aischool.microsoft.com/en-us/home

EXPLORE

Explore projects in AI
https://create.arduino.cc/projecthub/electropeak/
speak-to-arduino-and-control-it-with-google-
assistant-3791ee?ref=tag&ref_id=artificial%20
intelligence&offset=3
https://www.microsoft.com/en-
us/ai/ai-lab-projects

174
Let's Learn Artificial Intelligence - Base Module

Use an AI enabled tool for Graphics

EXPLORE

Spark is a creative tool powered by AI, free for education and licenses are
generated by Adobe team. Students can create, id and passwords by the
process given on the website

https://helpx.adobe.com/enterprise/using/edu-deployment-guide.html

175
ACKNOWLEDGEMENT

We thank all contributors and facilitators who have supported the development of this
Module. We thank the NASSCOM team for facilitating the Industry-Academia workgroup in
this endeavor.

Companies Represented

176
Workgroup Members
01. Arokiasamy Stephen Raj Head of Data Science and AI Robert Bosch Engineering &
Business Solutions Pvt. Ltd.
02. Ashutosh Raina Doctoral Research Scholar Edu. Tech. - IDP, IIT-Bombay
03. Asna Siddiqui Program Lead - INDIAai NASSCOM
04. Atul Udupi Chief Innovation Officer XcelCorp
05. BC. Jainaressh Account Manager UNITY 3D - Education
06. Ganesh Vaitheeswaran Senior Architect SAP Labs
07. Ganeshan Rajan Senior Data and Information Architect GE Healthcare
08. Garima Babbar Head Education & Skill Development Adobe Systems India Pvt. Ltd.
Programs, India & South Asia
09. Jassi Dimple Director PROGILENCE Capability
Development Pvt. Ltd.
10. Jibu Elias Content & Research Lead, INDIAai NASSCOM
11. Manish Kumar Managing Director IOT School
12. Naba Suroor Young Professional Atal Innovation Mission, Niti
Aayog
13. Narendra Chaudhary Field Engineer UNITY Technologies
14. Prakash Goteti Principal Consultant, AI and Analytics TechMahindra
15. Rahul Lodhe Senior Director Engineering SAP Labs
16. Ramswaroop Mishra Data Analytics & AI Competency Head WIPRO
17. Ronak Jogeshwar Innovation Lead Atal Innovation Mission, Niti
Aayog
18. S Manish Singh Managing Director PROGILENCE Capability
Development Pvt. Ltd.
19. Shruti Verma Head - Marketing and Operations, UNITY Technologies
Indian Sub-Continent
20. Snehasis Bagchi OEM Partner Lead - Future Skills NASSCOM
21. Sridhar Iyer Convener Edu. Tech. - IDP, IIT-Bombay
22. UnniKrishnan AR Head Business- Higher Education NVIDIA
& Research
23. Vinnie Jauhari Director - Education Advocacy Microsoft Corporation India
Pvt. Ltd.
24. Yudhisther Yadav Lead Strategic Initiatives – FutureSkills NASSCOM

177

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy