AI Imp Topics (Final)
AI Imp Topics (Final)
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.
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.
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.
1. Simple Reflex Agents: These agents act only based on the current percept, ignoring the
rest of the percept history.
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.
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.
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.
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:
Let a be the proposition that patient has stiff neck and b be the proposition that patient has meningitis.
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:
• It is used to calculate the next step of the robot when the already executed step is given.
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.
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.
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')
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
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.
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)