0% found this document useful (0 votes)
10 views

AI Imp Topics (Final)

The document discusses artificial intelligence including key features like learning, reasoning, problem solving and perception. It also discusses different approaches to AI like thinking humanly, acting humanly, thinking rationally and acting rationally. The document then discusses advantages of AI, types of AI like narrow AI and general AI, AI agents including different types, searching methods in AI including uninformed and informed search, knowledge-based agents in AI including different types, and probability in AI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

AI Imp Topics (Final)

The document discusses artificial intelligence including key features like learning, reasoning, problem solving and perception. It also discusses different approaches to AI like thinking humanly, acting humanly, thinking rationally and acting rationally. The document then discusses advantages of AI, types of AI like narrow AI and general AI, AI agents including different types, searching methods in AI including uninformed and informed search, knowledge-based agents in AI including different types, and probability in AI.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

QUESTION 1:-

ARTIFICIAL INTELLIGENCE: -
Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that are
programmed to think like humans and mimic their actions. The term can also be applied to any machine
that exhibits traits associated with a human mind, such as learning and problem-solving.

Key features of AI include:


1. Learning: AI adapts and learns from new information or experiences.

2. Reasoning: Processes information for decision-making.

3. Problem-Solving: Tackles challenges using available data.

4. Perception: Recognizes and interprets objects, speech, and text.

5. Interaction: Engages with humans and the environment, using natural language and robotics.

The field of AI is vast and encompasses various approaches to mimic or replicate aspects of human
intelligence. These approaches can be categorized into four primary views:

1. Thinking Humanly (The Cognitive Approach): This approach focuses on understanding and
replicating human thought processes.

2. Acting Humanly (The Turing Test Approach): It emphasizes the ability of machines to perform
tasks in ways that would be indistinguishable from a human in the same situation.

3. Thinking Rationally (The Laws of Thought Approach): This perspective is about creating systems
that emulate logical reasoning processes.

4. Acting Rationally (The Rational Agent Approach): It involves developing agents that act
rationally to achieve their goals, based on their understanding and perception of the world.

Advantages of AI:
1. efficiency: Processes data rapidly for swift decision-making.
2. Availability: Operates continuously without fatigue.
3. Accuracy: Reduces errors compared to human work.
4. Automation: Takes over mundane tasks, freeing humans for complex tasks.
5. Personalization: Tailors services to individual needs through data analysis.
6. Innovation: Drives technological advancements, such as autonomous vehicles and smart devices.
7. Cost Reduction: Optimizes operations to save money over time.
Types Of AI:
1. Narrow AI (Weak AI): Specializes in one specific task. For example, chatbots on websites excel in
customer service interactions but can't perform other tasks.

2. General AI (Strong AI): Can perform a wide range of tasks, similar to human intelligence. As of
now, it's theoretical, akin to robots in science fiction stories.

3. Artificial Superintelligence: Hypothetically surpasses human intelligence in all areas. No real-


world examples exist; it's a concept explored in sci-fi like advanced AI systems controlling entire
cities.

QUESTION 2: -
AI Agents:
AI agents are autonomous entities in artificial intelligence that perceive their environment through
sensors and act upon that environment using actuators. They are designed to achieve specific
objectives, making decisions based on their programming and the data they gather.

Types of AI agents include:

1. Simple Reflex Agents: These agents act only based on the current percept, ignoring the
rest of the percept history.

Example: A thermostat programmed to turn on the heating when the temperature


drops below a certain threshold.

2. Model-Based Reflex Agents: These agents maintain an internal state to track the world,
allowing them to handle partial observability.

Example: A navigation system in a car that recalculates the route based on traffic
updates.

3. Goal-Based Agents: These agents act to achieve their goals, considering the future
outcomes of their actions.

Example: A chess-playing AI that decides moves based on a strategy to win the game.
4. Utility-Based Agents: Optimize actions based on a utility function for the best outcome.

5. Learning Agents: Adapt their actions based on past experiences and learning.

Searching Method:
In AI, searching methods are essential for problem-solving and decision-making processes. These
methods can be broadly categorized into two types:

1. Uninformed Search (Blind Search): This type of search does not have additional information
about states beyond that provided in the problem definition. Key types include:

• Breadth-First Search: Explores equally in all directions. This method is good when the
path cost is a non-decreasing function of the depth of the node.

BFS Searching CODE:-


from collections import defaultdict, deque for neighbor in self.graph[node]:
class Graph: if neighbor not in visited:
def __init__(self): queue.append(neighbor)
self.graph = defaultdict(list) visited.add(neighbor)
if __name__ == "__main__":
def add_edge(self, u, v):
self.graph[u].append(v) graph = Graph()
graph.add_edge(0, 1)
def bfs(self, start): graph.add_edge(0, 2)
visited = set() graph.add_edge(1, 2)
queue = deque([start]) graph.add_edge(2, 0)
visited.add(start) graph.add_edge(2, 3)
while queue: graph.add_edge(3, 3)
node = queue.popleft()
print(node, end=' ') print("BFS starting from node 2:")
graph.bfs(2)
• Depth-First Search: Explores as far as possible along each branch before backtracking.
It's memory-efficient but may get stuck in loops.

DFS Searching Code:-


from collections import defaultdict visited = set()
class Graph: self.dfs_util(start, visited)
def __init__(self): # Example usage:
self.graph = defaultdict(list) if __name__ == "__main__":
# Create a sample graph
def add_edge(self, u, v): graph = Graph()
self.graph[u].append(v) graph.add_edge(0, 1)
graph.add_edge(0, 2)
def dfs_util(self, node, visited): graph.add_edge(1, 2)
visited.add(node) graph.add_edge(2, 0)
print(node, end=' ') graph.add_edge(2, 3)
for neighbor in self.graph[node]: graph.add_edge(3, 3)
if neighbor not in visited: # Perform DFS starting from node 2
self.dfs_util(neighbor, visited) print("DFS starting from node 2:")
def dfs(self, start): graph.dfs(2)

2. Informed Search (Heuristic Search): These algorithms are more efficient as they use specific
knowledge about the problem to find solutions more efficiently. Examples include:

• Greedy Search: Chooses the node that appears to lead most directly to the goal.

• A Search*: Includes both the cost to reach the node and an estimate of the cost from
the node to the goal.
Knowledge-Based Agents in Artificial Intelligence
Knowledge-based agents in AI are systems with a knowledge repository used for decision-
making and actions. They interpret and reason with this knowledge. Types include intelligent
personal assistants, healthcare diagnostic systems, recommendation systems, and logistics
planning systems, aiding in complex decision-making across various domains.

Types Of Knowledge Based


Agents:
1. Logical Agents:
Logic-based agents use logic to represent and manage information. First-order logic
andpropositional logic are frequently used.
2. Rule-Based Agents:
The rule-based process initiates the decision-making process. Each rule has an action
and a condition. If the conditions are met, the relevant work is carried out.

3. Semantic Networks:
The Semantic Web uses nodes and edges to model relationships between elements.

4. Frame-Based Systems:
Framework organizes data into structures designed to represent knowledge about
specific concepts.
5. Bayesian Agents:
Similarly, reasoning is used by Bayesian agents to update beliefs and make decisions
based on new information.
6. Fuzzy Logic Systems:
Fuzzy logic agents use fuzzy sets and linguistic variables to handle uncertainty.

7. Production Systems:
A production process consists of products (policies) and control strategies
implemented.
8. Ontology-Based Agents:
Ontology based technology defines content and relationships in the domain through
therepresentation of information.
QUESTION 3: -
AI Agents:
Probability can be defined as a chance that an uncertain event will occur. It is the numerical measure of
the likelihood that an event will occur. The value of probability always remains between 0 and 1 that
represent ideal uncertainties.

• 0≤P(A)≤1, where P(A) is the probability of an event A.


• P(A)=0, indicates total uncertainty in an event A.
• P(A)=1, indicates total certainty in an event A.
We can find the probability of an uncertain event by using the below formula.
𝐓𝐨𝐭𝐚𝐥 𝐧𝐮𝐦𝐛𝐞𝐫 𝐨𝐟 𝐨𝐮𝐭𝐜𝐨𝐦𝐞𝐬
Probability of occurrence= 𝐍𝐮𝐦𝐛𝐞𝐫 𝐨𝐟 𝐝𝐞𝐬𝐢𝐫𝐞𝐝 𝐨𝐮𝐭𝐜𝐨𝐦𝐞𝐬

• P(¬A) = probability of a not happening event.


• P(¬A)+P(A)=1.

Probability in AI:
Definition: Probability is a measure of the likelihood that a particular event will occur. In the context of
AI, probability is used to model uncertainty and make decisions based on uncertain information.

Example: In a spam detection system, probabilities can be used to model the likelihood of an email
being spam or not based on various features such as the presence of certain keywords, sender
information, and email structure.
Bayes Rule:
Definition: Bayes' Rule is a fundamental concept in probability theory. It provides a way to update
probabilities based on new evidence. It is particularly useful in the context of making predictions or
inferences.

Example: Consider a medical test for a rare disease. Bayes' Rule can be used to update the probability of
having the disease based on the test result and the prior probability of the disease in the population.

Example-1:
Question: what is the probability that a patient has diseases meningitis with a stiff neck?
(Meningitis ( meh·nuhn·jai·tuhs )is a disease that causes inflammation of the meninges, the protective

membranes that cover the spinal cord and brain. It's also called spinal meningitis.)

Given Data:

A doctor is aware that disease meningitis causes a patient to have a stiff neck, and it occurs 80% of the

time. He is also aware of some more facts, which are given as follows:

• The Known probability that a patient has meningitis disease is 1/30,000.

• The Known probability that a patient has a stiff neck is 2%.

Let a be the proposition that patient has stiff neck and b be the proposition that patient has meningitis.

, so we can calculate the following as:

P(a|b) = 0.8

P(b) = 1/30000

P(a)= .02

Hence, we can assume that 1 patient out of 750 patients has meningitis disease with a stiff neck.
Example-2:
Question: From a standard deck of playing cards, a single card is drawn. The probability that
the card is king is 4/52, then calculate posterior probability P(King|Face), which means the
drawn face card is a king
card.
Solution:

P(king): probability that the card is King= 4/52= 1/13

P(face): probability that a card is a face card= 3/13

P(Face|King): probability of face card when we assume it is a king = 1

Putting all values in equation (i) we will get:

Application of Bayes' theorem in Artificial intelligence:

Following are some applications of Bayes' theorem:

• It is used to calculate the next step of the robot when the already executed step is given.

• Bayes' theorem is helpful in weather forecasting.

• It can solve the Monty Hall problem.


QUESTION 4:-
Machine Learning : -
Machine learning is a subset of artificial intelligence that provides systems the ability to
automatically learn and improve from experience without being explicitly programmed. It
focuses on the development of algorithms that can process input data and use statistical
analysis to predict an output while updating outputs as new data becomes available.

Types of Machine Learning:

1. Supervised Learning: This type involves an algorithm learning from labeled training
data, guiding the model towards making predictions or decisions based on past data.
Tasks include regression (predicting a continuous value) and classification (predicting a
discrete label).

2. Unsupervised Learning: Here, the algorithm learns patterns from unlabeled data. It
aims to model the underlying structure or distribution in the data to learn more about it.
Common tasks include clustering (grouping similar data points) and dimensionality
reduction (simplifying data without losing important features).

3. Reinforcement Learning: A type of machine learning concerned with how agents ought
to take actions in an environment to maximize some notion of cumulative reward. The
algorithm learns to achieve a goal in an uncertain, potentially complex environment.

Steps in an ML Prediction Program:


1. Data Collection: Gather the data that the algorithm will learn from.

2. Data Preprocessing: Clean the dataset to remove missing or irrelevant information.

3. Split the Data: Divide the data into training and testing datasets.

4. Choose a Model: Select the appropriate algorithm for the pattern you expect to find in the data.

5. Train the Model: Feed the training data to the model to let it learn from it.

6. Test the Model: Evaluate the model’s accuracy by making predictions on the test dataset.

7. Parameter Tuning: Adjust model parameters to improve its accuracy.

8. Prediction or Inference: Use the trained model to make predictions on new data.
Example Program for Prediction:
# Import necessary libraries
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
import pandas as pd

# Load dataset
data = pd.read_csv('data.csv')

# Preprocess and split the dataset


X = data.drop('target', axis=1)
y = data['target']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize and train the model


model = LinearRegression()
model.fit(X_train, y_train)

# Predict and evaluate the model


predictions = model.predict(X_test)
mse = mean_squared_error(y_test, predictions)

# Output the performance


print(f"The Mean Squared Error on the test set is: {mse:.2f}")
QUESTION 5:-
ANN : -
Artificial Neural Networks (ANN):

Artificial Neural Networks (ANNs) are computing systems inspired by the biological neural networks of
animal brains. An ANN is composed of a large number of interconnected processing nodes, known as
neurons, which work in unison to solve specific problems. ANNs are the foundation of deep learning
algorithms.

Characteristics of ANNs:
1. Layers: An ANN consists of an input layer, one or more hidden layers, and an output layer. Each
layer has multiple neurons.

2. Weights: Connections between neurons have weights that adjust as learning proceeds. The
weight increases or decreases the strength of the signal at a connection.

3. Activation Function: Neurons have an activation function that determines whether it should be
activated or not, based on whether the neuron's signal is above a certain threshold.

Applications of ANNs:
• Image and speech recognition

• Natural Language Processing (NLP)

• Game playing and decision making (e.g., AlphaGo)

• Prediction in various domains like stock markets and medicine

Natural Language Processing (NLP):


Natural Language Processing is a field of AI focused on the interaction between computers and humans
through natural language. The ultimate objective of NLP is to read, decipher, understand, and make
sense of human languages in a valuable way.

Subfields and Tasks in NLP:


1. Text Analysis: Understanding, interpreting, and manipulating human language found in text.

2. Machine Translation: Translating text or speech from one language to another.

3. Sentiment Analysis: Determining the emotional tone behind a series of words.

4. Chatbots: Simulating human conversation through AI.

5. Speech Recognition: Translating spoken language into text.


Steps in an NLP Program:
1. Text Collection: Gather the text data to be analyzed.

2. Text Preprocessing: Clean and prepare the data, which might involve tokenization, stemming,
and removal of stop words.

3. Feature Extraction: Convert text into a form understandable by machine learning models, often
using techniques like Bag-of-Words or Word Embeddings.

4. Model Training: Train a machine learning model (like ANNs) to perform a specific NLP task.

5. Evaluation: Test the model's performance with new, unseen text data.

6. Deployment: Implement the NLP system in a real-world application.

Image Processing is a technique to enhance raw images received from cameras/sensors


placed on satellites, spacecraft, aircraft, or pictures taken in normal day-to-day life for various
applications. It involves the manipulation and analysis of visual information and can include
tasks like enhancing image features, removing noise, aligning images, or detecting specific
shapes.

import cv2
import matplotlib.pyplot as plt # Function to convert an image to grayscale
def convert_to_grayscale(image_path):
# Function to load and display an image img = cv2.imread(image_path,
def load_and_display_image(image_path): cv2.IMREAD_GRAYSCALE)
img = cv2.imread(image_path) plt.imshow(img, cmap='gray')
img_rgb = cv2.cvtColor(img, plt.title("Grayscale Image")
cv2.COLOR_BGR2RGB) plt.axis('off')
plt.imshow(img_rgb) plt.show()
plt.title("Original Image")
plt.axis('off') # Function to apply edge detection
plt.show() def edge_detection(image_path):
img = cv2.imread(image_path,
# Function to resize an image cv2.IMREAD_GRAYSCALE)
def resize_image(image_path, scale_percent): edges = cv2.Canny(img, 100, 200)
img = cv2.imread(image_path) plt.imshow(edges, cmap='gray')
width = int(img.shape[1] * scale_percent / plt.title("Edge Detection")
100) plt.axis('off')
height = int(img.shape[0] * scale_percent / plt.show()
100)
resized_img = cv2.resize(img, (width, height)) # Example usage
plt.imshow(resized_img) image_path = 'D:\AI Lab\image.jpg'
plt.title("Resized Image") load_and_display_image(image_path)
plt.axis('off') resize_image(image_path, 50)
plt.show() convert_to_grayscale(image_path)

You might also like