Class X AI Notes (Autosaved)
Class X AI Notes (Autosaved)
Talking
Thinking
Learning
Planning
Understanding
What is Intelligence?
Intelligence refers to the ability to understand, distinguish, question
things/objects/feeling/situations/ people along with acquiring and applying
knowledge and skills in various domain.
Types of intelligence
3
Text Editors
Chatting, commenting, emailing, etc., are a part of our lives. The keypad apps in
smartphones have built-in AI to auto-predict sentences and emojis. Gmail also has an
auto-predictor that suggests the next part of the sentence as you type.
Facial Recognition
Healthcare
Real-world AI products are rampant in the healthcare industry, with many hospitals
and pharma companies investing in advanced technology. Data shows that 38% of
medical and healthcare providers use computer-aided diagnosis when treating
patients
4
Customer Service
The customer service industry is quickly using chatbots to interact with customers.
Electronic Payments
Payment apps are well-known AI products in everyday life. Google Pay, PhonePe,
Paytm, etc., are commonly used payment apps in India to make instant electronic
payments by scanning a QR code.
Home Assistants
Home assistants are the easiest example of AI products used in our day-to-day lives.
Many of us have a home assistant device like Alexa, Siri, Cortana, or Google Assistant to
play music, place an order, read out webpages, or provide answers to our questions by
searching on the internet. They are hands-free devices that listen to our voice and
respond by answering in audio.
Generative AI has taken chatbots to the next level. They can give us predetermined
replies, understand our input, and provide a more detailed and realistic response.
ChatGPT by OpenAI took the world by storm. Google Bard and Microsoft Bing followed
it, though ChatGPT continues to be the most used chatbot. A survey
by Forbes reported that 97% of companies think ChatGPT will have a positive impact
on their operations.
What AI is not?
1. AI is not just Automation-Ex smart washing machine, smart TV
2. AI is not single entity like human or animal.
3. AI is not emotions like human being
4. AI is not magic. It is math and algorithm.
Deep learning is incredibly powerful tool for extracting complex pattern from data
using neural network having multiple layer in it.
Following figure depicts what deep learning is and where it resides in the field
of artificial intelligence:
Deep Learning is sub field of Artificial Neural Network which in turn sub field
of Machine Learning in Artificial Intelligence.
6
Artificial Intelligenec: Any technique that mimics human behavior using computer or
digital processor is known as artificial intelligence. For example: Robots, Chatbots,
Spam Filter & Email Categorization, Face Recognition etc
Applications
Requirements
Deep learning has following requirements:
2. Hardware Requirements: ).
3. Software Requirements: .
Domains of AI
Natural Language Processing (NLP)
Natural Language Processing (NLP) is a domain of AI that focuses on enabling
machines to understand, interpret, and generate human language.
The purpose of NLP is to bridge the communication gap between humans and
computers, allowing seamless interactions and extracting valuable insights from
textual data.
Applications of NLP
Virtual Assistants: NLP is the backbone of popular virtual assistants like Siri,
Alexa, and Google Assistant. These assistants understand spoken language,
process user queries, and provide relevant responses or perform tasks based on
the context.
Computer Vision
Definition and Scope of Computer Vision
Augmented Reality (AR): Overlapping virtual objects with the real world using
computer vision techniques, enriching the user experience.
Traffic Analysis: Analyzing traffic flow and congestion through computer vision
techniques to optimize transportation systems.
Data Science
10
4. Surveillance
AI has made it possible to develop face recognition Tools which may be used for
surveillance and security purposes.
As a result, this empowers the systems to monitor the footage in real-time and can be
a pathbreaking development in regards to public safety.
Session IV AI Ethics
AI ethics is a set of guiding principles designed to help humans maximize the benefits
of artificial intelligence and minimize its potential negative impacts. These principles
establish ‘right’ from ‘wrong’ in the field of AI, encouraging producers of AI
technologies to address questions surrounding transparency, inclusivity, sustainability
and accountability, among other areas.
AI ethics may require organizations to establish policies that respect data privacy
laws, account for bias in algorithms and explain to customers how their data is used
before they sign up for a product.
11
1. Privacy Rights: AI technologies often involve the collection and analysis of large
amounts of data, raising concerns about privacy rights. Governments and companies
must ensure that individuals' personal data is protected and secure.
12
2. Bias: AI algorithms can reflect and even biases present in the data they are trained on,
leading to unfair outcomes. It's essential to address bias in AI systems to ensure that
they do not violate individuals' rights.
3. Transparency and Accountability: The opacity of AI systems can pose challenges to
accountability and the right to information. There is a need for transparency in how AI
systems are developed, deployed, and used to ensure that individuals can understand
and challenge decisions that affect their rights.
AI Bias:
Facial Recognition: Facial recognition algorithms have been found to exhibit bias,
particularly against people of color.
Hiring Algorithms: AI-powered hiring platforms may bias. For instance, if a company
historically hired more men for technical roles, an AI hiring system trained on this
data may continue to favor male candidates.
AI bias can comes from various sources, both technical and societal. Here are
several reasons why AI systems may bias:
. Amazon’s Hiring-Not selected female resume for job hiring for technical post
1
2. COMPOS-
4. US healthcare-
UsS health care system used an AI model that assigned a lower risk rate for black
people than white people for same disease. It happened because the model was
optimized for cost, and since black people perceived as being less able to pay, the
model ranked their health risk lower than white people.
Reducing AI Bias
Advantages
Reduce human errors
Help in learning repetitive task
Provide digital assistance
Faster and more accurate
24x7 Availability
Disadvantages
High Costs
No Creativity
14
Unemployment
Make Humans Lazy
Emotionless
Questions answers
UNIT_II
Project Cycle
Defination-Project cycle refers to the life cycle of any project that describe different
project stages,with each step being separate from one another and delivering or
meeting a certain objective.
15
1. Problem Scoping
2. Data Acquisition
3. Data Exploration
4. Modeling
5. Evaluation
Problem Scoping
the problem but also set specific objectives, goals, and criteria for success. However,
scoping a problem is no simple task. It requires a deep understanding of the issue so
that we can work effectively and solve problem-solving.
Data Acquisition
This is the second phase of the AI project cycle, which is focused on obtaining the
necessary data for the project. While developing an AI system for predictive purposes,
it’s essential to begin by training it with relevant data.
1. Surveys
2. Web Scraping
3. Sensors
4. Cameras
5. Observations
Data Exploration
Data is a complicated thing, often just a bunch of numbers. But to make sense of it, we
need to find the hidden patterns. That’s where data visualization comes in. It’s all
about turning those numbers into pictures that are easy for people to understand.
Modeling
In the AI project cycle, modeling is a critical step in simplifying complex data for
computers to process and make predictions. At the start, data is usually presented in
charts or graphs to help people spot patterns. But, for AI systems to work, we need to
convert this data into a basic form that computers can grasp that is binary (0s and 1s).
Evaluation
Now, we are at the last stage of the AI project cycle. Once you’ve created and trained a
model, it’s crucial to thoroughly test it to evaluate how well it performs. To do this, we
use a separate dataset called testing data.
https://aiforkids.in/class-10/project-cycle/#problem-scoping
18
The first blank is the answer of who. The stakeholder, the name of the people, the
name of the group of people who are facing the problem.
In the second blank, you list the painpoints that you are going to solve. The
stakeholders might have five pain points, but you’re only going to solve the three top
three. You will list that here.
In the third blank you put the answer of “where.” Where they’re actually facing the
problem.
And the last blank is for why are we solving the problem? You can say, because we can
do this, this, and this, and list your reasons.
4W Canvas Examples
For the first example let us say there is a long waiting line for the parking area in the
mall near your house. People often park their cars on the roads rather than wait for
19
their turn. This creates traffic problems. And this is the problem that you are going to
solve.
Let’s get answer to the 4Ws:
Who is facing the problem – The car owners of the city.
What is the problem – They have to wait for a long time for parking space.
Where does the problem exist – In the XYZ Mall when they visit them.
Why are you are trying to solve this problem – because you have the ability to develop
a software that calculates the average wait time before the next parking space falls
vacant, so that somebody’s waiting in the line. They will know they have just two
minutes to wait and then they’ll join the queue and park the car in the parking.
This is how the problem statement can be framed.
Data Acquisition is the process of collecting accurate and reliable data to work
with. Data Can be in the format of the text, video, images, audio, and so on and it can
be collected from various sources like interest, journals, newspapers, and so on.
Data Sources
20
Surveys
1. Survey is one of the method to gather data from the users for the second stage of ai
project cycle that is data acquisition.
2. Survey is a method of gathering specific information from a sample of people. for
Example a census survey is conducted every year for analyzing the population.
3. Surveys are conducted in particular areas to acquire data from particular people.
Web Scraping
1. Web Scraping means collecting data from web using some technologies.
2. We use it for monitoring prices, news and etc.
Sensors
1. Sensors are very Important but very simple to understand.
2. Sensors are the part of IOT. IOT is internet of things.
3. Example of IOT is smart watches or smart fire alarm which automatically detects wire
and starts the alarm.. How does this happen, this happens when sensors like fire
sensor sends data to the IOT or the smart alarm and if sensor detects heat or fire the
alarm starts.
21
Cameras
1. Camera captures the visual information and then that information which is called
image is used as a source of data.
2. Cameras are used to capture raw visual data
Observations
API
1. API stands for Application Programming interface.
2. API is actually a messenger which takes requests from you and then tells the system
what you want and then it gives you a response
Validity: Data is considered valid if it has the correct format, type, and range. This may
differ based on the country, sector, or standards used. Here are several examples:
Accuracy: How effectively does the data describe the real-world conditions it is
trying to describe? This is one of the most important properties of high-quality
data. Accuracy can be checked by comparing data with a reliable source.
Timeliness
22
For data to retain its quality, it should be recorded promptly to manage changes.
Weekly over annually, tracking is the solution to timeliness. An example of timeliness
metrics is time variance.
In the form of numbers and text, in Comes in a variety of shapes and sizes
standardized, readable formats. that does not conform to a predefined
Typically XML and CSV. data model.
Follows a predefined relational data Typically DOC, WMV, MP3
model. Does not have a data model, though may
Stored in a relational database in tablets, have hidden structure.
rows, and columns, with specific labels. Stored in unstructured raw formats or in
Relational databases use SQL for a NoSQL database. Many companies use
processing. data lakes to store large volumes of
Easy to search and use with ample unstructured data that they can then
analytics tools available. access when needed.
Quantitative (has countable elements), Requires complex search, processing, and
easy to group based on attributes or analysis before it can be placed in a
characteristics. relational database.
Qualitative with subjective information
23
If we simplify this Data Exploration means that the data which we collected in Data
Acquisition, in Data Exploration we need to arrange it for example if we have data of
50 students in a class, we have their Mobile Number, Date of Birth, Class, etc.
In the process of data exploration, we can make a chart for that data in which all the
names will be at one place and all the mobile numbers at one, etc.
1. Google Charts
Google chart tools are powerful, simple to use, and free. Try out our rich gallery of
interactive charts and data tools.
2. Tableau
Tableau is often regarded as the grandmaster of data visualization software and for
good reason.
Tableau has a very large customer base of 57,000+ accounts across many industries
due to its simplicity of use and ability to produce interactive visualizations far beyond
those provided by general BI solutions.
24
3. FusionCharts
It can produce 90 different chart types and integrates with a large number of
platforms and frameworks giving a great deal of flexibility.
4. Highcharts
A simple options structure allows for deep customization, and styling can be done via
JavaScript or CSS. Highcharts is also extendable and pluggable for experts seeking
advanced animations and functionality.
Data visualization is the representation of information and data using charts, graphs,
maps, and other visual tools. These visualizations allow us to easily understand any
patterns, trends, or outliers in a data set.
Data visualization can be used in many contexts in nearly every field, like public policy,
finance, marketing, retail, education, sports, history, and more. Here are the benefits of
data visualization:
Storytelling: People are drawn to colors and patterns in clothing, arts and culture,
architecture, and more. Data is no different—colors and patterns allow us to visualize
the story within the data.
Accessibility: Information is shared in an accessible, easy-to-understand manner for a
variety of audiences.
Visualize relationships: It’s easier to spot the relationships and patterns within a data
set when the information is presented in a graph or chart.
Exploration: More accessible data means more opportunities to explore, collaborate,
and inform actionable decisions.
Types of chart
25
Session-V Modelling
What is an AI model?
26
An AI model is a program that has been trained on a set of data to recognize certain
patterns or make certain decisions without further human intervention.
Supervised Learning
Supervised learning is where a computer algorithm is trained on input data that has
been labeled for a particular output.
What is classification ?
Classification in which the algorithm’s job is to separate the labeled data to predict
the output.
What is Regression ?
Example: Regression is used to predict the weather. it is also used widely for weather
forecasting.
Unsupervised Learning
Example: Suppose a boy sees someone performing tricks by a ball, so he also learnt the
tricks by himself. This is what we call unsupervised learning.
Reinforcement Learning
In this type of learning, The system works on Reward or Penalty policy. In this an
agent performs an action positive or negative, in the environment which is taken as
input from the system, then the system changes the state in the environment and the
agent is provided with a reward or penalty.
The system also builds a policy, that what action should be taken under a specific
condition.
For example: Suppose you have a dataset containing 100 images of apples and
bananas each. Now you created a machine using Computer-Vision and trained it with
the labeled images of apples and bananas. If you test your machine with an image of an
apple it will give you the output by comparing the images in its datasets. This is known
as the Rule-Based Approach.
Datasets
Bas
Training Set Testing Set
e
https://aiforkids.in/class-10/project-cycle/#problem-scoping
Neural Networks are series of networks of independent Neurons just like in our brain,
but in computers, neurons are not the living tissue it is just a algorithm which give
output based on given data.
The key advantage of Neural Networks, are that they are able to extract data features
automatically without needing the input of the programmer.
Axon-The axon is a long fibre that carries signl from the cell body out to other
neurons.
Dendrites-Tree like structure that carries electrical signals into the cell body.
Structure of ANN
Structure: The structure of artificial neural networks is inspired by biological
neurons. A biological neuron has a cell body or soma to process the impulses,
dendrites to receive them, and an axon that transfers them to other neurons. The
input nodes of artificial neural networks receive input signals, the hidden layer
nodes compute these input signals, and the output layer nodes compute the final
output by processing the hidden layer’s results using activation functions.
33
Dendrite Inputs
Synapses Weights
Axon Output
Synapses: Synapses are the links between biological neurons that enable the
transmission of impulses from dendrites to the cell body. Synapses are the weights
that join the one-layer nodes to the next-layer nodes in artificial neurons. The
strength of the links is determined by the weight value
Layers in ANN
34
Input Layer: Each feature in the input layer is represented by a node on the
network, which receives input data.
Weights and Connections: The weight of each neuronal connection indicates
how strong the connection is. Throughout training, these weights are changed.
Hidden Layers: Each hidden layer neuron processes inputs by multiplying them
by weights, adding them up, and then passing them through an activation
function. By doing this, non-linearity is introduced, enabling the network to
recognize intricate patterns.
Output: The final result is produced by repeating the process until the output
layer is reached.
The Artificial Neural Network systems are modelled on the human brain and
nervous system.
Every node of layer in a Neural Network is compulsorily a machine learning
algorithm.
It is very useful to implement when solving problems for very huge datasets.
They can perform multiple tasks in parallel without affecting the system
performance.
Neural Networks have the ability to learn by themselves and produce the output
that is not limited to the input provided to them.
Training an ANN
Steps:
The very first advantage of neural networks is that they lead to an effective visual
analysis. Since an artificial neural network is similar to that of a human’s neural
network, it is capable of performing more complex tasks and activities as
compared to other machines.
3. User-friendly Interface
The last advantage among others is that they portray a user-friendly interface.
For any machine or artificial equipment to become a success, its interface and
usability of it should be user-friendly.
36
Despite their ability to quickly adapt to the changing requirements of the purpose
they are supposed to work for, neural networks can be a bit hefty to arrange and
organize. This means that they require heavy machinery and hardware
equipment to work for any application.
2. Incomplete Results
The second demerit of neural networks is that they can often create incomplete
results or outputs. Since ANNs are trained to adapt to the changing applications
of neural networks, they are often left untrained for the whole process.
3. Data Suitability
Another one of the challenges of neural networks is that they are highly
dependent on the data made available to them. This infers that the efficiency of
any neural network is directly proportional to the amount of data it receives to
process.
Applications of ANN
1. Facial Recognition
3. Social Media
No matter how cliche it may sound, social media has altered the normal boring course
of life. Artificial Neural Networks are used to study the behaviours of social media
users. Data shared everyday via virtual conversations is tacked up and analyzed for
competitive analysis.
Neural networks duplicate the behaviours of social media users. Post analysis of
individuals' behaviours via social media networks the data can be linked to people’s
spending habits. Multilayer Perceptron ANN is used to mine data from social media
applications.
4. Defence
Defence is the backbone of every country. Every country’s state in the international
domain is assessed by its military operations. Neural Networks also shape the defence
operations of technologically advanced countries. The United States of America,
Britain, and Japan are some countries that use artificial neural networks for
developing an active defence strategy.
5. Healthcare
The age old saying goes like “Health is Wealth”. Modern day individuals are leveraging
the advantages of technology in the healthcare sector. Convolutional Neural
Networks are actively employed in the healthcare industry for X ray detection, CT
Scan and ultrasound.
6. Signature Verification and Handwriting Analysis
Signature Verification , as the self explanatory term goes, is used for verifying an
individual’s signature. Banks, and other financial institutions use signature verification
to cross check the identity of an individual.
7. Weather Forecasting
38
The forecasts done by the meteorological department were never accurate before
artificial intelligence came into force. Weather Forecasting is primarily undertaken to
anticipate the upcoming weather conditions beforehand. In the modern era, weather
forecasts are even used to predict the possibilities of natural disasters.
Session 7 Evaluation
The stage of testing the models is known as Evaluation. In this stage, we evaluate each
and every model tried and choose the model which gives the most efficient and
reliable results.
Model Evaluation
Model Evaluation in Machine Learning is the process of determining a trained model's
effectiveness and quality using a variety of metrics and approaches. It entails
evaluating whether the model achieves the required goals and how well it generalizes
to fresh, untested data. We are able to examine several models, grasp their advantages
and disadvantages, and make informed judgments thanks to model evaluation.
Determining the model's predicted accuracy and evaluating its effectiveness in solving
the given problem are the key goals of model evaluation.
Model evaluation has various subtopics that are essential to thoroughly assess the
performance and accuracy of machine learning models. Some of the key topics within
model evaluation include.
39
Model evaluation has various subtopics that are essential to thoroughly assess the
performance and accuracy of machine learning models. Some of the key topics within
model evaluation include.
Result TP FN TP TN TP FP TP TP TN TN
Predicted
4. F1-Score
F1-score is used to evaluate the overall performance of a classification model. It is
the harmonic mean of precision and recall,
F1 SCORE= TP¿¿
For the above case:
F1-Score: = 0.8333
We balance precision and recall with the F1-score when a trade-off between
minimizing false positives and false negatives is necessary, such as in information
retrieval systems.
1. Interactive mode
2. Script mode
42
Script mode is where you write your code in a .py file and then run it with the
python command. This is the most common way that people use Python because it
lets you write and save your code so that you can use it again later.
Interactive mode is where you type your code into the Python interpreter directly.
This is useful for trying out small snippets of code, or for testing things out as you’re
writing them.
Keywords are reserved words in Python that have a special meaning and are used to
define the syntax and structure of the language. These words cannot be used as
identifiers for variables, functions, or other objects. Python has a set of 35 keywords,
each serving a specific purpose in the language.
When working with the Python language, it is important to understand the different types of
tokens that make up the language. Python has different types of tokens,
including identifiers, literals, operators, keywords, delimiters, and whitespace. Each token
type fulfills a specific function and plays an important role in the execution of a Python script.
1. Identifiers in Python
Identifiers is a user-defined name given to identify variables, functions, classes, modules, or any
other user-defined object in Python. They are case-sensitive and can consist of letters, digits, and
underscores. Yet, they cannot start with a digit. Python follows a naming convention called
“snake_case,” where words are separated by underscores. Identifiers are used to make code
more readable and maintainable by providing meaningful names to objects.
44
my_variable
my_function()
my_class
my_module
_my_private_variable
my_variable_with_underscores
3. Literals in Python
Literals are the fixed values or data items used in a source code. Python supports
different types of literals such as:
(i) String Literals: The text written in single, double, or triple quotes represents the
string literals in Python. For example: “Computer Science”, ‘sam’, etc. We can also
use triple quotes to write multi-line strings.
Python3
# String Literals
a = 'Hello'
b = "Geeks"
c = '''Geeks for Geeks is a
learning platform'''
# Driver code
print(a)
print(b)
print(c)
Output
Hello
Geeks
Geeks for Geeks is a
learning platform
(ii) Character Literals: Character literal is also a string literal type in which the
character is enclosed in single or double-quotes.
Python3
# Character Literals
a = 'G'
b = "W"
45
# Driver code
print(a)
print(b)
Output:
G
W
(iii) Numeric Literals: These are the literals written in form of numbers. Python
supports the following numerical literals:
Integer Literal: It includes both positive and negative numbers along with 0. It
doesn’t include fractional parts. It can also include binary, decimal, octal,
hexadecimal literal.
Float Literal: It includes both positive and negative real numbers. It also includes
fractional parts.
Python3
# Numeric Literals
a =5
b = 10.3
c = -17
# Driver code
print(a)
print(b)
print(c)
Output
5
10.3
-17
(iv) Boolean Literals: Boolean literals have only two values in Python. These are
True and False.
Python3
# Boolean Literals
a =3
b = (a == 3)
c = True + 10
# Driver code
print(a, b, c)
46
Output
3 True 11
(v) Special Literals: Python has a special literal ‘None’. It is used to denote nothing,
no values, or the absence of value.
Python3
# Special Literals
var = None
print(var)
Output
None
Python Operators
Operators are special symbols that perform operations on variables and values. For
example,
print(5 + 6) # 11
Python Operators
Operators are special symbols that perform operations on variables and values. For
example,
print(5 + 6) # 11
Run Code
1. Arithmetic Operators
2. Assignment Operators
3. Comparison Operators
4. Logical Operators
47
+ Addition 5 + 2 = 7
- Subtraction 4 - 2 = 2
* Multiplication 2 * 3 = 6
/ Division 4 / 2 = 2
// Floor Division 10 // 3 = 3
% Modulo 5 % 2 = 1
** Power 4 ** 2 = 16
# addition
print ('Sum: ', a + b)
# subtraction
print ('Subtraction: ', a - b)
# multiplication
print ('Multiplication: ', a * b)
# division
print ('Division: ', a / b)
# floor division
print ('Floor Division: ', a // b)
# modulo
print ('Modulo: ', a % b)
48
# a to the power b
print ('Power: ', a ** b)
Run Code
Output
Sum: 9
Subtraction: 5
Multiplication: 14
Division: 3.5
Floor Division: 3
Modulo: 1
Power: 49
# assign 5 to b
b = 5
print(a)
# Output: 15
a = 5
b = 2
# equal to operator
print('a == b =', a == b)
Output
a == b = False
a != b = True
a > b = True
a < b = False
a >= b = True
a <= b = False
Logical AND:
and a and b
True only if both the operands are True
Logical OR:
or a or b
True if at least one of the operands is True
Logical NOT:
not not a True if the operand is False and vice-
versa.
# logical OR
print(True or False) # True
# logical NOT
print(not True) # False
Python Comments
Comments can be used to explain Python code.
Comments can be used to make the code more readable.
Comments can be used to prevent execution when testing code.
#This is a comment
print("Hello, World!")
x = y = z = "Orange"
print(x)
print(y)
print(z)
print(c)
print(d)
Output:
assigning values of different datatypes
4
geeks
3.14
True
Variables
Variables are containers for storing data values.
Creating Variables
Python has no command for declaring a variable.
x=5 output
y = "John" 5
print(x) John
input()
The input function is used in all latest version of the Python. It takes the
input from the user and then evaluates the expression.
The Python interpreter automatically identifies the whether a user input
a string, a number, or a list. Let's understand the following example.
Session III
Python conditionals and loops
Conditional Statement
The if statement
In order to write useful programs, we almost always need the ability to check
conditions and change the behavior of the program accordingly. Conditional
statements give us this ability. The simplest form is the if statement, which has the
genaral form:
if BOOLEAN EXPRESSION:
STATEMENTS
It is frequently the case that you want one thing to happen when
a condition it true, and something else to happen when it is
false. For that we have the if else statement.
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
Else
The else keyword catches anything which isn't caught by the preceding
conditions.
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Parameter Description
# printing first 6
# whole number
for i in range(6):
print(i, end=" ")
print()
0 1 2 3 4 5
57
# printing a natural
# number from 5 to 20
for i in range(5, 20):
print(i, end=" ")
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
58
If a user wants to increment, then the user needs steps to be a positive number.
# incremented by 4
for i in range(0, 30, 4):
print(i, end=" ")
print()
0 4 8 12 16 20 24 28
If a user wants to decrement, then the user needs steps to be a negative number.
# incremented by -2
for i in range(25, 2, -2):
print(i, end=" ")
print()
25 23 21 19 17 15 13 11 9 7 5 3
Python range() function doesn’t support float numbers. i.e. user cannot use floating-
point or non-integer numbers in any of its arguments. Users can use only integer
numbers.
Operator in and not in
Ex- 3 in [1,2,3,4,5]
True
5 in [1,2,3]
False
5 not in [1,2,3,4]
True
P
y
t
h
o
n
Here, we have printed each character of the string language using a for loop.
values = range(4)
Output
0
1
2
3
# Python
# while loop
count = 0
while (count < 3):
count = count + 1
print("Hello Geek")
Hello Geek
Hello Geek
62
Hello Geek
Questions and answers
When we put these two elements together, “data+science” refers to the scientific
study of data. Data Science involves applying scientific methods, statistical
techniques, computational tools, and domain expertise to explore, analyze, and
extract insights from data. The term emphasizes the rigorous and systematic
approach taken to understand and derive value from vast and complex datasets.
Essentially, data science is about using scientific methods to unlock the potential of
data, uncover patterns, make predictions, and drive informed decision-making across
various domains and industries.
2. In Transport
Data Science is also entered in real-time such as the Transport field like Driverless
Cars. With the help of Driverless Cars, it is easy to reduce the number of Accidents.
63
For Example, In Driverless Cars the training data is fed into the algorithm and with
the help of Data Science techniques, the Data is analyzed like what as the speed
limit in highways, Busy Streets, Narrow Roads, etc. And how to handle different
situations while driving etc.
3. In Finance
Data Science plays a key role in Financial Industries. Financial Industries always
have an issue of fraud and risk of losses. Thus, Financial Industries needs to
automate risk of loss analysis in order to carry out strategic decisions for the
company.
For Example, In Stock Market, Data Science is the main part. In the Stock Market,
Data Science is used to examine past behavior with past data and their goal is to
examine the future outcome. Data is analyzed in such a way that it makes it possible
to predict future stock prices over a set timetable.
4. In E-Commerce
E-Commerce Websites like Amazon, Flipkart, etc. uses data Science to make a
better user experience with personalized recommendations.
For Example, When we search for something on the E-commerce websites we get
suggestions similar to choices according to our past data and also we get
recommendations according to most buy the product
5. In Health Care
In the Healthcare Industry data science act as a boon. Data Science is used for:
Detecting Tumor.
Drug discoveries.
Medical Image Analysis.
Virtual Medical Bots.
6. Image Recognition
Currently, Data Science is also used in Image Recognition. For Example, When we
upload our image with our friend on Facebook, Facebook gives suggestions Tagging
who is in the picture. This is done with the help of machine learning and Data
Science.
7. Data Science in Gaming
In most of the games where a user will play with an opponent i.e. a Computer
Opponent, data science concepts are used with machine learning where with the
help of past data the Computer will improve its performance. There are many games
like Chess, EA Sports, etc. will use Data Science concepts.
8. Autocomplete
AutoComplete feature is an important part of Data Science where the user will get
the facility to just type a few letters or words, and he will get the feature of auto-
completing the line. In Google Mail, when we are writing formal mail to someone so
at that time data science concept of Autocomplete feature is used where he/she is an
efficient choice to auto-complete the whole line. Also in Search Engines in social
media, in various apps, AutoComplete feature is widely used.
1. PROBLEM SCOPING
Problem Scoping means selecting a problem which we might want to solve
using our AI knowledge.
Problem Scoping is the process of identifing the scope the problem (like
cause, nature or solution of a problem) that you wish to solve with the help of
your project.
The process of finalising the aim of a system or project means you scope the
problem that you wish to solve with the help of your project. This is "Problem
Scoping".
4WS PROBLEM CANVAS
The 4Ws Problem canvas helps you in identifying the key elements related to
the problem. Let us go through each of the blocks one by one.
Who?
The “Who” block helps you in analysing the people getting affected directly or
indirectly due to it. Under this, you find out who the ‘Stakeholders’ to this
problem are and what you know about them. Stakeholders are the people
who face this problem and would be benefitted with the solution.
What?
Under the “What” block, you need to look into what you have on hand. At this
stage, you need to determine the nature of the problem. What is the problem
and how do you know that it is a problem? Under this block, you also gather
evidence to prove that the problem you have selected actually exists.
Newspaper articles, Media, announcements, etc are some examples.
Where?
Now that you know who is associated with the problem and what the problem
65
actually is; you need to focus on the context / situation / location of the
problem.
Why?
You have finally listed down all the major elements that affect the problem
directly. Now it is convenient to understand who the people that would be
benefitted by the solution are; what is to be solved; and where will the solution
be deployed. These three canvases now become the base of why you want to
solve this problem.
Data Acquisition
Data acquisition refers to the systematic process of capturing data from various
sources in the physical world, converting it into digital format, and making it
available for analysis. This process involves the use of sensors, instruments, and
technologies to measure and record parameters such as temperature, pressure,
voltage, sound, image, or any other measurable quantity.
Data Exploration
What is data exploration?
Data exploration is a statistical process that lets you see how your data is distributed,
identify any outliers, and determine which statistical tests might be most appropriate.
When deciding what type of analysis or interpretation is most accurate for your data,
preliminary data exploration can help you understand its characteristics.
1. Descriptive analysis
Descriptive analysis offers the most basic overview of your data. For example, let’s say
you are an educator and have a spreadsheet of test scores for your learners.
Descriptive analysis would give you a summary of the data and key features
2. Visual analysis
Visual analysis helps you visualize your data's trends, distribution patterns, outliers, and
tendencies. This may be particularly useful if you have large data sets that are difficult
to understand with numbers alone fully. You can see the bigger picture of your data by
creating visual representations like graphs, charts, and plots.
3. Statistical analysis
Statistical analysis provides a deeper look into your data using mathematical tools.
Data Modeling
Data Modeling is the process of analyzing the data objects and their relationship to the
other objects. It is used to analyze the data requirements that are required for the
business processes. The data models are created for the data to be stored in a
database. The Data Model's main focus is on what data is needed and how we have
to organize data rather than what operations we have to perform.
Data Model is basically an architect's building plan. It is a process of documenting
complex software system design as in a diagram that can be easily understood. The
diagram will be created using text and symbols to represent how the data will flow. It is
also known as the blueprint for constructing new software .
Evaluation
Model evaluation is the process of using different evaluation metrics to understand a
machine learning model’s performance, as well as its strengths and weaknesses.
67
Classification
The most popular metrics for measuring classification performance include accuracy,
precision, confusion matrix, log-loss, and AUC (area under the ROC curve).
Accuracy measures how often the classifier makes the correct predictions, as it is the
ratio between the number of correct predictions and the total number of predictions.
Precision measures the proportion of predicted Positives that are truly Positive.
Precision is a good choice of evaluation metrics when you want to be very sure of
your prediction. For example, if you are building a system to predict whether to
decrease the credit limit on a particular account, you want to be very sure about the
prediction or it may result in customer dissatisfaction.
A confusion matrix (or confusion table) shows a more detailed breakdown of correct
and incorrect classifications for each class. Using a confusion matrix is useful when
you want to understand the distinction between classes, particularly when the cost of
misclassification might differ for the two classes, or you have a lot more test data on
one class than the other. For example, the consequences of making a false positive
or false negative in a cancer diagnosis are very different.
Data Evaluation
Data evaluation may include the following tasks:
Deployment
is the mechanism through which applications, modules, updates, and patches are
delivered from developers to users. The methods used by developers to build, test
and deploy new code will impact how fast a product can respond to changes in
customer preferences or requirements and the quality of each change.
ZIP: ZIP files are used an data containers, they store one or more than one files in
the compressed form. it widely used in internet After you downloaded ZIP file, you
need to unpack its contents in order to use it.
JSON and XML
JSON (JavaScript Object Notation) and XML (Extensible Markup
Language) are formats for storing and exchanging structured and
hierarchical data
SQL and NoSQL
SQL (Structured Query Language) and NoSQL (Not Only SQL) are types of databases
that store and query data.
What is NumPy?
NumPy is a Python library used for working with arrays.
Installation of NumPy
If you have Python and PIP already installed on a system, then
installation of NumPy is very easy.
If this command fails, then use a python distribution that already has
NumPy installed like, Anaconda, Spyder etc.
Import NumPy
Once NumPy is installed, import it in your applications by adding
the import keyword:
import numpy
import numpy
print(arr)
[1 2 3 4 5]
NumPy as np
NumPy is usually imported under the np alias.
alias: In Python alias are an alternate name for referring to the same
thing.
Create an alias with the as keyword while importing:
import numpy as np
Now the NumPy package can be referred to as np instead of numpy.
import numpy as np
print(arr)
What is Pandas?
Pandas is a Python library used for working with data sets.
It has functions for analyzing, cleaning, exploring, and manipulating
data.
The name "Pandas" has a reference to both "Panel Data", and "Python
Data Analysis" and was created by Wes McKinney in 2008.
Pandas are also able to delete rows that are not relevant, or contains
wrong values, like empty or NULL values. This is called cleaning the data.
71
Installation of Pandas
If you have Python and PIP already installed on a system, then
installation of Pandas is very easy.
If this command fails, then use a python distribution that already has
Pandas installed like, Anaconda, Spyder etc.
import pandas as pd
mydataset = {
'cars': ["BMW", "Volvo", "Ford"],
'passings': [3, 7, 2]
}
myvar = pd.DataFrame(mydataset)
print(myvar)
cars passings
0 BMW 3
1 Volvo 7
2 Ford 2
Pandas as pd
Pandas is usually imported under the pd alias.
alias: In Python alias are an alternate name for referring to the same thing.
import pandas as pd
Example
72
import pandas as pd
mydataset = {
'cars': ["BMW", "Volvo", "Ford"],
'passings': [3, 7, 2]
}
myvar = pd.DataFrame(mydataset)
print(myvar)
What is Matplotlib?
Matplotlib is a low level graph plotting library in python that serves as a
visualization utility.
Matplotlib was created by John D. Hunter.
Matplotlib is open source and we can use it freely.
Installation of Matplotlib
If you have Python and PIP already installed on a system, then
installation of Matplotlib is very easy.
If this command fails, then use a python distribution that already has
Matplotlib installed, like Anaconda, Spyder etc.
Example
Draw a line in a diagram from position (0,0) to position (6,250):
plt.plot(xpoints, ypoints)
plt.show()
Basic Statistics
The arithmetic mean is the sum of all of the data points divided by the number
of data points.
75
The medium is 2.
77
Range
The range tells you the spread of your data from the lowest to the
highest value in the distribution. It’s the easiest measure of variability to
calculate.
To find the range, simply subtract the lowest value from the highest
value in the data set.
78
Variance-
Variance-
14-7=7
14-13=1
14-22=-8
Count of numbers=3
Average=114/3=38
Sqrt of 38 is 6.164=6
79
Function in Python
import numpy as np
Arry1=np.array([1,2,3,4,5,6,7,8,9])
Arry1
Other numpy functions
np.mean(arry1),np.medium(arry1),no.var(arry1),np.std(ary1)
We'll use diagrams, as well sample data to show how you can classify
data using the K-NN algorithm.
In Medical field
Types of Images
There are three types of images. They are as following:
1. Binary Images
It is the simplest type of image. It takes only two values i.e, Black and
White or 0 and 1. The binary image consists of a 1-bit image and it takes
only 1 binary digit to represent a pixel. Binary images are mostly used
for general shape or outline.
2. Gray-scale images
Grayscale images are monochrome images, Means they have only one
color. Grayscale images do not contain any information about color. Each
pixel determines available different grey levels.
3. Colour images
Colour images are three band monochrome images in which, each band
contains a different color and the actual information is stored in the
digital image. The color images contain gray level information in each
spectral band.
The images are represented as red, green and blue (RGB images). And
each color image has 24 bits/pixel means 8 bits for each of the three
color band(RGB).
85
Image:
87
Color: White
Resolution
Image resolution is typically described in PPI, which refers to how many pixels are
displayed per inch of an image.
Higher resolutions mean that there more pixels per inch (PPI), resulting in more
pixel information and creating a high-quality, crisp image.
Images with lower resolutions have fewer pixels,
Image Classification
Localisation
for now, consider that the location of the object in the image can be represented as
coordinates of these boxes. So this box around the object in the image is formally
known as a bounding box. Now, this becomes an image localization problem where
90
we are given a set of images and we have to identify where is the object present in
the image.
Note that here we have a single class. what if we have multiple classes? here is an
example,
In this image, we have to locate the objects in the image but note that all the
objects are not dogs. Here we have a dog and a car. So we not only have to locate
the objects in the image but also classify the located object as a dog or Car. So this
becomes an object detection problem.
OpenCV- Introduction
Opencv is a huge open-source library for computer vision, machine learning, and image
processing. Now, it plays a major role in real-time operation which is very important in
today’s systems. By using it, one can process images and videos to identify objects,
faces, or even the handwriting of a human.
OpenCV allows you to perform various operations in the image.
Read the Image : OpenCV helps you to read the image fro file or directly from
camera to make it accessible for further processing.
Image Enhacncement : You will be able to enhance image by adjusting the
brightness , sharpness or contract of the image. This is helpful to visualize quality
of the image.
Object detection: As you can see in the below image object can also be detected
by using OpenCV , Bracelet , watch , patterns, faces can be detected. This can
also include to recognize faces , shapes or even objects .
Image Filtering: You can change image by applying various filters such as
blurring or Sharpening.
Draw the Image: OpenCV allows to draw text, lines and any shapes in the
images.
91
Saving the Changed Images: After processing , You can save images that are
being modified for future analysis.
Session III Understanding convolution operator and CNN
Convolution operation-
93
94
1. Convolutional Layer
This layer is the first layer that is used to extract the various features
from the input images. In this layer, the mathematical operation of
convolution is performed between the input image and a filter of a
particular size MxM. By sliding the filter over the input image, the dot
product is taken between the filter and the parts of the input image
with respect to the size of the filter (MxM).
2.Pooling Layer- Pooling Layers divide the input data into small regions, called
pooling windows or receptive fields, and perform an aggregation operation, such as
96
taking the maximum or average value, within each window. This aggregation reduces
the size of the feature maps, resulting in a compressed representation of the input
data.
Uses/Application of CNN
98
3. Voice Assistants
These days voice assistants are all the rage! Whether its Siri, Alexa, or Google
Assistant, almost everyone uses one of these to make calls, place reminders,
schedule meetings, set alarms, surf the internet, etc. These voice assistants have
made life much easier. But how do they work? They use a complex combination of
speech recognition, natural language understanding, and natural language
processing to understand what humans are saying and then act on it. The long
term goal of voice assistants is to become a bridge between humans and the
internet and provide all manner of services based on just voice interaction.
However, they are still a little far from that goal seeing as Siri still can’t understand
what you are saying sometimes!
4. Language Translator
Want to translate a text from English to Hindi but don’t know Hindi? Well, Google
Translate is the tool for you! While it’s not exactly 100% accurate, it is still a great
tool to convert text from one language to another.
6. Grammar Checkers
1. PROBLEM SCOPPING
Let us look at various factors around this problem through the 4Ws problem
canvas.
Who Canvas – Who has the problem? or Who are the stakeholders?.
2. DATA ACQUISITION
To understand the sentiments of people, we need to collect their
conversational data so the machine can interpret the words that they use
and understand their meaning. Such data can be collected from various
means:
1. Surveys
2. Observing the therapist’s sessions
3. Databases available on the internet
4. Interviews, etc.
3. DATA EXPLORATION
Once the data has been collected, it needs to be processed and cleaned.
4. MODELLING
Once the text has been normalised, it is then fed to an NLP based AI model.
Depending upon the type of chatbot we try to make, there are a lot of AI
models available which help us build the foundation of our project.
5. EVALUATION
The model trained is then evaluated and the accuracy for the same is
generated on the basis of the relevance of the answers which the machine
gives to the user’s responses
AI engineer: AI engineers build models using machine learning algorithms and deep
learning neural networks that can be used to make decisions, such as in the production
of chatbots.
NLP engineer: NLP engineers create programs that can understand human languages
and respond accordingly, using a combination of computer science and AI.
Types Of Chatbot –
Mainly, chatbots are classified into three types: Rule-Based, AI-Based and Hybrid.
based on the keywords extracted from the user’s utterance. Most of them don’t
use NLP/NLU. The advantage of using this type of is that it is economic.
2. AI Based Chatbot: They are built using ML, NLP/NLU. It also provides answers
from a given database but the thing that makes it unique is that it becomes more
intelligent over time with the help of past interactions with the users.
3. Hybrid Chatbot: These are the most common type of chatbot. It is basically a mix
of both Rule-based and AI-based chatbots. They interact with humans and provide
a personalized reply i.e It can start the conversation with the user but when the
conversation gets deeper chatbot can be replaced by a human being.
Concept of NLP
They break up problem into very small pieces to simplify.
Remove complexity by removing extra information.
Use AI to solve each smaller piece separately
Tie together the processed result.
Finally convert the processed result to numbers so that computers can
understand it.
Text Normalisation
105
Tokenisation-
Tokenization, in the realm of Natural Language Processing (NLP) and
machine learning, refers to the process of converting a sequence of text into
smaller parts, known as tokens. These tokens can be as small as characters
or as long as words.
Remove stop words, special char. And numbers-Stop words do not add
much meaning in sentence.
Ex- and, the ,a,an
107
Stemming-
The process of removing affixes from a word so that we are left with the
stem of that word is called stemming. For example, consider the words
‘run’, ‘running’, and ‘runs’, all convert into the root word ‘run’ after
stemming is implemented on them.
Lemmatisation-
Lemmatization is a text pre-processing technique used in natural language
processing (NLP) models to break a word down to its root meaning to identify
similarities. For example, a lemmatization algorithm would reduce the word
better to its root word.
108
Case Normalisation-
Case Normalisation refers to conversion of all the words in the same case
(ofter lowercase) and finally convert to numbers.
Bag of Words
It is a representation of text that describes the occurrence of words within a
document.
A Bag of words contains two things
1. Vocabulary of known words
2. A measure of the presence of own words
Bag of words contains collection of words.
How does BoW work, and how do we implement it?
Here are the steps involved when we want to implement the Bag of
Word Model:
Preprocess the data: We should convert the text into a lowercase letter,
and we should remove all non-word characters and punctuation.
Finding the frequent words: The vocabulary should be defined by
finding the frequency of each word in the document. Each sentence
should be tokenized into words, and we should count the number of
occurrences of the word.
109
1. Data Collection:
We should consider some lines of text as different documents that need to
be vectorized:
The cat danced
Cat danced on chair
The cat danced with a chair
2. Determine the vocabulary:
The vocabulary is the set of all words found in the document. These are the
only words that are found in the documents above.
3. Counting:
The vectorization process will involve counting the number of times every
word appears: