def __init__(self, classData, average=0.0, shrinkage=0.0):
"""Construct a new Quadratic Discriminant Analysis (QDA) 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.
average: This parameter regularizes QDA by mixing the class
covariance matrices with the average covariance matrix.
A value of zero is pure QDA while a value of one
reduces to LDA.
shrinkage: This parameter regularizes QDA by shrinking each
covariance matrix toward the average eigenvalue of
the average covariance matrix.
Returns:
A trained QDA classifier.
"""
Classifier.__init__(self, util.colmat(classData[0]).shape[1],
len(classData))
self.dtype = np.result_type(*[cls.dtype for cls in classData])
# average regularization parameter
self.average = average
# shrinkage regularization parameter
self.shrinkage = shrinkage
self.train(classData)
评论列表
文章目录