Main Content

logp

Log unconditional probability density for discriminant analysis classifier

Description

lp = logp(Mdl,Tbl) returns the log Unconditional Probability Density (lp) of the observations (rows) in Tbl using the discriminant analysis classifier model Mdl. You can use lp to identify outliers in the training data.

lp = logp(Mdl,X) returns the log of the unconditional probability density of the observations (rows) in X using the discriminant analysis classifier model Mdl.

example

Examples

collapse 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

Input Arguments

collapse all

Trained discriminant analysis classifier, specified as a ClassificationDiscriminant model object trained with fitcdiscr, or a CompactClassificationDiscriminant model object created with compact.

Sample data, specified as a table. Each row of Tbl corresponds to one observation, and each column corresponds to one predictor variable. Categorical predictor variables are not supported. Optionally, Tbl can contain an additional columns for the response variable, which can be categorical. Tbl must contain all of the predictors used to train the model. Multicolumn variables and cell arrays other than cell arrays of character vectors are not allowed.

If you trained Mdl using sample data contained in a table, then the input data for logp must also be in a table.

Data Types: table

Predictor data, specified as a numeric matrix. Each row of X corresponds to one observation, and each column corresponds to one predictor variable. Categorical predictor variables are not supported. The variables in the columns of X must be the same as the variables used to train Mdl. The number of rows in X must equal the number of rows in Y.

If you trained Mdl using sample data contained in a matrix, then the input data for logp must also be in a matrix.

Data Types: single | double

More About

collapse all

Unconditional Probability Density

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

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

where P(k) is the prior probability of class k, P(x|k) is the conditional density of x given class k, and K is the total number of classes. The conditional density function of the multivariate normal with 1-by-d mean μk and d-by-d covariance Σk at a 1-by-d point x is

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

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

Version History

Introduced in R2011b