Computational Intelligence: Methods and Applications

18
Computational Intelligence: Computational Intelligence: Methods and Applications Methods and Applications Lecture 13 Bayesian risks & Naive Bayes approach Włodzisław Duch Dept. of Informatics, UMK Google: W Duch

description

Computational Intelligence: Methods and Applications. Lecture 13 Bayesian risks & N aive Bayes approach Włodzisław Duch Dept. of Informatics, UMK Google: W Duch. Bayesian future. - PowerPoint PPT Presentation

Transcript of Computational Intelligence: Methods and Applications

Page 1: Computational Intelligence:  Methods and Applications

Computational Intelligence: Computational Intelligence: Methods and ApplicationsMethods and Applications

Lecture 13

Bayesian risks & Naive Bayes approach

Włodzisław Duch

Dept. of Informatics, UMK

Google: W Duch

Page 2: Computational Intelligence:  Methods and Applications

Bayesian futureBayesian futureBayesian futureBayesian futureThe February 2004 issue of MIT Technology magazine showcases Bayesian Machine Learning as one of the 10 emerging technologies that will change your world!

Intel wants computers to be more proactive, learn from their experiences with users and the world around them.

Intel Open Source Machine Learning library OpenML, and Audio-Visual Speech Recognition .

Now are part of: Open Source Computer Vision Library http://sourceforge.net/projects/opencvlibrary

http://opencvlibrary.sourceforge.net/

Page 3: Computational Intelligence:  Methods and Applications

Total risksTotal risksTotal risksTotal risksConfusion matrix:

Total risk of the decision procedure Ĉ:

1

1 1 1

ˆ ˆ ,K K K

k k k kl klk k l

R C P R C P P

If all Pkl=0 for k≠l the risk is zero (assuming ii =0).

Minimizing risk means that we try to find decision procedure Ĉ that minimizes “important” errors. For example, if classes k, k=1,..10, are degrees of severity of heart problems, than mixing 12 < 19

11 12 1 1 1

21 22 2 2 1

1 2 1

...

...ˆ( ) | ( )... ... ... ... ...

...

K K

K Kk l

K K KK KK

P P P P

P P P PP C C

P P P P

X X P

Page 4: Computational Intelligence:  Methods and Applications

Bayesian riskBayesian riskBayesian riskBayesian riskSelect the class corresponding to minimum conditional risk:

This is equivalent to the following decision procedure Ĉ:

1 1

1 1

| |K K

k ik i i j ij i ii i

g P P g P P

X X X X

1

1

| |

for arg min |ˆ

for otherwise

K

l il ii

k ll K

D

R P

k R dC

X X

XX

d is the value of the risk of not taking any action.

Discrimination functions gk(X) provide minimal risk decision

boundaries if good approximation to P(X|) probabilities are found.

Define conditional risk of performing action l given X

Page 5: Computational Intelligence:  Methods and Applications

Discriminating functionsDiscriminating functionsDiscriminating functionsDiscriminating functions

gk(X) may also be replaced by posterior probabilities; in the feature

space area where the lowest risk corresponds to decision i we have

gi(X) > gj(X), and gi(X) = gj(X) at the border.

Any monotonic function of P(i|X) may be used as discriminating f:

Some choices:

• Majority classifier

• maximum likelihood classifier

• MAP, Maximum A Posterior classifier

• minimum risk classifier (best)

ln | ln | ln ln ( )i i i ig P P P P X X X X

|

|

|

i i

i i

i i

i i

g P

g P

g P

g R

X

X X

X X

X X

Page 6: Computational Intelligence:  Methods and Applications

SummarySummarySummarySummary

Posterior probabilities is what we want:

Minimization of error may be done in a number of ways, for ex:

Minimization of risk takes into account cost of different types of errors:

using Bayesian decision procedure minimizes total/conditional risks.

Try to write risk for 2 class 1D problem with P(1)=2/3,

P(2)=1/3, P(X|1)=Gauss(0,1), P(X|2)=Gauss(2,2),

|| i i

i

P PP

P

XX

X

1 1

1 ; |K K

ii i ii i

E P E P C

X

X X

Likelihood x Prior Evidence

0 1

2 0

where Ci(X) = 1 if X is from class i, and 0 otherwise.

Page 7: Computational Intelligence:  Methods and Applications

1D Gaussians1D Gaussians1D Gaussians1D GaussiansSimplest application of Bayesian decisions: Gaussian distributions.

2 distributions, 1D, with the same variance, different means:

Discriminating function: log posteriors

2 21| exp / 2

2i iP X X

1 1

2 2

2 21 1

2 222

|ln ln

|

exp / 2ln ln

exp / 2

P X Pg X

P X P

X P

PX

1

2

|ln

|

P Xg X

P X

Page 8: Computational Intelligence:  Methods and Applications

1D Gaussians solution1D Gaussians solution1D Gaussians solution1D Gaussians solutionAfter simplifications:

2 211 2 1 2

2 22

ln2

Pg X X

P

g(X)>0 for class , g(X)<0 for class

1 20 2

X

For equal a priori probabilities g(X0)=0 in the middle

between the means of the two distributions. Otherwise it is shifted towards class with smaller prior:

211 2

01 2 2

ln2

PX

P

Page 9: Computational Intelligence:  Methods and Applications

dD GaussiansdD GaussiansdD GaussiansdD GaussiansMultivariate Gaussians:

Non-diagonal covariance matrix rotates the distributions.

Discriminant functions are quadratic:

1/ 2 1/ 2

1 1| exp

22

T

i i i id

i

P

X X μ X μ

1

1ln ln

21

2

i i i

T

i i i

g P

X

X μ X μ

Discriminant function is thus Mahalanobis distance from the mean + terms that take into account the prior probability and the variance.

DM(X,)=const

Page 10: Computational Intelligence:  Methods and Applications

Linear classifiersLinear classifiersLinear classifiersLinear classifiersIdentical covariance matrices => linear discrimination function:

where:

1 1

T0 0

1

1ln

2T T

i i i i i

ij j i i ij

g P

W X W W

X μ Σ X μ Σ μ

W X

T 1

10

1ln

2

i

Ti

Ti i i iW P

W μ Σ

μ Σ μ

This type of linear discrimination functions are used quite frequently, not only in statistical theories but also in neural networks, where: X are input signals, W are synaptic weights, and W0 is the neuron activation threshold.

Page 11: Computational Intelligence:  Methods and Applications

Special casesSpecial casesSpecial casesSpecial casesIf identical covariance matrices and identical a priori probabilities are assumed then Mahalanobis distance is obtained:

Weighted Euclidean distance function from the center of the Gaussian distribution serves as discriminating function.

Bayesian classifier becomes now a nearest prototype classifier:

1 ,T

i i i ig D X X μ Σ X μ X μ

2 2, ; 1/i j j ij j jj

D s X s X μ

Note: max g(X) min D(X,)

For diagonal covariance matrices distance becomes:

if arg min ,k ii

k D X X μ

Page 12: Computational Intelligence:  Methods and Applications

IllustrationIllustrationIllustrationIllustrationInfluence of priors on decision borders:

in 1 D

In 2D

In 3D

Note that decision borders are not between means.

Fig. 2.11, Duda, Hart, Stork

Page 13: Computational Intelligence:  Methods and Applications

Naive Bayesian classifierNaive Bayesian classifierNaive Bayesian classifierNaive Bayesian classifierHow to estimate probability densities required by Bayesian approach?

P(X|)=P(X1,X2..Xd|) in d-dimensions and b values/feature,

requires bd bins to estimated numerically density of the vectors!

In practice there is never enough data for that!

Instead of multidimensional function the problem is reduced to estimation of d one-dimensional Pi functions.

If the class is a disease than symptoms X1, X2, depends on the class but not directly on each other, so usually this may work.

It works for Gaussian density distributions for classes; perhaps feature selection has already removed correlated features.

1

| |d

k i i ki

P P X

X

Assume (naively) that all features are conditionally independent.

Page 14: Computational Intelligence:  Methods and Applications

NBNBNBNBEstimate (learn from data) the posterior probability:

If the overall result is positive than class 1 is more likely. Each feature has an additive, positive or negative, contribution.

For discrete or symbolic features P(Xi|) is estimated from histograms, for continuous features a single Gaussian or a combination of Gaussians is frequently fit to estimate the density.

1

| | |d

k kk i i k k

j

P PP P X P

P P

X XX X

Use the log-likelihood ratio:

1 1 1

12 2 2

| |ln ln ln

| |

di i

i i i

P P P X

P P P X

X

X

Page 15: Computational Intelligence:  Methods and Applications

NB Iris exampleNB Iris exampleNB Iris exampleNB Iris examplenbc(iris_type) = { prob(iris_type) = {

Iris-setosa : 50, Iris-versicolor: 50, Iris-virginica : 50 }; prob(sepal_length|iris_type) = {

Iris-setosa : N(5.006, 0.124249) [50], (Normal distribution)

Iris-versicolor: N(5.936, 0.266433) [50], (mean, std)

Iris-virginica : N(6.588, 0.404343) [50] };

prob(sepal_width|iris_type) = {

Iris-setosa : N(3.428, 0.14369) [50], Iris-versicolor: N(2.77, 0.0984694) [50], Iris-virginica : N(2.974, 0.104004) [50] };

prob(petal_length|iris_type) = { Iris-setosa : N(1.462, 0.0301592) [50], Iris-versicolor: N(4.26, 0.220816) [50], Iris-virginica : N(5.552, 0.304588) [50] };

prob(petal_width|iris_type) = { Iris-setosa : N(0.246, 0.0111061) [50], Iris-versicolor: N(1.326, 0.0391061) [50], Iris-virginica : N(2.026, 0.0754327) [50] };

Use RapidMiner, Weka, or applet: http://www.cs.technion.ac.il/~rani/LocBoost/

Page 16: Computational Intelligence:  Methods and Applications

NB on fuzzy XOR exampleNB on fuzzy XOR exampleNB on fuzzy XOR exampleNB on fuzzy XOR example

For demonstrations one may use WEKA, GhostMiner 3

or an applet: http://www.cs.technion.ac.il/~rani/LocBoost/

NB fails completely on such data – why?

P(X1,X2|k) probabilities

are needed, but they are more difficult to estimate.

Use local probability around your query point.

Page 17: Computational Intelligence:  Methods and Applications

NB generalizationNB generalizationNB generalizationNB generalizationIf the first-order (independent) feature model is not sufficient for strongly interacting features one can introduce second and third-order dependencies (to find interacting features look at covariance matrix).

Surprisingly:

• frequently adding explicit correlations makes things worse, presumably because difficulty in reliable estimation of two or three dimensional densities.

• NB is quite accurate on many data sets, and fairly popular, has many free software packages and numerous applications.

• Local approach: make all estimations only around X!

1 2 3 4 5 6| , | | , , | ...k i k i k i kP P X X P X P X X X X

This leads to graphical causal Bayesian network models.

Page 18: Computational Intelligence:  Methods and Applications

LiteratureLiteratureLiteratureLiteratureDuda, Hart & Stork Chap. 2 has a good introduction to the Bayesian decision theory, including some more advanced sections:

• on min-max, or overall risk minimization which is independent of prior probabilities;

• or Neyman-Pearson criteria that introduce constraints on acceptable risk for selected classes.

More detailed exposition of Bayesian decision and risk theory may be found in chapter 2 of:

S. Theodoridis, K. Koutroumbas, Pattern recognition (2nd ed)

Decision theory is obviously connected with hypothesis testing.

Chapter 3 of K. Fukunaga, Introduction to statistical pattern recognition (2nd ed, 1990), is probably the best source, with numerous examples.