def __init__(self, classData, weightInitFunc=pinit.runif,
optimFunc=optim.scg, **kwargs):
"""Create a new logistic regression 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.
weightInitFunc: Function to initialize the model weights.
The default function is the runif function in the
paraminit module. See the paraminit module for
more candidates.
optimFunc: Function used to optimize the model weights.
See ml.optim for some candidate optimization
functions.
kwargs: Additional arguments passed to optimFunc.
Returns:
A new, trained logistic regression classifier.
"""
Classifier.__init__(self, util.colmat(classData[0]).shape[1],
len(classData))
optim.Optable.__init__(self)
self.dtype = np.result_type(*[cls.dtype for cls in classData])
self.weights = weightInitFunc((self.nIn+1, self.nCls)).astype(self.dtype, copy=False)
self.train(classData, optimFunc, **kwargs)
评论列表
文章目录