def __init__(self, classData, shrinkage=0):
"""Construct a new Linear Discriminant Analysis (LDA) classifier.
Args:
classData: Training data. This is a numpy array or list of numpy
arrays with shape (nCls,nObs[,nIn]). If the dimensions
index is missing the data is assumed to be
one-dimensional.
shrinkage: This parameter regularizes LDA by shrinking the average
covariance matrix toward its average eigenvalue:
covariance = (1-shrinkage)*covariance +
shrinkage*averageEigenvalue*identity
Behavior is undefined if shrinkage is outside [0,1].
This parameter has no effect if average is 0.
Returns:
A trained LDA classifier.
"""
Classifier.__init__(self, util.colmat(classData[0]).shape[1],
len(classData))
self.dtype = np.result_type(*[cls.dtype for cls in classData])
self.shrinkage = shrinkage
self.train(classData)
评论列表
文章目录