# Artificial Intelligence Review

see pace

## Search and Games (Ch. 3-4-5)

Problem types:

``````- deterministic (observable): by doing action A, I know what state will be next.
- non-observable: no idea where I am.
- non-deterministic:
- unknown state space: "online" exploration.``````

Problem formulation:

``````- initial state
- actions 'successor functions'
- goal test
- path cost``````

Search strategies: strategy means the order of picking nodes. To evaluate it, check:

``````- completeness:
- time complexity:
- space complexity:
- optimality:

Measurement terms: (b - max branching factor, d - depth of least-cost solution, m - max depth of state space)``````

Search (Uninformed) algorithm:

``````- Depth First:              keep checking the child     of each node until: NULL/VISITED then expand or GOAL then stop
- Breadth First:            keep checking the neighbor  of each node until: NULL/VISITED then expand or GOAL then stop
- Iterative Deepening:      BFS with limited depth(+1) at each iteration (lots of repeated work, but memory efficient) https://www.youtube.com/watch?v=7QcoJjSVT38

- Uniform search "cheapest first":
- keep adding "expanding" a new path (once at a time) to the frontier, as you expand:
- follow the cheapest total path among the available ones in frontier.

- Greedy search algorithm "closer to target":
- keep adding "expanding" a new path (once at a time) to the frontier, as you expand:
- follow the path the looks closer to the goal.

- A* search "cheapest & minimum cost first":
- combine greedy search approach (closer to goal) AND uniform cost (shortest path)
- function: f = g + h
- where:
- g(path) = path cost
- h(path) = estimated distance to path using heuristic function
- SO:
- minimizing g maintains shortest path.
- minimizing h maintains closer to the goal.``````

DFS:

• recursively explore graph, backtracking as necessary. (CAREFULL NOT to REPEAT)

Uniform cost search:

• ... expands the node n with the lowest path cost g(n). This is done by storing the frontier as a priority queue ordered by g.

highlights:

• Tree vs. Graph search: graph search handle the issue of repeated (cycle) states in tree search by recording the visited nodes.

### search algorithms classified:

Uninformed Search:

• DFS: expands the deepest unexpanded node first. Depth-limited search adds a depth bound.
• BFS: expands the shallowest nodes first.
• Uniform cost-search: expands the node with lowest path cost g(n).
• Iterative deepening search: calls depth-first search with increasing depth limits unitl a goal is found.

Informed Search: 'Heuristic'

• Best-first search: selects a node for exapnsion according to evaluation function. Greedy Best-fist search expands nodes with minimal h(n).
• A*: expands nodes with minimal f(n) = g(n) + h(n).
• g(n): distance from starts. g(n): distance to the goal.

Optimization search: 'local search'

• Hill climbing (greedy local search): a loop that continually moves in the direction of increasing vlaue--that is, uphill. Terminates when reaches a "peak" (no neighbor has a higher value than the current one).
• Random restart (a variant of hill climbing to resovle the local maxima problem): conducts a series of hill-climbing searches from randomly generated initial states, until a goal is found.
• Simulated annealing: combine hill climbing with a random walk in a way that yields both efficiency and completeness.

Resrouce:

see A* berkeley

search optimality, Greedy best-first, A*, DPS, and BFS:

udacity

Heuristic search, hill-climbing, evaluation function:

Search practice:

berkeley search quiz

### Games:

Minimax algorithms

alpha-beta algorithm:

## Constraint satisfaction problems (Ch. 6)

Backtracking:

``````Go back to the previous (non-selected) choice when fails with the current one.

i.e. assign VAL1 to VAR1, then VAL2 to VAR2 ... etc fail ?  go back and assign VAL2 to VAR1 then proceed.``````

Forward checking:

``````Keep track of remaining legal values for unassigned variables.
Terminate search when any variable has no legal values.``````

see: pace , berkeley lec4-5

## Logic (Ch. 7-8)

a sentence that is ..

VALID:

• is always true.

SATISFIABLE:

• is true in some model (not necessarily in all model).

UNSATISFIABLE:

• there is no model where it is true.

Propositional Logic

see pace

Inference in PL

see pace

udacity

## Handling uncertainty (Ch. 13-14)

Expected Return:

• E[R] = ∑ Ri · Pi
• where:
• Ri is the return of scenario i
• Pi is the probability of scenario i

Joint probability and uncertainty:

Bayes:

• Posterior = (likelihood * prior) / evidence (marginal)
• P(B | A) = ( P(A | B) * P(B) ) / P(A)
• How?
• P(A, B) ≡ P(A ∩ B)
• P(A ∩ B) = P(A) * P(B) ≡ P(B) * P(A)
• and when A and B joint (conditional):
• P(A ∩ B) = P(A) * P(B | A) ≡ P(B) * P(A | B)
• ∴ P(A) * P(B | A) = P(B) * P(A | B)
• ⇒ P(B | A) = ( P(B) * P(A | B) ) / P(A)

• Where:
• A ≡ (A ∧ B) ∨ (A ∧ ¬ B)
• P(A) = P(A, B) + P(A, ¬ B)
•       = P(A | B) * P(B) + P(A | ¬ B) * P(¬B)
• OR
• P(A) = ∑ P(A | B= i) * P(B= i)
• Total probability / Marginal likelihood

see pace

Bayesian network:

see udacity

coursera

reference and tutorial on Bayesian network in python

Probability:

Other:

A MUST READ: Unifying Logic and Probability: A New Dawn for AI? (Russel) ppt and paper

## Learning (Ch. 18)

Decision Trees

``````Entropy:
H(D) = - SUM [pi * log(pi) ]
Information Gain:
G(D,A) = H(D) - SUM [ Di / D * H(Di)]``````

see: assignment 6

decision trees at udacity

Machine Learning explained simply:

see: udacity

SVM, Kernel Trick, and more

see: udacity

UC Berkeley