Ai and ML Notes
Ai and ML Notes
• Reasoning and problem-solving: AI systems struggle to reason and solve problems in a way
that is similar to human intelligence.
• Computer vision: AI systems struggle to interpret and understand visual data from images
and videos.
• Robotics: AI systems have difficulty interacting with and manipulating physical objects in the
world.
Examples and Applications AI has many examples and applications in various fields, including:
• Virtual assistants: AI-powered virtual assistants, such as Siri and Alexa, can perform tasks
such as answering questions and controlling smart home devices.
• Image recognition: AI-powered image recognition systems can identify objects and people in
images.
• Self-driving cars: AI-powered self-driving cars can navigate roads and avoid obstacles.
• Chatbots: AI-powered chatbots can have conversations with humans and provide customer
support.
Intelligent Behavior Intelligent behavior refers to the ability of an AI system to perform tasks that
would typically require human intelligence. Some examples of intelligent behavior include:
• Reasoning and problem-solving: AI systems can reason and solve problems in a way that is
similar to human intelligence.
• Learning: AI systems can learn from data and improve their performance over time.
• Perception: AI systems can perceive and understand sensory data from the world.
The Turing Test The Turing test is a measure of a machine's ability to exhibit intelligent behavior
equivalent to, or indistinguishable from, that of a human. The test involves a human evaluator
engaging in natural language conversations with both a human and a machine, without knowing
which is which. If the evaluator cannot reliably distinguish the human from the machine, the
machine is said to have passed the Turing test.
Rational versus Non-Rational Reasoning Rational reasoning refers to the use of logical and
systematic methods to arrive at a conclusion. Non-rational reasoning, on the other hand, refers to
the use of intuitive or emotional methods to arrive at a conclusion. AI systems can use both rational
and non-rational reasoning methods to make decisions and solve problems.
Here's a detailed explanation of the nature of environments in AI, categorized into the following
dimensions:
• Examples: Chess, Tic-Tac-Toe, and other board games where all information is visible.
• Examples: Poker, Video Games, and Real-World Applications where not all
information is available.
• Examples: Autonomous Vehicles interacting with other vehicles, Smart Homes with
multiple devices, and Multi-Player Games.
• Examples: Chess, Tic-Tac-Toe, and other board games where the outcome is certain.
• Static Environments: In these environments, the environment remains unchanged over time.
• Examples: Chess, Tic-Tac-Toe, and other board games where the rules and
environment remain constant.
• Dynamic Environments: In these environments, the environment changes over time, either
due to external factors or the actions of the AI system.
• Discrete Environments: In these environments, the state and actions are discrete, meaning
they can only take on specific, distinct values.
• Examples: Chess, Tic-Tac-Toe, and other board games where the moves are discrete.
• Continuous Environments: In these environments, the state and actions are continuous,
meaning they can take on any value within a certain range.
These dimensions are not mutually exclusive, and many environments can be characterized by
multiple dimensions. Understanding the nature of the environment is crucial for designing and
developing effective AI systems.
Would you like me to elaborate on any of these points or explore other aspects of the nature of
environments in AI?
Here's a detailed explanation of the nature of agents in AI, categorized into the following types:
• Autonomous Agents: These agents operate independently, making decisions and taking
actions without human intervention.
• Semi-Autonomous Agents: These agents operate with some level of human oversight or
intervention, often requiring human input or approval for certain decisions or actions.
• Examples: Self-Driving Cars with human override, Autonomous Systems with human
monitoring, and AI-powered decision support systems.
Reflexive Agents:
• Reflexive Agents: These agents react to the environment based on pre-programmed rules or
reflexes, without deliberation or planning.
Goal-Based Agents:
• Goal-Based Agents: These agents operate to achieve specific, well-defined goals, often using
planning and decision-making to achieve those goals.
Utility-Based Agents:
• Utility-Based Agents: These agents operate to maximize a utility function, which represents
the desirability of different outcomes or states.
Hybrid Agents:
• Hybrid Agents: These agents combine different types of agency, such as autonomous and
goal-based, or reflexive and utility-based.
• Examples: Autonomous Vehicles with both navigation goals and route optimization,
AI-powered Personal Assistants with both task-oriented goals and utility-based
decision-making.
Understanding the nature of agents is crucial for designing and developing effective AI systems that
can interact with their environment and achieve their objectives.
Would you like me to elaborate on any of these points or explore other aspects of the nature of
agents in AI?
1. Situation Awareness: Perception allows the AI system to understand its current situation and
environment, enabling it to make informed decisions.
2. Object Recognition: Perception enables the AI system to recognize and identify objects,
people, and other entities in the environment.
3. State Estimation: Perception allows the AI system to estimate the state of the environment,
including the location, velocity, and other properties of objects.
4. Decision-Making: Perception provides the AI system with the necessary information to make
decisions, such as navigating through a crowded space or avoiding obstacles.
1. Action and Effect: Environmental interactions allow the AI system to take actions that affect
the environment, enabling it to achieve its goals.
2. Feedback Loop: Environmental interactions provide the AI system with feedback about the
consequences of its actions, enabling it to learn and adapt.
3. Exploration and Discovery: Environmental interactions enable the AI system to explore and
discover new aspects of the environment, expanding its knowledge and understanding.
Types of Perception:
2. Navigation: Interactions that involve moving through the environment, such as walking or
flying.
1. Sensor Noise and Uncertainty: Perception is often affected by sensor noise and uncertainty,
which can lead to errors and misinterpretation.
3. Limited Action and Effect: The AI system's actions may have limited effect on the
environment, or may be constrained by physical or other limitations.
Future Directions:
1. Multimodal Perception: Developing AI systems that can integrate information from multiple
sensory sources, such as vision, hearing, and touch.
2. Active Perception: Developing AI systems that can actively control their perception, such as
by moving their sensors or adjusting their focus.
3. Human-Robot Interaction: Developing AI systems that can interact with humans in a natural
and intuitive way, such as through gesture recognition or natural language processing.
Basic search is a fundamental problem-solving strategy in artificial intelligence that involves finding a
path from an initial state to a goal state. Here are some key concepts and strategies related to basic
search:
Problem Spaces:
1. States: A set of possible situations or configurations that the problem can be in.
2. Goals: A set of desired states that the problem solver is trying to reach.
3. Operators: A set of actions that can be applied to the current state to produce a new state.
1. Uninformed Search: This strategy involves searching the problem space without any
additional information about the problem.
• Breadth-First Search (BFS): Expands the search tree level by level, exploring all nodes
at the current level before moving to the next level.
• Depth-First Search (DFS): Expands the search tree by exploring as far as possible
along each branch before backtracking.
• Uniform Cost Search (UCS): Expands the search tree by exploring the node with the
lowest cost first.
2. Informed Search: This strategy involves using additional information about the problem to
guide the search.
• Greedy Search: Expands the search tree by selecting the node that is closest to the
goal.
• A* Search: Expands the search tree by selecting the node that has the lowest
estimated total cost (heuristic + cost so far).
• Hill Climbing: Expands the search tree by selecting the node that is most likely to
lead to the goal.
The problem space can be represented using various data structures, such as:
1. Graphs: A graph is a collection of nodes and edges, where each node represents a state and
each edge represents an operator.
3. Matrices: A matrix can be used to represent the problem space, where each cell represents a
state and the values in the cell represent the operators.
Example:
Suppose we want to find the shortest path from a starting city to a destination city using a map. The
problem space can be represented as a graph, where each city is a node and each road is an edge.
The goal is to find the shortest path from the starting city to the destination city.
Uninformed search is a type of search strategy that does not use any additional information about
the problem, such as heuristics or domain knowledge. Instead, it relies solely on the problem's
definition and the search algorithm to find a solution.
Breadth-First Search is a type of uninformed search that explores the search space level by level,
starting from the initial state. It uses a queue data structure to keep track of the nodes to be visited.
3. If the queue is empty and no solution has been found, return failure.
Example:
Suppose we want to find the shortest path from a starting city to a destination city using a map. The
problem space can be represented as a graph, where each city is a node and each road is an edge.
The goal is to find the shortest path from the starting city to the destination city.
Depth-First Search is a type of uninformed search that explores the search space by diving as deep as
possible along each branch before backtracking.
3. If the stack is empty and no solution has been found, return failure.
Example:
Suppose we want to find the shortest path from a starting city to a destination city using a map. The
problem space can be represented as a graph, where each city is a node and each road is an edge.
The goal is to find the shortest path from the starting city to the destination city.
Depth-First Search with Iterative Deepening is a type of uninformed search that combines the
benefits of DFS and BFS. It starts with a small depth limit and increases it iteratively until a solution is
found.
Example:
Suppose we want to find the shortest path from a starting city to a destination city using a map. The
problem space can be represented as a graph, where each city is a node and each road is an edge.
The goal is to find the shortest path from the starting city to the destination city.
Code example:->
Heuristics are used in informed search algorithms to guide the search towards the goal state. A
heuristic is a function that estimates the distance from a given state to the goal state. Informed
search algorithms use heuristics to focus the search on the most promising areas of the search space.
Hill Climbing
Hill Climbing is a type of informed search algorithm that uses a heuristic to guide the search. It starts
with an initial state and applies a series of small changes to the state, evaluating the heuristic at each
step. The algorithm moves to the state with the best heuristic value and repeats the process until a
solution is found or a maximum number of iterations is reached.
3. Generate a set of neighboring states by applying small changes to the current state.
6. Repeat steps 3-5 until a solution is found or a maximum number of iterations is reached.
Generic Best-First Search
Generic Best-First Search is a type of informed search algorithm that uses a heuristic to guide the
search. It maintains a priority queue of states, where the priority of each state is determined by its
heuristic value. The algorithm repeatedly selects the state with the best heuristic value and expands
it, adding its neighbors to the priority queue.
• Select the state with the best heuristic value from the priority queue.
• Expand the selected state, adding its neighbors to the priority queue.
A* is a type of informed search algorithm that uses a heuristic to guide the search. It maintains a
priority queue of states, where the priority of each state is determined by its heuristic value plus the
cost of reaching that state. The algorithm repeatedly selects the state with the best priority value and
expands it, adding its neighbors to the priority queue.
How A* Works:
• Select the state with the best priority value from the priority queue.
• Expand the selected state, adding its neighbors to the priority queue.
The space and time efficiency of search algorithms are crucial factors to consider when
evaluating their performance. Here, we'll discuss the space and time complexity of various
search algorithms.
Time Complexity
Time complexity refers to the amount of time an algorithm takes to complete, usually
measured in terms of the number of operations performed.
• Breadth-First Search (BFS): O(b^d), where b is the branching factor and d is the depth of the
search tree.
• Depth-First Search (DFS): O(b^d), where b is the branching factor and d is the depth of the
search tree.
• Dijkstra's Algorithm: O((V + E)logV), where V is the number of vertices and E is the number
of edges.
• A*: O(b^d), where b is the branching factor and d is the depth of the search tree.
Space Complexity
• Breadth-First Search (BFS): O(b^d), where b is the branching factor and d is the depth of the
search tree.
• Depth-First Search (DFS): O(d), where d is the depth of the search tree.
• Dijkstra's Algorithm: O(V + E), where V is the number of vertices and E is the number of
edges.
• A*: O(b^d), where b is the branching factor and d is the depth of the search tree.
Trade-Offs
There are trade-offs between time and space complexity. For example:
• BFS uses more memory than DFS, but it can be faster for very large graphs.
• A* uses more memory than Dijkstra's Algorithm, but it can be faster for graphs with a large
number of edges.
Optimizations
There are several optimizations that can be used to improve the space and time efficiency of
search algorithms:
• Iterative Deepening: This involves using a combination of BFS and DFS to search the graph.
• Transposition Tables: This involves storing the results of previous searches to avoid
redundant computation.
Two-player games are a type of game where two players, often referred to as MAX and MIN, take
turns making moves. The goal of the game is for one player to win, while the other player tries to
prevent them from winning. Minimax search is a popular algorithm used to play two-player games,
such as chess, checkers, and tic-tac-toe.
Game Tree
A game tree is a tree-like data structure that represents the possible moves and their outcomes in a
two-player game. Each node in the tree represents a game state, and the edges represent the
possible moves from one state to another. The root node represents the initial game state, and the
leaf nodes represent the terminal game states (i.e., the game is over).
Minimax Search
Minimax search is a recursive algorithm that explores the game tree to find the best move for the
MAX player. The algorithm works by:
3. Otherwise, recursively explore the child nodes (i.e., the possible moves).
4. For each child node, evaluate the game state and recursively explore its child nodes.
5. Backtrack and return the best move for the MAX player.
Minimax Algorithm
Example: Tic-Tac-Toe
Genetic algorithms are a type of search algorithm inspired by the process of natural selection. They
work by generating a population of candidate solutions, evaluating their fitness, and selecting the
fittest individuals to reproduce and create a new generation.
Implementation of A* Search
A* search is a popular pathfinding algorithm that uses a heuristic function to guide the search. It
works by maintaining a priority queue of nodes, where the priority of each node is determined by its
estimated total cost (heuristic + cost so far).
Beam Search
Beam search is a type of search algorithm that uses a beam of nodes to explore the search space. It
works by maintaining a fixed-size beam of nodes, where each node represents a possible solution.
The algorithm iteratively expands the beam by adding new nodes and pruning the least promising
ones.
Minimax Search
Minimax search is a type of search algorithm used for playing games like chess, checkers, and tic-tac-
toe. It works by recursively exploring the game tree, evaluating the game state at each node, and
backtracking to find the best move.
Alpha-Beta Pruning
Alpha-beta pruning is a technique used to optimize minimax search by pruning branches of the game
tree that will not affect the final decision. It works by maintaining two values, alpha and beta, which
represent the best possible score for the maximizing player and the best possible score for the
minimizing player, respectively.
Expectimax Search
Expectimax search is a type of search algorithm used for playing games with chance nodes. It works
by recursively exploring the game tree, evaluating the game state at each node, and backtracking to
find the best move. The algorithm takes into account the probability of each chance node and uses
expected values to make decisions.
Chance Nodes
Chance nodes are nodes in the game tree that represent random events or uncertain outcomes.
They are used to model games with elements of chance, such as dice rolls or card draws.
Knowledge representation and reasoning are fundamental concepts in artificial intelligence (AI) that
enable machines to understand and manipulate knowledge. In this section, we will review
propositional and predicate logic, which are essential components of knowledge representation and
reasoning.
Propositional Logic
Propositional logic is a branch of logic that deals with statements that can be either true or false. It is
used to represent knowledge using propositional formulas, which are composed of propositional
variables, logical operators, and parentheses.
Propositional Variables
Propositional variables are symbols that represent statements that can be either true or false. For
example, "It is raining" can be represented by the propositional variable "R".
Logical Operators
Logical operators are used to combine propositional variables to form more complex propositional
formulas. The most common logical operators are:
• OR (∨): Disjunction
Propositional Formulas
Propositional formulas are expressions that are composed of propositional variables, logical
operators, and parentheses. For example, "It is raining and the sky is cloudy" can be represented by
the propositional formula "R ∧ C".
Predicate Logic
Predicate logic is a branch of logic that deals with statements that contain variables and predicates. It
is used to represent knowledge using predicate formulas, which are composed of predicates,
variables, logical operators, and quantifiers.
Predicates
Predicates are symbols that represent relationships between variables. For example, "x is a student"
can be represented by the predicate "S(x)".
Variables
Variables are symbols that represent objects or values. For example, "x" can represent a student.
Quantifiers
Quantifiers are used to specify the scope of variables in predicate formulas. The most common
quantifiers are:
Predicate Formulas
Predicate formulas are expressions that are composed of predicates, variables, logical operators, and
quantifiers. For example, "All students are enrolled in a course" can be represented by the predicate
formula "∀x (S(x) → E(x))".
Knowledge Representation
Knowledge representation is the process of encoding knowledge in a format that can be understood
and manipulated by machines. There are several knowledge representation formalisms, including:
• Frames: A frame is a data structure that represents a concept or object using a set of
attributes and values.
Reasoning
Reasoning is the process of drawing conclusions from knowledge. There are several reasoning
techniques, including:
• Inductive Reasoning: Inductive reasoning is the process of drawing conclusions from specific
instances to general rules.
Inference Engines
Inference engines are software systems that are used to reason about knowledge. They take
knowledge as input and produce conclusions as output. There are several types of inference engines,
including:
• Forward Chaining: Forward chaining is a type of inference engine that starts with a set of
premises and applies logical rules to derive conclusions.
• Backward Chaining: Backward chaining is a type of inference engine that starts with a
conclusion and applies logical rules to derive premises.
Resolution and theorem proving are two important techniques used in artificial intelligence to reason
about knowledge. In this section, we will focus on propositional logic only.
Resolution
Resolution is a technique used to prove the validity of a logical argument. It involves applying a set of
rules to a set of premises to derive a conclusion. The resolution rule is as follows:
• Resolution Rule: If we have two clauses of the form A ∨ B and ¬A ∨ C, we can infer the clause
B ∨ C.
Theorem Proving
Theorem proving is the process of using logical rules to prove the validity of a logical statement. In
propositional logic, theorem proving involves using the resolution rule to derive a conclusion from a
set of premises.
Propositional theorem proving involves using the resolution rule to prove the validity of a
propositional formula. The process involves the following steps:
1. Convert the formula to conjunctive normal form (CNF): The formula must be converted to
CNF, which is a conjunction of clauses, where each clause is a disjunction of literals.
2. Apply the resolution rule: The resolution rule is applied to the clauses to derive new clauses.
3. Repeat the process: The process is repeated until a contradiction is derived or a conclusion is
reached.
Example
Suppose we want to prove the validity of the formula (A ∧ B) → C. We can convert the formula to
CNF as follows:
(A ∨ ¬B ∨ C) ∧ (¬A ∨ C)
We can then apply the resolution rule to derive the following clauses:
1. A ∨ ¬B ∨ C
2. ¬A ∨ C
3. ¬B ∨ C
We can then apply the resolution rule again to derive the following clause:
First Order Logic resolution Review of probabilistic reasoning. Bayes theorem, inference by
enumeration.
First Order Logic Resolution
First order logic (FOL) resolution is a technique used to prove the validity of a logical argument in first
order logic. It involves applying a set of rules to a set of premises to derive a conclusion.
• Resolution Rule: If we have two clauses of the form A ∨ B and ¬A ∨ C, we can infer the clause
B ∨ C.
• Factoring Rule: If we have a clause of the form A ∨ A, we can infer the clause A.
• Paramodulation Rule: If we have two clauses of the form A ∨ B and C ∨ ¬A, we can infer the
clause B ∨ C.
FOL theorem proving involves using the FOL resolution rules to prove the validity of a logical
statement. The process involves the following steps:
1. Convert the formula to clausal form: The formula must be converted to clausal form, which
is a conjunction of clauses, where each clause is a disjunction of literals.
2. Apply the FOL resolution rules: The FOL resolution rules are applied to the clauses to derive
new clauses.
3. Repeat the process: The process is repeated until a contradiction is derived or a conclusion is
reached.
Example
Suppose we want to prove the validity of the formula ∀x (P(x) → Q(x)). We can convert the formula
to clausal form as follows:
¬P(x) ∨ Q(x)
We can then apply the FOL resolution rules to derive the following clauses:
1. ¬P(x) ∨ Q(x)
2. P(x) ∨ ¬Q(x)
We can then apply the FOL resolution rules again to derive the following clause:
Q(x)
Probabilistic Reasoning
Probabilistic reasoning is a technique used to reason about uncertain events. It involves using
probability theory to assign probabilities to events and to reason about the relationships between
events.
Bayes Theorem
Bayes theorem is a fundamental theorem in probability theory that describes the relationship
between the probability of an event and the probability of its causes. It is as follows:
Inference by Enumeration
Example
Suppose we want to reason about the probability of a person having a certain disease given that they
have a certain symptom. We can use Bayes theorem to calculate the probability as follows:
We can then use inference by enumeration to calculate the probability of the disease given the
symptom.
Discrete Probability
Discrete probability deals with events that have a finite number of possible outcomes. For example,
the roll of a die, the toss of a coin, or the draw of a card from a deck.
A random variable is a variable that takes on a value from a set of possible outcomes. A probability
distribution is a function that assigns a probability to each possible outcome of a random variable.
Axioms of Probability
The axioms of probability are a set of rules that define the properties of probability. They are:
3. Additivity: The probability of the union of two mutually exclusive events is equal to the sum
of their individual probabilities.
Bayes' Rule
Bayes' rule is a formula for updating the probability of an event based on new evidence. It is given
by:
where P(A|B) is the probability of event A given event B, P(B|A) is the probability of event B given
event A, P(A) is the prior probability of event A, and P(B) is the prior probability of event B.
Types of Probability Distributions
1. Bernoulli Distribution: A distribution that models the outcome of a single trial with two
possible outcomes.
2. Binomial Distribution: A distribution that models the number of successes in a fixed number
of independent trials.
3. Poisson Distribution: A distribution that models the number of events occurring in a fixed
interval of time or space.
4. Uniform Distribution: A distribution that models a random variable that can take on any
value within a certain range.
5. Normal Distribution: A distribution that models a random variable that is symmetric and
bell-shaped.
Expected Value
The expected value of a random variable is a measure of its central tendency. It is calculated by
summing the product of each possible outcome and its probability.
Variance
Standard Deviation
The standard deviation of a random variable is a measure of its spread or dispersion. It is calculated
by taking the square root of the variance.
Machine learning is a subfield of artificial intelligence that involves the use of algorithms and
statistical models to enable machines to perform a specific task without being explicitly
programmed.
Definition
Machine learning is a type of artificial intelligence that enables machines to learn from data and
improve their performance on a specific task over time.
5. Anomaly Detection: Anomaly detection involves identifying instances that are significantly
different from the rest of the data. Examples include fraud detection, network intrusion
detection, and quality control.
7. Natural Language Processing: Natural language processing involves analyzing and generating
human language. Examples include text classification, sentiment analysis, and language
translation.
8. Computer Vision: Computer vision involves analyzing and understanding visual data from
images and videos. Examples include object detection, image classification, and facial
recognition.
1. Data Collection: Collecting data relevant to the problem you want to solve.
3. Model Selection: Selecting a suitable machine learning algorithm for the problem.
5. Model Evaluation: Evaluating the performance of the model using metrics such as accuracy,
precision, and recall.
3. Decision Trees: A tree-based model that predicts a categorical label or continuous value.
5. Support Vector Machines: A linear or non-linear model that predicts a categorical label or
continuous value.
6. Neural Networks: A non-linear model that predicts a categorical label or continuous value.
Classification is a type of machine learning algorithm that predicts a categorical label or class that an
instance belongs to. Examples include spam vs. not spam emails, cancer vs. not cancer diagnosis, and
product recommendation.
Inductive Learning
Inductive learning is a type of machine learning that involves making generalizations or predictions
based on specific instances or observations. It involves learning from data and making predictions or
decisions based on that data.
Statistical learning with Naive Bayes is a type of machine learning algorithm that uses Bayes' theorem
to make predictions or classify instances. It is a simple and effective algorithm that is widely used in
many applications.
The Naive Bayes algorithm is a type of statistical learning algorithm that uses Bayes' theorem to
make predictions or classify instances. It is based on the following assumptions:
1. Calculate the prior probability: Calculate the prior probability of each class or label.
2. Calculate the likelihood: Calculate the likelihood of each feature or variable given each class
or label.
3. Calculate the posterior probability: Calculate the posterior probability of each class or label
given the features or variables.
Perceptron
A perceptron is a type of artificial neural network that is used for binary classification problems. It is
a single layer neural network that consists of a set of input neurons, a set of output neurons, and a
set of weights that connect the input neurons to the output neurons.
Neural network learning is the process of training a neural network to perform a specific
task. There are two main types of neural network learning:
1. Feed Forward Learning: In feed forward learning, the neural network is trained by passing
the input data through the network and calculating the error between the predicted output
and the actual output. The error is then used to adjust the weights of the network.
2. Back Propagation Learning: In back propagation learning, the neural network is trained by
passing the input data through the network and calculating the error between the predicted
output and the actual output. The error is then used to adjust the weights of the network,
but in a more efficient way than feed forward learning.
A feed forward neural network is a type of neural network where the data flows only in one
direction, from the input layer to the output layer. The network consists of multiple layers of
neurons, each of which receives input from the previous layer and sends output to the next
layer.
A back propagation neural network is a type of neural network that uses the back
propagation algorithm to train the network. The network consists of multiple layers of
neurons, each of which receives input from the previous layer and sends output to the next
layer. The error between the predicted output and the actual output is calculated and used
to adjust the weights of the network.
The perceptron learning rule is a simple algorithm for training a perceptron. The rule is as
follows:
2. Pass the input data through the perceptron and calculate the output.
3. Calculate the error between the predicted output and the actual output.
The back propagation learning rule is a more complex algorithm for training a neural
network. The rule is as follows:
2. Pass the input data through the neural network and calculate the output.
3. Calculate the error between the predicted output and the actual output.
4. Back propagate the error through the neural network, adjusting the weights of each layer
based on the error.
Maximum likelihood estimation (MLE) is a method of estimating the parameters of a statistical model
by finding the values that maximize the likelihood of observing the data. The likelihood function is
defined as the probability of observing the data given the model parameters.
Gradient Descent
Gradient descent is an optimization algorithm used to minimize or maximize a function by iteratively
moving in the direction of the negative gradient of the function. In the context of MLE, gradient
descent is used to find the values of the model parameters that maximize the likelihood function.
Parameter Estimation
Parameter estimation is the process of estimating the values of the parameters of a statistical model
from data. In MLE, the parameters are estimated by finding the values that maximize the likelihood
function.
MLE with gradient descent is a method of estimating the parameters of a statistical model by
maximizing the likelihood function using gradient descent. The algorithm works as follows:
2. Compute the likelihood function and its gradient with respect to the model parameters.
3. Update the model parameters by moving in the direction of the negative gradient of the
likelihood function.
Example
Suppose we have a dataset of exam scores and we want to estimate the mean and standard
deviation of the scores using MLE with gradient descent. The likelihood function is defined as:
where x_i is the i-th exam score, μ is the mean, and σ is the standard deviation.
We can use gradient descent to find the values of μ and σ that maximize the likelihood function. The
gradient of the likelihood function with respect to μ and σ is:
Supervised Learning
Supervised learning is a type of machine learning where the model is trained on labeled data. In
other words, the data used to train the model includes both the input features and the
corresponding output labels. The goal of supervised learning is to learn a mapping between the input
features and the output labels, so that the model can make accurate predictions on new, unseen
data.
Unsupervised learning is a type of machine learning where the model is trained on unlabeled data. In
other words, the data used to train the model only includes the input features, and there are no
corresponding output labels. The goal of unsupervised learning is to learn patterns or structure in
the data, without any prior knowledge of what those patterns might be.
• Dimensionality reduction: reducing the number of input features while preserving the
important information
Reinforcement Learning
Reinforcement learning is a type of machine learning where the model learns to make decisions by
interacting with an environment. In reinforcement learning, the model (also called an "agent") takes
actions in the environment, and receives feedback in the form of rewards or penalties. The goal of
reinforcement learning is to learn a policy that maximizes the cumulative reward over time.
Cross Validation
Cross validation is a technique used to evaluate the performance of a machine learning model by
training and testing it on multiple subsets of the data. The goal of cross validation is to get a more
accurate estimate of the model's performance on unseen data.
• K-Fold Cross Validation: The data is divided into k subsets, and the model is trained on k-1
subsets and tested on the remaining subset. This process is repeated k times, with each
subset being used as the test set once.
• Leave-One-Out Cross Validation: The data is divided into n subsets, where n is the number
of data points. The model is trained on n-1 subsets and tested on the remaining subset. This
process is repeated n times, with each subset being used as the test set once.
There are several metrics that can be used to measure the accuracy of a classifier, including:
• Accuracy: The proportion of correctly classified instances out of all instances in the test set.
• Precision: The proportion of true positives out of all positive predictions made by the
classifier.
• Recall: The proportion of true positives out of all actual positive instances in the test set.
Confusion Matrices
A confusion matrix is a table used to evaluate the performance of a classifier. It shows the number of
true positives, false positives, true negatives, and false negatives.