0% found this document useful (0 votes)
37 views171 pages

Compensatory Classes - Additional Optional Classes

Uploaded by

p.bindushreedora
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)
37 views171 pages

Compensatory Classes - Additional Optional Classes

Uploaded by

p.bindushreedora
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/ 171

• Compensatory classes

• Additional optional
classes

1
“Dream, Dream, Dream. Dreams transform into
thoughts and thoughts result in action.”
-APJ Abdul Kalam

2
Why to Study Machine Learning?

[Most of the content in the presentation are borrowed from the slides created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC
Berkeley. All materials available at http://ai.berkeley.edu.]
Character Recognition
Speech Recognition
Fingerprint Based Identity
Disease Diagnosis
Video based Surveillance
Object Recognition
Credit Screening
Natural Language Processing
Applications
 Prediction
 Medical disease
 Price of a stock
 Estimation
 Risk factor of certain disease
 Classification
 Object in a scene
 Recognition
 Handwritten character
13
Artificial Intelligence and Robotics
Medical Robots
Manufacturing Robots
Domestic Robots
Mobile Robots
NAO Robot
Use cases of AI and Robotics in Agriculture
Sophia: The First Robot to Receive Citizenship of a Country
Automation with Generative AI & ChatGPT
How Explainable AI Works
Generative adversarial networks
“the most interesting
idea in the last 10
years in Machine
Learning”

24
AI History
The 7 Areas of AI:
1. Knowledge Representation.
(Understanding Form, shapes etc.. Recognition through partial Information)

2. Understanding Natural Language.


(The spirit is willing, but the flesh is weak 
The vodka is strong, but the meat is rotten)

3. Learning.
(Copying a human by watching and repeating the task).

4. Planning and Problem Solving.


5. Inference.
6. Search.
7. Vision.
Some fundamental questions
 What is intelligence?
 What is thinking?

 What is a machine?
 Is the computer a machine?

 Can a machine think?


 If yes, are we machines?

Ref: NPTEL course Artificial Intelligence Introduction by Prof Deepak Khemani, IIT Madras
Human vs Machine
 Is human a machine HUMAN (~)
 Free will
 Operate on a broad variety  Self-repair
 low energy foods vs highly refined fuels  They reproduce themselves
 Self navigate through complex  Not build or programmed
for specific purpose
environments.
 No design
 They spontaneously organize into  Emotion
collectives for mutual defense  Consciousness
 Ethics
 They communicate
 Generalizability
 They invent, they problem-solve, they
share solutions to common challenges.
 No human operator/controller
The debate over Thinking Machines
 Herbert Dreyfus: “Intelligence depends upon unconscious
instincts that can never be captured in formal rules”
https://en.wikipedia.org/wiki/Hubert_Dreyfus%27s_views_on_artificial_intelligence

 Roger Penrose: “.. There is something (quantum mechanical)


going on in our brains that current physics cannot explain”

Ref: NPTEL course Artificial Intelligence Introduction by Prof Deepak Khemani, IIT Madras
Intelligence and machine
 Intelligence: the ability to acquire and apply knowledge and
skills.[Dictionary definition]

 Machine: an apparatus using mechanical power and having


several parts, each with a definite function and together
performing a particular task. [Dictionary definition]
Some definitions
 Herbert Simon: We call programs intelligent if they exhibit behaviours that would be
regarded intelligent if they were exhibited by human beings
 Avron Barr and Edward Feigenbaum: Physicists ask what kind of place this universe is
and seek to characterize its behaviour systematically. Biologists ask what it means for
a physical system to be living. We in AI wonder what kind of information-processing
system can ask such questions.
 Elaine Rich: AI is the study of techniques for solving exponentially hard problem in
polynomial time by exploiting knowledge about the problem domain.
 Eugen Charniak and Drew McDermott: AI is the study of mental faculties through the
use of computational models.

 “The idea that thinking and computing are radically the same” John Haugeland in “AI:
The vary Idea”
Ref: NPTEL course Artificial Intelligence Introduction by Prof Deepak Khemani, IIT Madras
Defining AI

The simulation of human intelligence on a machine, so as to


make the machine efficient to identify and use the right piece of
“Knowledge” at a given step of solving a problem.
What is AI?
The science of making machines that:

Think like people Think rationally


• Allen Newell and Herbert • Aristotle: right thinking
Simon (1961): General • difficult to encode how
Problem Solver to think
• cognitive science,
neuroscience

Act like people Act rationally


• Alan Turing (1950) In the end it’s not about
• Don’t answer too quickly how you think, it’s about
• Not intelligent how you end up acting
Rational Decisions
We’ll use the term rational in a very specific, technical way:
 Rational: maximally achieving pre-defined goals
 Rationality only concerns what decisions are made
(not the thought process behind them)
 Goals are expressed in terms of the utility of outcomes
 Being rational means maximizing your expected utility

Computational Rationality
A (Short) History of AI
 1940-1950: Early days
 1943: McCulloch & Pitts: Boolean circuit model of brain
 1950: Turing's “Computing Machinery and Intelligence”
 1950—70: Excitement: Look, Ma, no hands!
 1950s: Early AI programs, including Samuel's checkers
program, Newell & Simon's Logic Theorist, Gelernter's
Geometry Engine
 1956: Dartmouth meeting: “Artificial Intelligence” adopted
 1958: John McCarthy LISP, Program with common sense
 1962: Frank Rosenblatt- perceptron’s convergence theorm
 1964: Eliza- Chatbot created at MIT AI Lab
 1965: Robinson's complete algorithm for logical reasoning
 Failure:
 Most early programs knew nothing of their subject matter
 Intractactability of many of the problems
 Basic structures being used to generate intelligent behaviour
A (Short) History of AI
 1970—90: Knowledge-based approaches
 1969—79: Early development of knowledge-based systems
 DENDRAL(Buchanan et. al. 1969): inferring molecular structure
 MYCIN(Feigenbaum et al. 1971): diagnose blood infection
 SHRDLU(Winograd): understanding natural language

 1980—88: Expert systems industry booms


 First successful commercial expert system, R1 (McDermott, 1982)

 1988—93: Expert systems industry busts: “AI Winter”


 1990—: Statistical approaches
 Resurgence of probability, focus on uncertainty
 General increase in technical depth
 Agents and learning systems… “AI Spring”?

 2000—: Where are we now?


What Can AI Do?
Quiz: Which of the following can be done at present?

 Play a decent game of table tennis?


 Play a decent game of Jeopardy?
 Drive safely along a curving mountain road?
 Drive safely along Telegraph Avenue?
 Buy a week's worth of groceries on the web?
 Buy a week's worth of groceries at Berkeley Bowl?
 Discover and prove a new mathematical theorem?
 Converse successfully with another person for an hour?
 Perform a surgical operation?
 Put away the dishes and fold the laundry?
 Translate spoken Chinese into spoken English in real time?
 Write an intentionally funny story?

Image
Imageref: https://www.gpsmycity.com/tours/telegraph-avenue-shopping-in-berkeley-
Ref: https://www.flickr.com/photos/dalaimages/4980104346
5276.html
Branches of AI

Ref: https://medium.com/@chethankumargn/artificial-intelligence-definition-types-examples-technologies-962ea75c7b9b
Natural Language
 Speech technologies (e.g. Siri)
 Automatic speech recognition (ASR)
 Text-to-speech synthesis (TTS)
 Dialog systems

Demo: NLP – ASR tvsample.avi


Natural Language
 Speech technologies (e.g. Siri)
 Automatic speech recognition (ASR)
 Text-to-speech synthesis (TTS)
 Dialog systems

 Language processing technologies


 Question answering
 Machine translation

 Web search
 Text classification, spam filtering, etc…
Vision (Perception)
 Object and face recognition
 Scene segmentation
 Image classification

Demo1: VISION – lec_1_t2_video.flv


Images from Erik Sudderth (left), wikipedia (right)
Demo2: VISION – lec_1_obj_rec_0.mpg
Robotics
 Robotics
 Part mech. eng.
 Part AI
 Reality much
harder than
simulations!

 Technologies
 Vehicles
 Rescue
 Soccer!
 Lots of automation…

Images from UC Berkeley, Boston Dynamics, RoboCup, Google


Logic

 Logical systems
 Theorem provers
 NASA fault diagnosis
 Question answering

 Methods:
 Deduction systems
 Constraint satisfaction
 Satisfiability solvers (huge advances!)

Image from Bart Selman


Game Playing
 1968: David Levy
 Chess program can not beat him for next 10 years
 1996: Gary Kasparov Beats Deep Blue (1L , 3 W, 2 D)
“I could feel --- I could smell --- a new kind of intelligence across the table.”
 1997: Deep Blue Beats Kasparov (3.5-2.5)
“Deep Blue hasn't proven anything.”
 First match won against world champion
 “Intelligent creative” play
 200 million board positions per second
 Deep Blue employed custom VLSI chips to
execute the alpha-beta search algorithm in parallel

 Huge game-playing advances recently, e.g. in Go!

 “Love and Sex with Robots” book by David Levy (2007)


 In 2008, now he talks about robot companions

Text from Bart Selman, image from IBM’s Deep Blue pages
Decision Making
 Applied AI involves many kinds of automation
 Scheduling, e.g. airline routing, military
 Route planning, e.g. Google maps
 Medical diagnosis
 Web search engines
 Spam classifiers
 Automated help desks
 Fraud detection
 Product recommendations
 … Lots more!
Recent AI news (Only few)
 The Ministry of Commerce and Industry has set up the Task force on Artificial Intelligence to kick-
start the use of AI for India's economic transformation. https://www.aitf.org.in/

 Microsoft has announced a $1 billion investment in OpenAI as part of a shared ambition to


achieve the holy grail of artificial general intelligence (AGI). https://artificialintelligence-
news.com/2019/07/22/microsoft-openai-artificial-general-intelligence/

 DABUS, a machine architecture, has been given credit for designing a ‘fractal container’
(pdf) which is easy for robots to grasp, as well as a ‘neural flame’ (pdf) which attracts enhanced
attention.

 Elon Musk’s ambitious Neuralink project to link human brains with machines is part of the
entrepreneur’s crusade to “stop the AI apocalypse”. https://artificialintelligence-
news.com/2019/07/18/musk-link-human-brains-machines-stop-ai-apocalypse/
Source of references: https://artificialintelligence-news.com/
Main events in the history of AI

Period Key Events

The birth of Artificial McCulloch and Pitts, A Logical Calculus of the Ideas
Intelligence Immanent in Nervous Activity, 1943
(1943–1956) Turing, Computing Machinery and Intelligence, 1950
The Electronic Numerical Integrator and Calculator
project (von Neumann)
Shannon, Programming a Computer for Playing Chess,
1950
The Dartmouth College summer workshop on machine
intelligence, artificial neural nets and automata theory,
1956
Main events in the history of AI

Period Key Events

The rise of artificial LISP (McCarthy)


intelligence The General Problem Solver (GPR) project (Newell and
(1956–late 1960s) Simon)
Newell and Simon, Human Problem Solving, 1972
Minsky, A Framework for Representing Knowledge, 1975

The disillusionment Cook, The Complexity of Theorem Proving Procedures,


in artificial 1971
intelligence (late Karp, Reducibility Among Combinatorial Problems, 1972
1960s–early 1970s)
The Lighthill Report, 1971
Main events in the history of AI

Period Key Events

The discovery of DENDRAL (Feigenbaum, Buchanan and Lederberg,


expert systems (early Stanford University)
1970s–mid-1980s) MYCIN (Feigenbaum and Shortliffe, Stanford University)
PROSPECTOR (Stanford Research Institute)
PROLOG - a logic programming language (Colmerauer,
Roussel and Kowalski, France)
EMYCIN (Stanford University)
Waterman, A Guide to Expert Systems, 1986
Main events in the history of AI

Period Key Events

The rebirth of Hopfield, Neural Networks and Physical Systems with


artificial neural Emergent Collective Computational Abilities, 1982
networks Kohonen, Self-Organized Formation of Topologically
(1965–onwards) Correct Feature Maps, 1982
Rumelhart and McClelland, Parallel Distributed
Processing, 1986
The First IEEE International Conference on Neural
Networks, 1987
Haykin, Neural Networks, 1994
Neural Network, MATLAB Application Toolbox (The
MathWork, Inc.)
Main events in the history of AI

Period Key Events

Evolutionary Rechenberg, Evolutionsstrategien - Optimierung


computation (early Technischer Systeme Nach Prinzipien der Biologischen
1970s–onwards) Information, 1973
Holland, Adaptation in Natural and Artificial Systems,
1975.
Koza, Genetic Programming: On the Programming of the
Computers by Means of Natural Selection, 1992.
Schwefel, Evolution and Optimum Seeking, 1995
Fogel, Evolutionary Computation –Towards a New
Philosophy of Machine Intelligence, 1995.
Main events in the history of AI
Period Key Events

Computing with Zadeh, Fuzzy Sets, 1965


Words Zadeh, Fuzzy Algorithms, 1969
(late 1980s–onwards)
Mamdani, Application of Fuzzy Logic to Approximate
Reasoning Using Linguistic Synthesis, 1977
Sugeno, Fuzzy Theory, 1983
Japanese “fuzzy” consumer products (dishwashers,
washing machines, air conditioners, television sets,
copiers)
Sendai Subway System (Hitachi, Japan), 1986
The First IEEE International Conference on Fuzzy
Systems, 1992
Kosko, Neural Networks and Fuzzy Systems, 1992
Kosko, Fuzzy Thinking, 1993
Cox, The Fuzzy Systems Handbook, 1994
Zadeh, Computing with Words - A Paradigm Shift, 1996
Fuzzy Logic, MATLAB Application Toolbox (The
MathWork, Inc.)
Machine Learning
 What the data sayslearning from Data
 Data: Labelled/ Unlabelled
 Sophisticated algorithms run in the machine learn the data
statistics Machine Learning

 Used when:
 Human expertise does not exist (navigating on Mars)
 Humans are unable to explain their expertise (speech recognition)
 Mimicking like human intelligence (unmanned system)
54
What is Machine Learning?

 Machine learning is programming computers to optimize a


performance criterion using example data or past experience.

 Optimize a performance criterion using example data or past


experience.
 Role of Statistics: Inference from a sample
 Role of Computer science: Efficient algorithms to
 Solve the optimization problem
 Representing and evaluating the model for inference
An Example
Fish packing plant wants to automate the process ofsorting
incoming fish on a conveyor belt according to species.
 Model
 Pre-processing
 Segmentation
 Feature extraction
 Training
 Cost Function

56
Training Set

Data+ Model
Pre-
Processing
Task
Feature f

Cost
Function
Sub-problems
 Feature Extraction
 Noise
 Model Selection
 Model Fitting
 Prior Knowledge
 Missing Features
 Segmentation
 Context
 Invariances
 Evidence Pooling
 Costs and Risks
 Computational Complexity

58
Learning and Adaptation
 Supervised Learning
 Unsupervised Learning
 Reinforcement Learning

59
Supervised Learning
 Supervision: The data (observations, measurements, etc.) are
labeled with pre-defined classes.
 Regression, Classification
 It is like that a “teacher” gives the classes (supervision).

Fei-Fei, Deng, Su, & Li, VSS, 2009

60
Unsupervised Learning
 Unsupervision: The goal is to describe the associations and
patterns among a set of input measures
 Clustering

Learning Algorithm

Classification VS Clustering

61
Reinforcement Learning
 Reinforcement: ‘Reward’/ ‘Penalty’ feedback to categorize data.
In reinforced learning, learning is based on a reward that
reinforces it is ‘correct’ or a penalty that reinforces it is ‘wrong’.

62
A Few Learning techniques
 Unsupervised
 Clustering

 Supervised
 Regression
 Classification

63
Clustering: Unsupervised Learning

 The goal is to describe the associations and patterns among a


set of input measures

Patterns/Feature

Learning Algorithm

64
Training Set

Data+ Model
Pre-
Processing
Task
Feature f

Cost
Function
Model
 Model does not generalize to unseen data
 Fail to predict things that are not in training sample
 Pick a model that has lower generalization error
 How to evaluate generalization error?
 Split your data into train, validation, and test set.
 Use test set error as an estimator of generalization error

66
Model Selection
 Procedure:

 Step 1. Train on training set


 Step 2. Evaluate validation error
 Step 3. Pick the best model based on Step 2.
 Step 4. Evaluate the test error

67
Best Model : Bias/Variance Trade-off?

Y
Y

Y
X X X
Underfit Just right Overfit
High bias High Variance
Too simple Too Complex

68
Low Variance High Variance
High Bias
Low Bias

69
Bias-Variance Trade Off Is Revealed Via Test Set Not
Training Set

MSEtest

MSEtrain
Artificial Intelligence
Search

[Most of the content in the presentation are borrowed from the slides created by Dan Klein and Pieter Abbeel for CS188
Intro to AI at UC Berkeley. All materials available at http://ai.berkeley.edu.]
Agent and Environment
 An agent is an entity that perceives its environment through
sensors and acting upon that environment through actuators.

Environment
Agent Sensors Percepts

?
Actions
Actuators

 Agent= Architecture + program


Designing Rational Agents
 Rational Agent: that does the right thing
 A rational agent selects actions that maximize
its (expected) utility (not actual performance).
 Specifying the task environment (PEAS)
 Performance metric
 Environment
 Actuators
 Sensors

Auto Driving Car

Img Ref: https://corporate-innovation.co/tag/innovation/


Examples of agent types and their PEAS descriptions
Properties of task environments
 Fully observable vs. partially observable:
 A task environment is effectively fully observable if the sensors detect all aspects
that are relevant to the choice of action

 Single agent vs. multiagent:


 competitive vs cooperative multiagent

 Deterministic vs. stochastic.


 If the next state of the environment is completely determined by the current state
and the action executed by the agent then the environment is deterministic

 Episodic vs. sequential:


 In an episodic task environment, the agent’s experience is divided into atomic
episodes and the action in the current episode does not depend on the actions
taken in previous episodes
Properties of task environments
 Static vs. dynamic:
 Environment can change while an agent is deliberating

 Discrete vs. continuous:


 The chess environment has a finite number of distinct states
 Taxi driving is a continuous-state

 Known vs. unknown:


 In a known environment, the outcomes (or outcome probabilities if the
environment is stochastic) for all actions are given
 Known but partially observable environment — in solitaire card games, I know the rules but am
still unable to see the cards that have not yet been turned over.
 Unknown but fully observable environment—in a new video game, the screen may show the
entire game state but I still don’t know what the buttons do until I try them.
Examples of task environments and their characteristics
Types of agent program
 Agent Plan/Program
 Difficult to have a mapping for all possible
percept sequence to action

 Simple Reflex Agent


 Planning agent
 Model-based reflex agent
 Goal-based agent
 Utility-based agent
Simple Reflex Agents
 Reflex agents:
 Choose action based on current percept (and
maybe memory)
 May have memory or a model of the world’s
current state
 Do not consider the future consequences of
their actions
 Consider how the world IS

 Can a reflex agent be rational?


Planning Agents

 Planning agents:
 Ask “what if”
 Decisions based on (hypothesized)
consequences of actions
 Must have a model of how the world evolves in
response to actions (Model based agent)
 Must formulate a goal (Goal based agent)
 Consider how the world WOULD BE

 Complete vs. Optimal (Utility based agent)


planning

 Planning vs. replanning


Model based agent
 keep track of the part of the world it can’t see now.
 Knowledge about “How the world works (Agent, Environment)” is
called a model of the wolrd
 An agent that uses such a model
is called a model based agent
Goal-based agent
 As well as a current state description, the GOAL agent needs
some sort of goal information that describes situations that are
desirable
 “What will happen if I do such-and-such?” i.e. future information
Utility based agent
 Goals alone are not enough to generate high-quality behavior in
most environments. For example, many action sequences will get
the taxi to its destination (thereby achieving the goal) but some
are quicker, safer, more reliable, or cheaper than others
Pac-Man as an Agent

Agent Environment
Sensors Percepts
?
Actuators Actions

Pac-Man is a registered trademark of Namco-Bandai Games, used here for educational purposes
Search Problems
Search Problems Are Models
Search Problems
 A search problem consists of:

 A state(environment) space

 Possible actions
“N”,
 A successor function 1.0
(Mapping of state to action
with costs) “E”, 1.0

 A start state and a goal test

 A solution is a sequence of actions (a plan) which transforms


the start state to a goal state
Vacuum Cleaner Problem
The 8-puzzle

states?
 No of unique locations of tiles (9! )
actions?
 move blank left, right, up, down
goal test? = goal state (given)
path cost? 1 per move

[Note: optimal solution of n-Puzzle family is NP-hard]


The 8-puzzle

states?
 No of unique locations of tiles (9! is the total number of possible configurations of the puzzle,
whereas 9!/2 (181440) is the total number of solvable configurations. 8-puzzle has a property that exactly
half (of all) permutations can be reached from any starting state.)
actions?
 move blank left, right, up, down
goal test? = goal state (given)
path cost? 1 per move
Example: 8-queens problem
 The goal of the 8-queens problem is to place
eight queens on a chessboard such that no queen
attacks any other
 States: Any arrangement of 0 to 8 queens on the board is a state.
 Initial state: No queens on the board.
 Actions: Add a queen to any empty square.
 Transition model: Returns the board with a queen added to the
specified square.
 Goal test: 8 queens are on the board, none attacked. In this
formulation, we have 64 · 63 ··· 57 ≈ 1.8×10^14 possible
sequences to investigate.
Example: Pacman game

 World state:
 Agent positions: 120
 Food count: 30
 Ghost positions: 12
 Agent facing: NSEW

 How many
 World states?
120x(230)x(122)x4
 States for pathing?
120
 States for eat-all-dots?
120x(230)
State Space Graphs and Search Trees
State Space Graphs

 State space graph: A mathematical


representation of a search problem
 Nodes are (abstracted) world configurations
 Arcs represent successors (action results)
 The goal test is a set of goal nodes (maybe only one)

 In a state space graph, each state occurs only


once!

 We can rarely build this full graph in memory


(it’s too big), but it’s a useful idea
State Space Graphs

 State space graph: A mathematical


representation of a search problem a G
 Nodes are (abstracted) world configurations b c
 Arcs represent successors (action results) e
 The goal test is a set of goal nodes (maybe only one) d f
S h
 In a search graph, each state occurs only once! p r
q

 We can rarely build this full graph in memory


Tiny search graph for a
(it’s too big), but it’s a useful idea
tiny search problem
Search Trees
This is now / start

“N”, 1.0 “E”,


1.0 Possible futures

 A search tree:
 A “what if” tree of plans and their outcomes
 The start state is the root node
 Children correspond to successors
 Nodes show states, but correspond to PLANS that achieve those states
 For most problems, we can never actually build the whole tree
State Space Graphs vs. Search Trees

State Space Graph Each NODE in


in the search Search Tree
tree is an S

a G entire PATH in d e p
b c the state b c e h r q
d
e
f
space graph. h r p q f
a a
S h We construct
p q f q c G
p r
q both on a
q c G
demand – and
a
we construct
as little as
possible.
Problem Solving by Searching

Problem Formulation
Problem Formulation

A Problem Space consists of

 The current state of the world (initial state)

 A description of the actions we can take to transform one state of the world into another
(operators).

 A description of the desired state of the world (goal state), this could be implicit or explicit.

 A solution consists of the goal state, or a path to the goal state.

101
Problem Formulation
8-Puzzle Problem

Initial State Operators Goal State

2 1 3 Slide blank square left.


1 2 3
4 7 6 Slide blank square right. 4 5 6
….
5 8 7 8

102
Problem Formulation
8-Puzzle Problem

Representing states:

 For the 8-puzzle

 3 by 3 array 5 6 7
 5, 6, 7
 8, 4, BLANK 8 4
 3, 1, 2
3 1 2
 A vector of length nine
 5,6,7,8,4, BLANK,3,1,2

 A list of facts
 Upper_left = 5
 Upper_middle = 6
 Upper_right = 7
 Middle_left = 8
103
Problem Formulation
8-Puzzle Problem

Specifying operators:

There are often many ways to specify the operators, some will be much easier to implement...

• Move 1 left
• Move 1 right
• Move 1 up
• Move 1 down • Move Blank left
• Move 2 left • Move Blank right
• Move 2 right 5 6 7
• Move Blank up
• Move 2 up • Move Blank down 8 4
• Move 2 down
• Move 3 left 3 1 2
• Move 3 right
• Move 3 up
• Move 3 down 104
• Move 4 left
Problem Formulation
8-Puzzle Problem

1 2 3 1 2 3
4 8 4 5 6
7 6 5 7 8

Initial state Goal state

Operators: slide blank up, slide blank down, slide blank left, slide blank right

1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3
4 8 4 8 5 4 8 5 4 5 4 5 4 5 6
7 6 5 7 6 7 6 7 8 6 7 8 6 7 8

Solution: sb-down, sb-left, sb-up,sb-right, sb-down


Path cost: 5 steps to reach the goal 105
Missionaries and cannibals

 Three missionaries and three cannibals are on the left bank of a river.

 There is one canoe which can hold one or two people.

 Find a way to get everyone to the right bank, without ever leaving a group of
missionaries in one place outnumbered by cannibals in that place.
Missionaries and Cannibals

Initial State

107
Missionaries and Cannibals

Goal State

108
Problem Solving by Searching

A toy problem:
Missionaries and Cannibals
Missionaries and cannibals

 Three missionaries and three cannibals are on the left bank of a river.

 There is one canoe which can hold one or two people.

 Find a way to get everyone to the right bank, without ever leaving a group of
missionaries in one place outnumbered by cannibals in that place.

110
Missionaries and cannibals

 States: three numbers (i,j,k) representing the number of missionaries,


cannibals, and canoes on the left bank of the river.
 Initial state: (3, 3, 1)
 Operators: take one missionary, one cannibal, two missionaries, two cannibals,
one missionary and one cannibal across the river in a given direction (I.e. ten
operators).
 Goal Test: reached state (0, 0, 0)
 Path Cost: Number of crossings.

111
(3,3,1): Initial State

112
A missionary and cannibal cross

113
(2,2,0)

114
One missionary returns

115
(3,2,1)

116
Two cannibals cross

117
(3,0,0)

118
A cannibal returns

119
(3,1,1)

120
Two missionaries cross

121
(1,1,0)

122
A missionary and cannibal return

123
(2,2,1)

124
Two Missionaries cross

125
(0,2,0)

126
A cannibal returns

127
(0,3,1)

128
Two cannibals cross

129
(0,1,0)

130
A cannibal returns

131
(0,2,1)

132
The last two cannibals cross

133
(0,0,0) : Goal State

134
Solution = the sequence of actions within the path : [
(3,3,1)→ (2,2,0)→(3,2,1) →(3,0,0) →(3,1,1) →(1,1,0) →(2,2,1) →(0,2,0)
→(0,3,1) →(0,1,0) → (0,2,1) →(0,0,0)]; Cost = 11 crossings

135
Tower of Hanoi
 There are three towers
 64 gold disks, with decreasing sizes, placed on the first tower
 You need to move all of the disks from the first tower to the last tower
 Larger disks can not be placed on top of smaller disks
 The third tower can be used to temporarily hold disks
Tower of Hanoi
 The disks must be moved within one week. Assume one disk can
be moved in 1 second. Is this possible?

 To create an algorithm to solve this problem, it is convenient to


generalize the problem to the “N-disk” problem, where in our
case N = 64.

The minimal number of moves required to solve a Tower of


Hanoi puzzle?
Recursive Solution
Recursive Solution
Recursive Solution
Recursive Solution
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Tower of Hanoi
Water Jug Problem

Given a full 5-gallon jug and an empty 2-gallon jug, the goal is to fill the 2-gallon jug with exactly one
gallon of water.

 Possible actions:
 Empty the 5-gallon jug (pour contents down the drain)
 Empty the 2-gallon jug
 Pour the contents of the 2-gallon jug into the 5-gallon jug (only if there is enough room)
 Fill the 2-gallon jug from the 5-gallon jug
 Case 1: at least 2 gallons in the 5-gallon jug
 Case 2: less than 2 gallons in the 5-gallon jug
Monkey & Bananas
 A hungry monkey is in a room. Suspended from the roof, just out of his reach, is a bunch of bananas. In
the corner of the room is a box. The monkey desperately wants the bananas but he can’t reach them.
What shall he do?
Summary
 Search: process of constructing sequences of actions that achieve a goal given a
problem.
 Goal formulation is the first step in solving problems by searching. It facilitates problem
formulation.
 Formulating a problem requires specifying five components: State representation,
Initial state, Goal state, Operators (actions), and Path cost function.

152
Quiz: State Space Graphs vs. Search Trees

Consider this 4-state graph: How big is its search tree (from S)?

S G

Important: Lots of repeated structure in the search tree!


 Graph
 Traverse a state once
 Easy to identify loop
 Goal state when available

 Tree
 Traverse states multiple times in multiple paths
 Loop identification is difficult
Tree Search
Searching with a Search Tree

 Search:
 Expand out potential plans (tree nodes)
 Maintain a fringe of partial plans under consideration
 Try to expand as few tree nodes as possible
General Tree Search

 Important ideas:
 Fringe: The set of all nodes at the end of all visited paths is
called the fringe, frontier or border.
 Expansion
 Exploration strategy

 Main question: which fringe nodes to explore?


Search Algorithm Properties
 Complete: Guaranteed to find a solution if one exists?
 Optimal: Guaranteed to find the least cost path?
 Time complexity?
 Space complexity? b 1 node
… b
 Cartoon of search tree: nodes
b2
 b is the branching factor m tiers nodes
 m is the maximum depth
 solutions at various depths
bm nodes
 Number of nodes in entire tree?
 1 + b + b2 + …. bm = O(bm)
Depth-First Search
Depth-First Search
Strategy: expand a G
b c
a deepest node
e
first d f
S h
Implementation: p q r

Fringe is a LIFO
stack S

d e p
b c e h r q
a a h r p q f
p q f q c G

q c G a
a
Depth-First Search (DFS) Properties
 What nodes DFS expand?
 Some left prefix of the tree. 1
 Could process the whole tree! b
… b
node
 If m is finite, takes time O(bm) nodes
b2
 How much space does the fringe take? m tiers nodes
 Only has siblings on path to root, so O(bm)

 Is it complete? bm
 m could be infinite, so only if we prevent nodes
cycles (more later)

 Is it optimal?
 No, it finds the “leftmost” solution,
regardless of depth or cost
Breadth-First Search
Breadth-First Search
Strategy: expand a G
b c
a shallowest
d e
node first f
S h
Implementation: p q r
Fringe is a FIFO
queue S

d e p
Sear q
b c e h r
ch
a a h r p q f
Tiers
p q f q c G

q c G a
a
Breadth-First Search (BFS) Properties
 What nodes does BFS expand?
 Processes all nodes above shallowest solution 1 node
b
 Let depth of shallowest solution be s … b
 Search takes time O(bs) s tiers nodes
b2
nodes
 How much space does the fringe take? bs nodes
 Has roughly the last tier, so O(bs)

 Is it complete? bm nodes
 s must be finite if a solution exists, so yes!

 Is it optimal?
 Only if costs are all 1 (more on costs later)
Quiz: DFS vs BFS
Quiz: DFS vs BFS

 When will BFS outperform DFS?

 When will DFS outperform BFS?


Evaluating Model Performance: Train,
Validation, and Test Sets
To evaluate a machine learning model's performance accurately, it is essential to split the dataset into training, validation, and test
sets. This ensures that the model is trained on one set of data, its performance is evaluated on a separate validation set, and its
final performance is measured on an unseen test set.

Training Set Validation Set Test Set

Used to train the model. Used to tune hyperparameters and Used to assess the final performance
select the best model. of the selected model on unseen
data.
Cross-validation

• K-fold cross-validation avoids overlapping test sets


• First step: split data into k subsets of equal size
• Second step: use each subset in turn for testing, the remainder for training
• This means the learning algorithm is applied to k different training sets
• The error estimates are averaged to yield an overall error estimate; also,
standard deviation is often computed
• Alternatively, predictions and actual target values from the k folds are pooled to
compute one estimate
• Does not yield an estimate of standard deviation

You might also like