Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

logP

Class: CompactClassificationDiscriminant

Log unconditional probability density for discriminant analysis classifier

Syntax

lp = logP(obj,Xnew)

Description

lp = logP(obj,Xnew) returns the log of the unconditional probability density of each row of Xnew, computed using the discriminant analysis model obj.

Input Arguments

obj

Discriminant analysis classifier, produced using fitcdiscr.

Xnew

Matrix where each row represents an observation, and each column represents a predictor. The number of columns in Xnew must equal the number of predictors in obj.

Output Arguments

lp

Column vector with the same number of rows as Xnew. Each entry is the logarithm of the unconditional probability density of the corresponding row of Xnew.

Definitions

Unconditional Probability Density

The unconditional probability density of a point x of a discriminant analysis model is

P(x)=k=1KP(x,k),

where P(x,k) is the conditional density of the model at x for class k, when the total number of classes is K.

The conditional density P(x,k) is

P(x,k) = P(k)P(x|k),

where P(k) is the prior probability of class k, and P(x|k) is the conditional density of x given class k. The conditional density function of the multivariate normal with mean μk and covariance Σk at a point x is

P(x|k)=1(2π|Σk|)1/2exp(12(xμk)TΣk1(xμk)),

where |Σk| is the determinant of Σk, and Σk1 is the inverse matrix.

Examples

expand all

Construct a discriminant analysis classifier for Fisher's iris data, and examine its prediction for an average measurement.

Load Fisher's iris data and construct a default discriminant analysis classifier.

load fisheriris
Mdl = fitcdiscr(meas,species);

Find the log probability of the discriminant model applied to an average iris.

logPAverage = logP(Mdl,mean(meas))
logPAverage =

   -1.7254

Was this topic helpful?