预测使用说criminant Analysis Models
预测
uses three quantities to classify observations:posterior probability,prior probability, and成本。
预测
classifies so as to minimize the expected classification cost:
where
是个预测ed classification.
K是个number of classes.
是个posterior probability of classkfor observationx。
是个成本的classifying an observation asywhen its true class isk。
The space ofX
values divides into regions where a classificationY
is a particular value. The regions are separated by straight lines for linear discriminant analysis, and by conic sections (ellipses, hyperbolas, or parabolas) for quadratic discriminant analysis. For a visualization of these regions, seeCreate and Visualize Discriminant Analysis Classifier。
Posterior Probability
The posterior probability that a pointxbelongs to classk是个product of theprior probability和the multivariate normal density. The density function of the multivariate normal with 1-by-d意思是μ.k和d-by-dcovariance Σkat a 1-by-d观点xis
where 是个determinant of Σk, and 是个inverse matrix.
让P(k) represent the prior probability of classk。Then the posterior probability that an observationx是课堂kis
whereP(x) is a normalization constant, namely, the sum overk的P(x|k)P(k).
Prior Probability
现有概率是三种选择之一:
'uniform'
— The prior probability of classk
is 1 over the total number of classes.'empirical'
— The prior probability of classk
是个number of training samples of classk
除以培训样本总数。A numeric vector — The prior probability of class
k
是个j
th element of thePrior
vector. Seefitcdiscr.
。
After creating a classifierobj
, you can set the prior using dot notation:
obj.Prior = v;
wherev
是表示每个元素发生的频率的正元素的矢量。在设置新的先前时,您无需重新定制分类器。
成本
There are two costs associated with discriminant analysis classification: the true misclassification cost per class, and the expected misclassification cost per observation.
True Misclassification Cost per Class
成本(i,j)
是个成本的classifying an observation into classj
if its true class isi
。By default,成本(i,j)= 1
if我〜= j
, and成本(i,j)= 0
if我= J.
。换句话说,是成本0
正确分类,和1
for incorrect classification.
您可以在创建分类器时设置您喜欢的任何成本矩阵。通过成本矩阵成本
name-value pair infitcdiscr.
。
After you create a classifierobj
, you can set a custom cost using dot notation:
obj.Cost = B;
B
is a square matrix of sizeK
-by-K
when there areK
classes. You do not need to retrain the classifier when you set a new cost.
Expected Misclassification Cost per Observation
Suppose you have谈判
observations that you want to classify with a trained discriminant analysis classifierobj
。Suppose you haveK
classes. You place the observations into a matrixXnew
with one observation per row. The command
[label,score,cost] = predict(obj,Xnew)
returns, among other outputs, a cost matrix of size谈判
-by-K
。Each row of the cost matrix contains the expected (average) cost of classifying the observation into each of theK
classes.成本(n,k)
is
where
K是个number of classes.
是个posterior probability的classifor observationXnew(n).
是个成本的classifying an observation askwhen its true class isi。