logreg.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:cebl 作者: idfah 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号