## 2014-11-17

Published on 2014-11-17## Bayes Classifier

Bayes Classifier tries to minimises the probability of misclassification.

### Background Knowlege

#### Bayes' theorem

Bayes' theorem is stated mathematically as the following simple form:

For proposition *A* and evidence or background *B*,

*P*(*A*), the prior probability, is the initial degree of belief in*A*.*P*(*A*|*B*), the conditional probability, is the degree of belief in*A*, having taken*B*into account.- the quotient
*P*(*B*|*A*)/*P*(*B*) represent the support*B*provide for*A*.

Another form of Bayes' Theorem that is generally encountered when looking at two competing statements or hypotheses is:

Because *P*(*B*) = *P*(*B*|*A*)*P*(*A*) + *P*(*B*|¬*A*)*P*(¬*A*), in fact.

#### Chain Rule

In probability theory, the Chain Rule permits the calculation of any member of the *joint distribution* of a set of random variables using only *conditional probabilities*.

Consider an indexed set of sets *A*_{1} to *A** _{n}*, we can apply the definition of conditional probability bo obtain the value of this member of the joint distribution.

For example:

### Problem

We want to estimate *P*(*C*|**F**), in which *C* is a variable stands for a class, and **F** is a vector variable represents values of a set of attributes or features. With Bayes' Theorem, we know

*P*(*C*|**F**) = *P*(**F**|*C*)*P*(*C*)/*P*(**F**)

*P*(*C*=*c*), the probability of*C*for a specific value*c*, is easy to estimate by frequency of*c**P*(**F**=), the probability of*f***F**for a specific value, is a constant in fact, and could be ommited in condition that we consider*f**P*(*C*=*c*|_{i}**F**=) only.*f*

Thus the problem is now to estimate *P*(**F**|*C*).

### Naive Bayes Classifier

In *P*(**F**|*C*), the feature variable **F** consists of a set of features *F** _{i}* with 1 <=

*i*<=

*n*, thus

*P*(

**F**|

*C*) could be rewritten as

*P*(

*F*

*, ...,*

_{1}*F*

*|*

_{n}*C*). Using the Chain Rule for repeated applications of the definition of conditional probability, we get:

*P*(**F**|*C*) = *P*(*F** _{1}*, ...,

*F*

*|*

_{n}*C*) =

*P*(

*F*

*|*

_{1}*C*)

*P*(

*F*

*|*

_{2}*C*,

*F*

*)...*

_{1}*P*(

*F*

*|*

_{n}*C*,

*F*

*, ...,*

_{1}*F*

*)*

_{n-1}**The Naive Assumption**: assume that each feature *F** _{i}* is

**of every other feature**

*conditionally independent**F*

*for*

_{j}*j*≠

*i*, given the category

*C*. Therefore:

*P*(*F*|_{2}*C*,*F*) =_{1}*P*(*F*|_{2}*C*)*P*(*F*|_{3}*C*,*F*,_{1}*F*) =_{2}*P*(*F*|_{3}*C*)- ...
*P*(*F*|_{n}*C*,*F*, ...,_{1}*F*) =_{n-1}*P*(*F*|_{n}*C*)

And

*P*(**F**|*C*) = *P*(*F** _{1}*|

*C*)

*P*(

*F*

*|*

_{2}*C*)...

*P*(

*F*

*|*

_{n}*C*)

Now we get the estimation probability of category *c*. And with the same procedure we could get the estimation of every category, in which the category with maximum estimation will be picked as the classified category.

### Bayesian Network

*Bayesian Network*, also known as *Bayes(ian) Belief Network* or *Belief Network*, is a probabilistic graphical model that represents a set of random variables and their conditional dependencies via a *directed asyclic graph* (DAG). Bayesian Networks work well even if the features are not independent.

Formally, Bayesian networks are DAGs whose

- Nodes represent random variables in the Bayesian sense, e.i., they may be observable quantities, latent variables, unknown parameters or hypotheses.
- Edges reoresent conditional dependencies, thus nodes that are not connected represent variables that are conditionally independent of each other.

In a Bayesian network, each node is associated with a probability function that takes, as input, a particular set of values for the node's parent variables, and gives, as output, the probability of the variable represented by the node. This probability function associated with the node could be represented by a probability table.

- If node
*X*has no parent node, then the probability table consists of prior probability*P*(*X*) only. - If node
*X*has one parent node*Y*, then its probability table also includes conditional probability*P*(*X*|*Y*). - Else, if node
*X*has more parent nodes {*Y*for 1 <=_{i}*i*<=*k*}, then its probability table also includes conditional probability*P*(*X*|*Y*, ...,_{1}*Y*)_{k}

#### Build a Bayesian Network

- Build the network structure: divide the variables into cause variables and outcome variables, and some variables might be both cause variables for ones and outcome variables for others. An expert might be helpful. In applications the task of defining the network is too complex for humans, see Structure Learning.
- Once the structure is built, the probability associated with a node is easy to compute.

#### Properties

- Bayesian Network could handle dependent features.
- Building Bayesian Network is difficult and costing, but once built, it is easy to change.
- Bayesian Network is good at processing incomplete data: the omissive feature of an instance could be substituted by sum of all probable values of the feature.
- Bayesian Network is robust to overfitting.

## Artificial Neural Networks

*Artificial Neural Networks* (ANNs) are computational models inspired by an animal's central nervous systems, and are used to estimate or approximate functions that can depend on a large number of inputs and are generally unknown.

### Perceptron

The perceptron is an algorithm for learning a binary classifier: a function that maps its input ** x** (a real-valued vector) to an output value

*f*(

**) (a single binary value):**

*x*where ** w** is a vector of real-valued weights,

**.**

*w***is the dot product, and**

*x**b*is the 'bias', a constant term that does not depend on any input values.

**Algorithm**

- Initialise the weights
with 0 or random values asw(0).w- For each example
j= {x_{j},y} in training set_{j}D, perform the following steps

- Calculate the actual output:
y^{^}(_{j}k) =f[(wk),x_{j}]- Update the weights: for each weight
w,_{i}w(_{i}k+1) =w(_{i}k) +λ(y-_{j}y^{^}(_{j}k)x)_{ji}- For offline learning, the step 2 may be repeated until the iteration error is less than a user-specified error threshold γ, or a predetermined number of iterations have been completed.

The parameter *λ* is called learning rate.

### ANN

Artificial neural network types vary from those with only one or two layers of single direction logic, to complicated multi-input many directional feedback loops and layers.

For more information about ANN history and approches, see Wikipedia.