LogisticRegression.py 文件源码

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

项目:tinyml 作者: parasdahal 项目源码 文件源码
def predict(self, data, prob=False):
        """Computes the logistic probability of being a positive example

        Parameters
        ----------
        data : ndarray (n-rows,n-features)
            Test data to score using the current weights
        prob : Boolean
            If set to true, probability will be returned, else binary classification
        Returns
        -------
        0 or 1: int
            0 if probablity is less than 0.5, else 1
        """
        data = np.column_stack((np.ones(data.shape[0]), data))

        hypothesis = LogisticRegression.sigmoid(np.dot(data, self.theta))
        if not prob:
            return np.where(hypothesis >= .5, 1, 0)
        return hypothesis
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号